Laravel 4: Working directly on web server - php

Now I've searched and played around cannot get my head around what is going on.
I am unable to install a local webserver (XAMPP or w/e) onto this laptop, so I am hoping to have a play with Laravel 4 directly on my dedicated box.
I have a Linux box (Debian) with Apache, Composer and PHP 5.4.4 installed. Plenty of other websites up and running on this.
I have installed Laravel 4, via Composer directly into a directory: public_html/dev/
Apache is set-up so the sub-domain dev.mydomain.com points to this directory.
Going to dev.mydomain.com, or dev.mydomain.com/public/ (anything in-fact) gives me a 403 Forbidden error.
My apache config file:
<VirtualHost (my ip)>
ServerAdmin webmaster#localhost
ServerName dev.mydomain.com
DocumentRoot /home/user/public_html/dev
Options -Indexes -FollowSymLinks -MultiViews
</VirtualHost>
I've tried chmod 777 to public, the document root to /home/user/public_html/dev/public but with no luck.
Unless I'm missing the point of something here, or some security problem (since working on a live server isn't great) then please tell me, I'm probably being a noob.

Try this
<VirtualHost *:80>
DocumentRoot /home/user/public_html/dev/public
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/user/public_html/dev/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>

You had -FollowSymLinks, and i assume this applies to also the rewrite rule that comes default with laravel. (.htaccess file) removing the -Follosymlinks would have fixed it for you too i presume.

Related

Set up a local server on an external hard drive - Forbidden error

I have a Mac OSX El Capitan operating system. Since my laptop has limited space, I am trying to set up a local server on my 1TB external hard drive with the url http://media.database/, and that uses PHP. I have set it up the best I know how, but when I go to the page, it says "Forbidden You don't have permission to access /index.php on this server."
I have set apache and host files as best I know how, but I'm still pretty new to this sort of thing. I have listed my updates to those files below and restarted the apache server using sudo apachectl restart, which has gotten me this far. Can someone enlighten me on what I might be missing. All help is greatly appreciated.
/etc/apache2/httpd.conf
<VirtualHost *:80>
ServerName media.database
DocumentRoot "file:///Volumes/DBTARA/media/"
<Directory "file:///Volumes/DBTARA/media/">
DirectoryIndex index.php index.html
AllowOverride all
Options -MultiViews
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
/etc/hosts
127.0.0.1 media.database
/etc/apache2/users/vmbmacintosh.conf
<Directory "file:///Volumes/DBTARA/media/">
AllowOverride All
Options Indexes MultiViews FollowSymLinks
Require all granted
</Directory>
/etc/apache2/httpd.conf
I attempted to add the following DocumentRoot after the one I already have, but that made my other local servers inaccessible and kept the external one as forbidden.:
DocumentRoot "file:///Volumes/DBTARA/media"
<Directory "file:///Volumes/DBTARA/media">
Options FollowSymLinks Multiviews
MultiviewsMatch Any
AllowOverride None
Require all granted
</Directory>
Thanks again in advance for any assistance.

Need some assistance with my apache2 site config file

I'm trying to get apache2 to point to a PHP based application (word press in this case but the config needs to be generic enough to work for any php application).
and it either displays some basic HTML file access page or errors with "You don't have permission". I don't really know apache and I don't know PHP at all. Here's my current site_config file as it stands(with retractions replaced with ):
<VirtualHost *:80>
ServerAdmin <app_user>#localhost
ServerName amazonaws.com/<app_name>
ServerAlias *.amazonaws.com/<app_name>
DocumentRoot /home/<app_user>/<app_location>/staging/current
<Directory /home/<app_user>/<app_location>/staging/current >
AllowOverride All
Options -Indexes
Order allow,deny
Allow from all
</Directory>
LogLevel error
ErrorLog ${APACHE_LOG_DIR}/error.log
</VirtualHost>
I would also like to make it so you can have multiple websites on the same box but I'm not sure how to change the VirtualHost arg *:80 to account for that, I just get loads of ignoring errors.
I also have the following line in my apache2.conf:
DirectoryIndex index.php index.html
Folder permissions are set to 0755 for all files & folders in the project directory
output of apache2 -v:
Server version: Apache/2.4.7 (Ubuntu)
P.s. I know nothing about PHP and very little about apache2 so for this, speak to me as a total noob.
To solve The first problem I had to change the following lines:
Order allow,deny
Allow from all
to:
Require all granted
this finally allowed apache to allow users access to the folders, the second thing was to add an alias:
Alias /<app_name> "/home/<app_user>/<app_location>/staging/current"
and it started working as expected so now my site config looks like:
Alias /<app_name>"/home/<app_user>/<app_name>/<app_environment>/current"
<Directory "/<app_name>"/home/<app_user>/<app_name>/<app_environment>/current">
AllowOverride All
Options -Indexes
Require all granted
</Directory>
<VirtualHost *:80>
DocumentRoot "/<app_name>"/home/<app_user>/<app_name>/<app_environment>/current"
ErrorLog "/var/log/apache2/<app_name>.error_log"
CustomLog "/var/log/apache2/<app_name>.access_log" combined
</VirtualHost>

Laravel 5.2 Routes Not Working

