Everything was OK before I add a second website - Using Apache virtual host
Hello there!
I would love to count with your help if possible.
I am experiencing an issue here with my Linux/Apache server.
I had one website hosted until yesterday, using virtual host. So I've added a second website, and things started going wrong.
Well, the first website is ok, but the second one is not loading. I can see only a blank page. And it's a WordPress site, it's important to note, I think.
I can check the logs (access and error) but can't decide what is wrong or not.
Also, I am posting both virtual hosts files so you could take a look and maybe try to see what is wrong, if possible:
Vhost site 1
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName domain1.com
ServerAlias www.domain1.com
Protocols h2 http/1.1
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/domain1.com/public_html
<Directory /var/www/html/domain1.com/public_html>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog /var/www/html/domain1.com/logs/error.log
CustomLog /var/www/html/domain1.com/logs/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
<Location /server-status>
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from localhost
</Location>
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.domain1.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
<Directory /var/www/html/domain1.com/public_html/>
Require all granted
AllowOverride All
</Directory>
</VirtualHost>
Virtual host site 2:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName domain2.com
ServerAlias www.domain2.com
Protocols h2 http/1.1
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/domain2.com/public_html
<Directory /var/www/html/domain2.com/public_html>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog /var/www/html/domain2.com/logs/error.log
CustomLog /var/www/html/domain2.com/logs/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.domain2.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
Well, I would really appreciate any help because I am a little lost here. :)
Thanks in advance.
6 Replies
Yes.
My guess is that there’s some config problem with Wordpress. A blank page usually indicates that PHP has encountered some kind of error.
Did you check your logs? That’s why you have them…
— sw
I just saw my error.log
inside /var/www/html/domain1.com/logs
.
And it has some lines as below:
[Tue Mar 07 14:25:14.587607 2023] [proxy_fcgi:error] [pid 110090:tid 139896966485568] [client IP_ADDRESS] AH01071: Got error 'PHP message: PHP Warning: Unknown: Failed to open stream: No such file or directory in Unknown on line 0PHP message: PHP Fatal error: Failed opening required '/home1/USER_DIRECTORY_AT_OLD_HOST/public_html/wordfence-waf.php' (include_path='.:/usr/share/php') in Unknown on line 0'
But I don't understand that. That mentioned path is not used here at Linode in my server.
And the first website I moved here does not presented a similar error.
Now I am unable to access only the admin area. The other parts of the website are Ok.
WP is something I don’t do… still sounds linke a config problem with that.
- rename your index.php file to index.php.orig
- create a new index.php file with the following contents:
<?php
phpinfo();
?>
- make sure the index.php* files have the same ownership and permissions as the site that works
- navigate to your site using a browser
If you see a bunch of stuff related to PHP status, then your VirtualHost config is OK…and you need to figure out what’s wrong with Wordpress.
— sw
Hi @stevewi
Thank you very much for your kindness and great help.
I understand. :)
So, I ended discovering the problem. All because I didn't pay enough attention to error logs.
There was a line there referring to a problem with the WordFence plugin. But I had disabled all plugins, I thought. And sure I did!
But there was a .user.ini
file in the website public_html folder which had related configurations and so the error was happening. Removed the lines and everything started working again! :)
I was almost desperate!
Anyway, many, many thanks for your valuable help!