0

I isntalled a local LAMP system and basically copied my site into /var/www/ for some local "experiments" (without messing around with the live site). I've mirrored the db and everything. Now when I go to http://127.0.0.1/ my home page is loaded well but all the links (e.g. http://127.0.0.1/content/lodge) won't load, I just get 404 Not Found. I assume I'm missing some kind of php or apache setting.

edit1

I did

sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart

but this didn't seem to have made a change at all. Now within /etc/apache2/sites-available/ I have two files 000-default.conf, default-ssl.conf.
000-default.conf contains:

ServerAdmin webmaster@localhost
DocumentRoot /var/www
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

and default-ssl.conf contains

ServerAdmin webmaster@localhost    
DocumentRoot /var/www
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile      /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

and I'm not exactly sre where to add AllowOverride All, can you be a little more specific?

Oh and .htaccess is in /var/www/ too

edit 2

okay, now what I did, I installed a fresh copy of drupal in http://127.0.0.1/alternatives/Quaaout/ and if I use the original site folder with a new db, urls like http://127.0.0.1/alternatives/Quaaout/?q=user work just fine! But if I use my site/ directory from the live site, this url automatically leads me to a 404 at page http://127.0.0.1/alternatives/Quaaout/user and the difference makes which database I have setup in my settings.php - with the new db from the fresh copy, ?q=user works fine, with the live copy it doesn't. So I thought it may be the url redirections I have setup in table redirect but I cleared it and it still didn't work. So it's not the redirections, what else would be causing this?

  • 1
    You probably have to set Clean url drupal.org/getting-started/clean-urls (link like 127.0.0.1/q=user works?) – arrubiu Feb 19 '14 at 14:56
  • 1
    Have you checked that http://127.0.0.1/?q=content/lodge is working fine? – Jayendra Kainthola Feb 20 '14 at 4:45
  • @JayendraKainthola Yes but that doesn't work either, I don't know what's going on exactly here... :o – stdcerr Feb 20 '14 at 13:45
  • @arrubiu I followed that guide, thanks but it didn't solve the issue as 127.0.0.1/q=user doesn't work for me either... – stdcerr Feb 20 '14 at 13:46
  • Please check your .htaccess file and settings for RewriteBase. I also found this type of error when I setup local site from live server. I need to comment RewriteBase in .htaccess file. You also need to check clean url setting in admin of the site to verify mod_rewrite is working fine in your server. – Jayendra Kainthola Feb 21 '14 at 5:29
1

here's a copy of a working vhost file (000-default.conf):

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www
    <Directory />
            Options FollowSymLinks
            AllowOverride All
    </Directory>
    <Directory /var/www>
            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 All
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            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

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>

2

Make sure apache has mod_rewrite enabled, and that the drupal .htaccess file is there in your drupal root. If you're on debian/ubuntu, you should be able to do:

sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart
  • 1
    You may also have to go to /etc/apache2/sites-available and edit the virtual hosts there. The directory entries should contain [AllowOverride All] (without the brackets). Restart apache to make changes take effect. – Ollie Feb 19 '14 at 18:12
  • See my answer below (needed to add new answer to allow code) – Ollie Feb 20 '14 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.