I just moved a homestead laravel installation to my own vps setup.
Everything is working fine on the homepage (XX.XX.XX.XX/public).
But when i click ay links on the homepage it goes to XX.XX.XX.XX/link
instead of XX.XX.XX.XX/public/link as i whould think it should.
I have a local setup with homestead and a link like this one XX.XX.XX.XX/signin whould work fine.
And when i try XX.XX.XX.XX/public/signin on the vps it gives a 404 error.
In my sites-available i have setup the below .conf file.
<VirtualHost *:80>
ServerName XX.XX.XX.XX/app.domain.dk
DocumentRoot /var/www/app.domain.dk/public
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/app.domain.dk/public>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
What could be the problem, please help me : )
The problem is in wrongly configured web server. You should point web server to a laravel_project/public directory and use URLs like XX.XX.XX.XX/link instead of XX.XX.XX.XX/public/link.
For Apache you can use these directives:
DocumentRoot "/path_to_laravel_project/public"
<Directory "/path_to_laravel_project/public">
Don't forget to restart web server.
Solved.
I figured out i was missing a forward slash in my .conf file.
So it should be /var/www/app.domain.dk/public/
Thanks for the help everybody :)

MySQL not working with virtualhost

I'm working locally on my Macbook Pro using XAMPP and I'm trying to setup virtualhosts so that I can work on multiple projects more easily.
Everything appears to be working fine except I can't connect to MySQL through PHPMyAdmin and on the XAMPP control panel it says MySQL isn't running. However, I can access MySQL through an application I have in my htdocs folder. When I access phpmyadmin through localhost/phpmyadmin the CSS is loaded and PHPMyAdmin appears to be located, but MySQL can't connect so I'm not quite sure where the issue lies (considering I can connect through my application)
Upon going to localhost/phpmyadmin I get the following error
#2002 - No such file or directory
The server is not responding (or the local server's socket is not correctly configured).
The thing is, I can access the database just fine through the application. I can log in, save and do any other sort of interactions with the database.
Here's what I have in my httpd-vhosts.conf file
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/test1"
ServerName localhost
<Directory /Applications/XAMPP/xamppfiles/htdocs/test1>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName pma
DocumentRoot "/Applications/XAMPP/xamppfiles/phpmyadmin"
<Directory /Applications/XAMPP/xamppfiles/phpmyadmin>
Options FollowSymLinks
DirectoryIndex index.php
<IfModule mod_php5.c>
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_value include_path .
</IfModule>
</Directory>
</VirtualHost>
Now for a summary
I set up virtualhosts for apache on my Macbook
The virtualhost setup appears to be working fine for the application I have in my htodcs folder, and it can connect to the database. I can log in, save data and all that stuff.
When I browse to localhost/phpmyadmin I get a MySQL connection error. If I browse to pma/phpmyadmin (the virtualhost I tried to create) Chrome and Firefox just search google for it instead of recognizing the alias (is that the correct term?)
I ran into the same thing with a WAMP server. I solved it by putting back the original "out of the box" server settings:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "c:/Apache2/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
And then for each project used code such as:
<VirtualHost *:80>
ServerAdmin admin#localhost
DocumentRoot "C:/wamp/projectname"
ServerName localhost
ServerAlias projectname.here
<Directory "C:/wamp/projectname">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Order allow,deny
Allow from all # <-- used for Apache 2.2
#Require all granted #<-- used for Apache 2.4+
</Directory>
</VirtualHost>
For different projects, just duplicate the last set of code for each project, renaming the DocumentRoot, ServerAlias and Directory path. You will notice the "ServerAlias" line; this is what made Apache serve up the project when entering the alias in the web browser. I found the explanation here which ironically was in the httpd-vhosts.conf file.
Also, please note that my research recommends for higher versions of Apache to use Require all granted in place of Allow from all as commented in the code above.
All of this code is in the httpd-vhosts.conf file, which on my Windows 7 installation is at c:\wamp\bin\apache\Apache2.2.21\conf\extra directory. Since you are using a Macbook and have already identified the location, I just put this in for other's reference.

Error web debug toolbar

I have recently upgraded the Ubuntu OS (10.04 -> 12.04) in my development workstation, and know I'm getting trouble in running the project I'm working on. I think it's some permission related problem. The fact is that I already have it running with no problems in a production server.
Is there any tool I can check project's folder permissions for errors, more or less like "symfony project:permissions" in Symfony 1 ?
I'm getting a css troubled first page in my dev frontend and a JS alert that reads:
An error occurred while loading the web debug toolbar (404: Not Found). Do you want to open the profiler?
The web folder .htacess is the same from the working production environment and I have an apache configuration equal to production only with ssl disabled.
Edit:
Virtual Host configuration:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
#<Directory />
# Options FollowSymLinks
# AllowOverride None
#</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
AcceptPathInfo On
Order allow,deny
allow from all
</Directory>
Alias /myproject /home/nelson/des/php/myproject/Symfony/web
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel debug
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The "AcceptPathInfo On" was included in an attempt to solve. I already tried with and without it.
Any help apreciated
It seems that you haven't published your assets (css, js, images...)
Try the following from command line in the root folder of Symfony :
php app/console assets:install web/ --symlink
Also, check that the rewrite mod is enabled : a2enmod rewrite
EDIT: Given your VirtualHost config file, it seems that you gave the wrong folder to Apache. You configuration must point to the web folder of Symfony2. For example :
<VirtualHost *:80>
DocumentRoot /home/myuser/www/Symfony/web
<Directory /home/myuser/www/Symfony/web>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
#......
</VirtualHost>

Categories