Virtual hosts - Everything was OK before I add a second website

Started by Ewsg, March 07, 2023, 02:26:22 PM

Previous topic - Next topic

Ewsg

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>

Vhost 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.

mario

In your wp-config.php file

Look for define('WP_DEBUG', false); and change the false to true.


define( 'WP_DEBUG', true );



Ewsg

Hi there,

Sorry for the delay.

Well, 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 I forgot, in the website public_html folder, which had related configurations and so the error was happening. Removed the lines and everything started working again! :)

mario