Reputation: 2848
Ok, so I'm trying to setup Symfony 2 demo application on my local machine. I use apache 2.2 web-server and I downloaded project's files into my ~/myproject/ directory (in my Home folder). As Symfony documentation reccomends here http://symfony.com/doc/current/cookbook/configuration/web_server_configuration.html I created file "myproject" in /etc/apache2/sites-available/ with following contents:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName myproject
ServerAlias www.myproject
DocumentRoot /home/dmitriy/myproject/web
<Directory /home/dmitriy/myproject/web>
# enable the .htaccess rewrites
AllowOverride All
Order allow,deny
Allow from All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
I disabled default apache config and enabled "myproject" by running
sudo a2dissite default && sudo a2ensite mysite
after that I restarted apache
sudo /etc/init.d/apache2 restart
Now, symfony demo project ships with .htaccess file in web/ directory and here is its contents:
DirectoryIndex app.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 302 ^/$ /app.php/
</IfModule>
</IfModule>
In my understanding I should now be able to see the project's index page by address "www.myproject" or just "myproject" right? Because of these two lines
ServerName myproject
ServerAlias www.myproject
but that doesn't work, and when I try that the browser shows some google results. When I try to prepend localhost/ I get 404 and only when I type localhost/app_dev.php or localhost/config.php I can see the real pages but it is not the way it should work is it? Something is wrong and apparently I made a mistake at some point but I lack experience and to it.
Upvotes: 0
Views: 198
Reputation: 2848
I forgot to edit my /etc/hosts file. After adding 127.0.0.1 myproject www.myproject
it finally worked!
Upvotes: 1