0

I'm trying to run a virtual host for drupal and having trouble setting it's root files.

I have a file drupalDev.conf in /etc/apache2/sites-enabled/ configured:

    ServerName drupaltest
    DocumentRoot /var/www/drupal

This is the only enabled site.

In var/www/drupal I have all drupal files, including install.php. Accessing http://drupaltest returns the /var/www/html/index.html which apache uses by default. Accessing http://drupaltest/install.php returns 404.

How can I tell the server to use the files within /var/www/drupal ?

Other settings:

/etc/hosts is set:

127.0.0.1   localhost
127.0.0.1   drupaltest

/etc/appache2/appache2.conf is set:

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

Note: I've tried setting 000-default.conf to DocumentRoot /var/www but nothing changed. Note: Below you'll find my initial drupalDev.conf settings:

<IfModule mod_ssl.c>
    <VirtualHost _default_:443>
        ServerAdmin webmaster@localhost
        ServerName drupaltest

        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

    </VirtualHost>
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
0

Follow these steps, it will solve your problem-

1. create a file drupalDev.conf in /etc/apache2/sites-available

sudo gedit /etc/apache2/sites-available/drupalDev.conf

2. Paste following code in drupalDev.conf

<VirtualHost *:80>
        DocumentRoot /var/www/drupal
        ServerName drupaltest
        ServerAlias drupaltest
        ServerAdmin admin@drupaltest

        <Directory /var/www/drupal/>
                Options Indexes MultiViews FollowSymLinks
                AllowOverride All
                allow from all
        </Directory>
</VirtualHost>

3. Run following command to enable drupalDev.conf

sudo a2ensite drupalDev.conf

4. Restart apache2 service

sudo service apache2 restart

5. Browse new created host domain in browser

http://drupaltest

Note : You may need to change file permission of /var/www/drupal to 777

sudo chmod 777 /var/www/drupal

  • It worked thanks. had to erase everything from drupalDev.conf and paste what you wrote. I will edit my question and write all the code from my initial drupalDev.conf file that didn't work. Can you briefly explain what changes made it work and why? – wr43th13 Jan 31 '16 at 10:54
  • Did you perform Step 3 & 4 with your previous drupalDev.conf ? – Anuj TBE Jan 31 '16 at 11:55
  • Also there is DocumentRoot and <Directory> tags navigating to root folder is missing in your VirtualHost. This tells the server, which directory is to navigate on visiting http://drupaltest – Anuj TBE Jan 31 '16 at 11:59
  • Yes, I did perform steps 3 and 4, only instead of restart I ran reload. Thanks for the insight. – wr43th13 Jan 31 '16 at 14:30

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.