Multiple sites on the same server (Centos 7 - apache) 2nd site going to apache welcome page

1.6k views Asked by At

I'm trying to set up 2 sites on the same server.

Problem: 'site_2' shows the apache's welcome page and not the actual site ('site_1' loads perfect, though);

So,

  1. on my-site_1.com, I see it's corresponding index page;
  2. on my-site_2.com, I see Apache's welcome page

What I have done: Double checked my process with multiple guides; for example: https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-centos-7

- Created folder structure for both sites:

  1. /var/www/site_1 /var/www/site_1/logs

  2. /var/www/site_2 /var/www/site_2/logs

- Created sites-available and sites-enabled directories

  1. /etc/httpd/sites-available

    Created .conf files for both sites

    • 001-site_1.conf
    • 002-site_2.conf

    Sample of 002-site_2.conf file:

    <VirtualHost *:80>
        ServerName www.my_site_2.com
        ServerAlias my_site_2.com
        DocumentRoot    /var/www/site_2
        ErrorLog /var/www/site_2/logs/error.log
        CustomLog /var/www/site_2/logs/requests.log combined

      <Directory "/var/www/site_2">

        Options FollowSymLinks
        AllowOverride All
        Require all granted

      </Directory>
    </VirtualHost>
  1. /etc/httpd/sites-enabled

Created symlinks for each virtual host defined in sites-available Example of symlink for site_2:

sudo ln -s /etc/httpd/sites-available/002-site_2.conf /etc/httpd/sites-enabled/002-site_2.conf
  • Applied Apache Policies on both sites Directories: Example:
#change content type to allow Apache to generate and append to web application log files
sudo semanage fcontext -a -t httpd_log_t "/var/www/site_2/logs(/.*)?"

#apply these changes and have them persist across reboots
sudo restorecon -R -v /var/www/site_2/logs

  • Added at the end of the file declaration for optional directory for additional configuration files to the /etc/httpd/conf/httpd.conf file:
IncludeOptional sites-enabled/*.conf
  • Restarted httpd service:
sudo systemctl restart httpd

- Output of httpd -S

 httpd -S
VirtualHost configuration:
*:443                  is a NameVirtualHost
         default server my_site_2.com (/etc/httpd/conf.d/ssl.conf:40)
         port 443 namevhost my_site_1.com (/etc/httpd/conf.d/ssl.conf:40)

*:80                   is a NameVirtualHost
         default server my_site_2.com (/etc/httpd/conf.d/drupal.conf:1)
         port 80 namevhost my_site_2.com (/etc/httpd/conf.d/drupal.conf:1)
         port 80 namevhost my_site_1.com (/etc/httpd/sites-enabled/001-site_1.conf:1)
                 alias my_site_1.com
         port 80 namevhost my_site_2.com (/etc/httpd/sites-enabled/002-site_2.conf:1)
                 alias my_site_2.com
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/etc/httpd/htdocs"
Main ErrorLog: "/etc/httpd/logs/error_log"
Mutex default: dir="/etc/httpd/run/" mechanism=default 
Mutex cache-socache: using_defaults
Mutex authdigest-opaque: using_defaults
Mutex watchdog-callback: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex authdigest-client: using_defaults
Mutex lua-ivm-shm: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex authn-socache: using_defaults
Mutex ssl-cache: using_defaults
PidFile: "/etc/httpd/run/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="apache" id=48 not_used
Group: name="apache" id=48 not_used

I wonder why on the "httpd -S" output my default server is "my_site_2.com" for port 443 (https) and port 80 (http)

I'm pretty sure I'm missing something, but I'm having a hard time figure out what. Any advice/suggestion are welcome. Many thanks in advance

0

There are 0 answers