2

I am trying to setup a ReactJS front end and Wordpress back end on the same AWS instance without a domain name. The AWS instance is running Amazon Linux.

I am attempting to use an IP address and port numbers to map to the Apache virtual hosts. I added the following VirtualHost directives to the httpd.conf file. Where the IP has been replaced with 1.1.1.1

ServerRoot "/etc/httpd"

Listen 80
Listen 8080

Include conf.modules.d/*.conf

User webapp
Group webapp

ServerAdmin root@localhost
ServerName localhost

<Directory />
    AllowOverride none
    Require all denied
</Directory>

DocumentRoot "/var/www/html/"

<Directory "/var/www">
    AllowOverride All
    # Allow open access:
    Require all granted
</Directory>

<Directory "/var/www/html">
    Options FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

<VirtualHost 1.1.1.1:80>
    ServerName 1.1.1.1
    DocumentRoot /var/www/html/client/public_html
</VirtualHost>

<VirtualHost 1.1.1.1:8080>
    ServerName 1.1.1.1
    DocumentRoot /var/www/html/server/public_html
</VirtualHost>

However when I try and access the site it is still directing all traffic to/var/www/html/regardless of whether I try and access port 80 or 8080

11
  • "Connection refused" usually means that Apache isn't running. Jul 1 '17 at 23:14
  • Thanks, yeah I messed up the configuration of the main config file which must have caused apache to crash. I have updated the question with the httpd.conf file I now have in place. I can't seem to get the redirect to work Jul 2 '17 at 4:33
  • 1
    You have a stray DocumentRoot which will cause issues, look above <Directory "/var/www">. Jul 2 '17 at 7:57
  • 1
    @SimonHayter Why would that DocumentRoot directive "cause issues"? That directive looks like it's defining the default DocumentRoot in the main server config (for localhost) and is most probably required. Any VirtualHosts that match would simply override this.
    – DocRoot
    Jul 2 '17 at 9:32
  • 1
    Well, because its not contained you are having it override all the other virtual hosts. Furthermore, when using <VirtualHost 1.1.1.1:8080> you shouldn't need to use ServerName 1.1.1.1 because it is already listening on the IP address and only when using a domain should you need to use the ServerName or ServerAlias. If you used <VirtualHost *:80> then you could use ServerName to be more specific. Jul 2 '17 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.