So I’m trying to get a second website working on my droplet. I sorted out the DNS settings then followed this tutorial for setting up a virtual host (https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-18-04) and others but nothing seems to have changed. my initial website works fine but my new domain just shows a generic “server not found” error.
In my /etc/apache2/sites-available
folder I have made two new config files
website1.net.conf
and website2.com.conf
, but I left the original config files 000-default.conf
and 000-default-le-ssl.conf
in there too just in case.
website1.net.conf
<VirtualHost *:80>
ServerName website1.net
ServerAlias www.website1.net
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =website1.net [OR]
RewriteCond %{SERVER_NAME} =www.website1.net
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
website2.com.conf (new website)
<VirtualHost *:80>
ServerName website2.com
ServerAlias www.website2.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/website2
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I also noticed that my apache error logs have a tun of errors on the new domain that look like…
[Fri Sep 20 13:47:03.989320 2024] [php:error] [pid 2458530] [client xx.xxx.xxx.xxx.xxxx] script '/var/www/website2/item.php' not found or unable to stat
[Fri Sep 20 13:47:04.001638 2024] [php:error] [pid 2458530] [client xx.xxx.xxx.xxx.xxxx] script '/var/www/website2/cache-compat.php' not found or unable to stat
[Fri Sep 20 13:47:04.016350 2024] [php:error] [pid 2458530] [client xx.xxx.xxx.xxx.xxxx] script '/var/www/website2/abouts.php' not found or unable to stat
[Fri Sep 20 13:47:04.031104 2024] [php:error] [pid 2458530] [client xx.xxx.xxx.xxx.xxxx] script '/var/www/website2/gel4y.php' not found or unable to stat
[Fri Sep 20 13:47:04.102058 2024] [php:error] [pid 2458530] [client xx.xxx.xxx.xxx.xxxx] script '/var/www/website2/wp-cron.php' not found or unable to stat
[Fri Sep 20 13:47:04.126998 2024] [php:error] [pid 2458530] [client xx.xxx.xxx.xxx.xxxx] script '/var/www/website2/alfanew.php' not found or unable to stat
[Fri Sep 20 13:47:04.141013 2024] [php:error] [pid 2458530] [client xx.xxx.xxx.xxx.xxxx] script '/var/www/website2/log.php' not found or unable to stat
[Fri Sep 20 13:47:04.151789 2024] [php:error] [pid 2458530] [client xx.xxx.xxx.xxx.xxxx] script '/var/www/website2/tinyfilemanager.php' not found or unable to stat
[Fri Sep 20 13:47:04.162970 2024] [php:error] [pid 2458530] [client xx.xxx.xxx.xxx.xxxx] script '/var/www/website2/rbzccnnp.php' not found or unable to stat
and I dont understand what it means or why the server thinks those files on my new site exist when I’ve never seen those files before.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Hey!
As far as I can see from the log output, the
not found or unable to stat
message indicates that the Apache web service is unable to read the files in the/var/www/website2
directory. Basically, it seems like your Apache logs are complaining about missing files in /var/www/website2. Make sure that the directory exists and the permissions are set correctly:After adding the two virtual hosts did you enable them with:
Also you might need to do a quick restart after that:
Also in some cases, browsers like Chrome will automatically forward your traffic to HTTPS, so if only one of the sites has an SSL certificate you might not see the incorrect content. So make sure to install SSL certificates for the two domain names just in case:
Let me know how it goes!
- Bobby