mfhamdane
By:
mfhamdane

Symfony2 project working on a vm with url rewriting (http://symfonyblog.vm/login) but not on DigitalOcean: http://symfonyblog.mfhamdane.com/symfonyblog.mfhamdane.com/public_html/web/login, it should be http://symfonyblog.mfhamdane.com/login

November 29, 2014 952 views

I followed all relevant DigitalOcean tutorials, it is not working. I've even deleted and recreated droplets several times. Below, Apache configuration in vhosts, in etc/apache2/sites-available.
1) in 000-default.conf, DocumentRoot = /var/www
2) in symfonyblog.mfhamdane.com.conf, see below:
<VirtualHost *:80>
ServerAdmin mfhamdane@hotmail.com
ServerName symfonyblog.mfhamdane.com
DocumentRoot /var/www/symfonyblog.mfhamdane.com/public_html/web

    DirectoryIndex app.php
    <Directory /var/www/symfonyblog.mfhamdane.com/public_html/web>
            Options -Indexes
            AllowOverride All
            Order allow,deny
            Allow from all
    </Directory>

    <IfModule mod_rewrite.c>
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ app.php [QSA,L]
    </IfModule>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Other Linux commands:
malik@symfonyblog:/$
sudo chown $USER:$USER /var/www/symfonyblog.mfhamdane.com/public_html

malik@symfonyblog:/$ sudo chmod -R 755 /var/www

malik@symfonyblog:/var/www$ sudo a2ensite symfonyblog.mfhamdane.com.conf

malik@symfonyblog:/var/www/symfonyblog.mfhamdane.com/public_html$
sudo a2enmod rewrite

malik@symfonyblog:/var/www/symfonyblog.mfhamdane.com/public_html$
sudo service apache2 restart

Removing cache and resetting ACL permissions:
malik@symfonyblog:/var/www/symfonyblog.mfhamdane.com/publichtml$
sudo rm -rf app/cache/*
malik@symfonyblog:/var/www/symfonyblog.mfhamdane.com/public
html$
sudo rm -rf app/logs/*
malik@symfonyblog:/var/www/symfonyblog.mfhamdane.com/publichtml$
sudo setfacl -R -m u:malik:rwX -m u:whoami:rwX app/cache app/logs
malik@symfonyblog:/var/www/symfonyblog.mfhamdane.com/public
html$
sudo setfacl -dR -m u:malik:rwX -m u:whoami:rwX app/cache app/logs

clearing cache in prod environment:
malik@symfonyblog:/var/www/symfonyblog.mfhamdane.com/public_html$
php app/console cache:clear --env=prod

And of course, original Symfony .htaccess is in the web folder.

Like I said, it works fine in the virtual machine. On DigitalOcean, one can access file index + there no url rewriting.
Help will be much appreciated as I cannot leave this site as it is.

Be the first one to answer this question.