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>
Related
I inherited a php/Laravel app that was running on an Apache server that I don't have access to. My task is to get it running on another Apache server. I'm pretty good with php but relatively new to Laravel and very new to Apache configuration.
I have figured out how to get the Laravel app running on Apache that is running on an Ubuntu VM (VirtualBox.) I can access the Laravel app in a browser on the Ubuntu VM via http://localhost. I can also access the Laravel app in a browser from the Internet via http://appname.com/public. However, if I just use http://appname.com, then I just get a folder listing of /var/www/appname.
I have tried several modifications to the /etc/apache2/available-sites/appname.conf file but haven't quite got it right yet, apparently. I have also read a number of posts around the nets about making modifications to various other config files including php config files and Apache config files. It seems like these other mods (while they may be workable) shouldn't be necessary.
Here is my current /etc/apache2/available-sites/appname.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName appname.com
ServiceAlias www.appname.com
DocumentRoot /var/www/appname/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Any advise is appreciated.
Bob
You need to allow the mod_rewrite in the apache server and allowSymLinks.
Source
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName appname.com
ServiceAlias www.appname.com
DocumentRoot /var/www/appname/public
<Directory "/var/www/appname/public">
Options FollowSymLinks
ReWriteEngine On
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
in the DocumentRoot Directory i would also allow MultiViews
<Directory "/var/www/appname/public">
Options FollowSymLinks MultiViews
ReWriteEngine On
</Directory>
You may need to also do
sudo a2enmod rewrite
to enable module rewrite.
Edit 1:
In my .conf files i got them with the quotes and they are working.
Did you enable the modudle rewrite?
Besides some options i also have the "/" folder with the next config.
<Directory "/">
Options FollowSymLinks
AllowOverride All
ReWriteEngine On
</Directory>
and here i'll write my full code of public directory
<Directory "/var/www/appname/public">
Options FollowSymLinks MultiViews
Order Allow,Deny
Allow from all
ReWriteEngine On
</Directory>
Try it and see if it works, after delete the options that you don't like to use.
Follow the steps and all will be good and easy,
1). Type following command in terminal
cd /etc/apache2/sites-available
2). Make a new config file
sudo cp 000-default.conf appname.dev.conf
3. Open the new config file and paste the following code
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin yourmail#example.com
ServerAlias appname.dev
DocumentRoot /var/www/html/appname/public
<Directory /var/www/html/appname/public>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
<FilesMatch \.php$>
#Change this "proxy:unix:/path/to/fpm.socket"
#if using a Unix socket
#SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
4). CTRL+x, then press y then press enter and run following command in terminal
sudo a2ensite appname.dev.conf
5). Type following command and edit the /etc/hosts file
sudo nano /etc/hosts
127.0.0.1 appname.dev
press CTRL x then press Enter and type following command
sudo service apache2 restart
6). Now your app will execute on appname.dev successfully.
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>
I have just gone through the Symblog tutorials on http://tutorial.symblog.co.uk/docs/customising-the-view-more-with-twig.html
In prod mode, if i access the url like so:
http://local.mysite.co.uk
I get the home page with links to all the blog posts.
However if i click one of the blog posts then I get a 404, in fact any of the links (to the about or contact) all return a 404, eg:
http://local.mysite.co.uk/12/a-day-with-symfony2
If I then access the prod mode via the app_dev.php all the links work again, ie:
http://local.mysite.co.uk/app.php/12/a-day-with-symfony2
I have run to ensure the mod rewrites should be working and restarted apache but no joy.
sudo a2enmod actions
Does anyone know why this might be happening?
Thanks,
John
PS: This is the current vhost file for the dev site i am learning with (Ubuntu lts, apache 2.4, php 5.4ish)
<virtualhost *:80>
# Admin email, Server Name (domain name) and any aliases
ServerAdmin webmaster#domain.com
ServerName mysite.co.uk
ServerAlias www.mysite.co.uk
ServerAlias local.mysite.co.uk
# Index file and Document Root (where the public files are located)
DirectoryIndex app.php
DocumentRoot /var/webroot/www/vhosts/mysite.co.uk/htdocs/Symfony/web/
# Custom log file locations
LogLevel warn
ErrorLog /var/webroot/www/vhosts/mysite.co.uk/log/error.log
CustomLog /var/webroot/www/vhosts/mysite.co.uk/log/access.log combined
</virtualhost>
When I add an AllowOverride All to the vhost file and restart apache I get the follwoing error:
* Starting web server apache2
*
* The apache2 configtest failed.
Output of config test was:
AH00526: Syntax error on line 15 of /etc/apache2/sites-enabled/mysite.co.uk.conf:
AllowOverride not allowed here
Action 'configtest' failed.
The Apache error log may have more information.
Altering the vhost worked (thanks to https://stackoverflow.com/users/308825/maerlyn).
Placing a directory tag with the Allowoverride All fixed the issue. Seems that the rewrites are specific to each vhost.
Here is my config for the symfony tutorial which is now functioning in prod mode:
<directory /var/webroot/www/vhosts/mysite.co.uk/htdocs/Symfony/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</directory>
<virtualhost *:80>
# Admin email, Server Name (domain name) and any aliases
ServerAdmin webmaster#domain.com
ServerName mysite.co.uk
ServerAlias www.mysite.co.uk
ServerAlias local.mysite.co.uk
# Index file and Document Root (where the public files are located)
DirectoryIndex app.php
DocumentRoot /var/webroot/www/vhosts/mysite.co.uk/htdocs/Symfony/web/
# Custom log file locations
LogLevel warn
ErrorLog /var/webroot/www/vhosts/mysite.co.uk/log/error.log
CustomLog /var/webroot/www/vhosts/mysite.co.uk/log/access.log combined
</virtualhost>
OK I am new to ASKING questions on stackoverflow, but I need to get this figured out. I have a VPS with Apache installed Running Ubuntu 12.04 LTS. I downloaded a php script which required php 5.4+ but I had 5.3 installed. Then I followed the instructions located at this link.
While doing the upgrade, the installer told me that my php.ini file was manually changed. I believe I did this in order to view the errors on screen with the "display_errors=on" variable a long time ago. I therefore selected the option to KEEP and USE the old version of php.ini. Once the installation was done and the apache server restarted. I went to my chrome browser and pressed "refresh" and to my dismay, "403 Forbidden".
Here is the conf file for the virtual server:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /home/{usr}/Public/
# Indexes + Directory Root.
DirectoryIndex index.html index.shtml index.php
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory /home/{usr}/Public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /home/{usr}/Public/log/{server}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /home/{usr}/Public/log/{server}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
I obscured the username to {usr} and the folder to {server} to keep anonymity. This file was created BY ME, by putting it together with some other example file. I'm not sure if this is correct, all I know is that before this upgrade, everything was working fine!
I also "LL"'d the "Public" folder and here's what I found:
drwxrwxrwx 28 {usr} {usr} 4096 Sep 4 01:09 Public/
It seems that all the folders under it have the same permission. Please help and if there are any questions, feel free to ask. I've been doing this for many years but by no means would I call myself an "expert".
Thanks in advance.
Did you also upgrade Apache 2 ?
Apache 2.4 has a new user rights policy system : http://httpd.apache.org/docs/2.4/upgrading.html#run-time
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.