I have tried following every tutorial I can find and I can’t seem to get the WordPress one click setup to serve files from a different directory besides the default /var/www/html.

I have used a2dissite, a2ensite, reloaded, restarted apache. The properties in the config file ServerName, etc.

One interesting detail is that when I ran a2dissite 000-default.conf came back with an error to the effect that the corresponding file in sites-enabled was not symlinked. Which is weird since creating new .conf files in sites-available does seem to symlink them into sites-enabled. I have setup these files on other droplets and had no problems. Is this something unique to this pre configured droplet?

I scrapped my first droplet - I had deleted all the original default .conf files in frustration and apache was, in my opinion, still using one of them. It was looking for a directory that I had deleted, which though an error, but that directory was not pointed to in any of the configurations that were supposed to be active.

This is my /etc/apache2/sites-available/mydomain.conf file.

<VirtualHost *:80>
    ServerAdmin ben@mydomain
    DocumentRoot /var/www/html.old
    ServerName mydomain
    ServerAlias www.mydomain
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /var/www/html.old/>
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

The only way I found to serve something else is to change the contents of /var/www/html. This is not ideal, since my next move is to get multiple sites running with subdomains. As of right now I am getting by but starting to get frustrated with the learning curve.

Any help would be greatly appreciated. Thanks.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hello,

What I could suggest is the following:

  • First run an Apache config test to make sure that there are no problems with your configuration:
apachectl -t
  • Share the output of the following command here:
ls -l /etc/apache2/sites-enabled
  • Access your site and right after that check your Apache error log:
tail -100 /var/log/apache2/error.log
  • Make sure that your Apache user has permissions to read and write to the /var/www/html.old folder:
chown -R www-data:www-data /var/www/html.old

Let me know how it goes!
Regards,
Bobby

  • I think you are on the right track. I am work right now and don’t have ssh set up here, I will try your advice when I get home.

    I must have missed the part about permissions. I know for a fact that after I used scp to transfer my local WordPress files to the server that the directories were owned by me. My big problem is I’m a newb. I know I want to check a log but I have no idea where it is for the most part. I don’t know all the commands I need to know, and my understanding of the whole system is incomplete. Learning curve.

    I guess now that I think about, my other droplets were all Node based running Nginx, not Apache, so I was wrong that I had configured Apache before.

    Thanks for the quick response and I will report back soon.

  • So I got it working. At least a single site (other than default site) that I uploaded with scp. It seemed to be a combination of two things.

    1. I permissions on the new WordPress files. The achieve_medical is the WordPress I uploaded and html.old was more of a test case for configs.
    drwxr-xr-x  6 www-data www-data 4096 Feb 11 03:48 achieve_medical/
    drwxr-xr-x  5 www-data www-data 4096 Feb 10 12:27 html/
    drwxr-xr-x  2 www-data www-data 4096 Jan 28 23:01 html.old/
    
    1. When I ran sudo a2dissite 000-default.conf I was getting an error/message basically saying it was refusing to delete the sites-enabled/000-default.conf file. This is how One Click install shipped. For whatever reason, Apache wanted to use this default config despite me using sudo a2ensite mydomain.conf. I just deleted the default configs and it worked.

    apachectl -t

    When I try to run the config test I get this. But the https seems to work and the browser says the cert is good.

    AH00526: Syntax error on line 16 of /etc/apache2/sites-enabled/mydomain.com-le-ssl.conf:
    SSLCertificateFile: file '/etc/letsencrypt/live/mydomain.com-0001/fullchain.pem' does not exist or is empty
    Action '-t' failed.
    The Apache error log may have more information.
    

    ls -l /etc/apache2/sites-enabled

    lrwxrwxrwx 1 root root 58 Feb 11 04:07 mydomain.com-le-ssl.conf -> /etc/apache2/sites-available/mydomain.com-le-ssl.conf
    lrwxrwxrwx 1 root root 41 Feb 11 03:40 mydomain.com.conf -> ../sites-available/mydomain.com.conf
    

    The only thing of note in the apache error logs is:

    AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
    

    In any event I am pleased just to have the site I want up and running. Thanks for the help!

Submit an Answer