Question

How to load a site from Apache using VM's Static / Floating IP ?

Posted May 26, 2020 136 views
Apache

I have site deployed and running on CentOS 8, Apache at http://127.0.0.1:81

$ sudo netstat -tulpn | grep LISTEN

tcp6       0      0 :::81                   :::*                    LISTEN      32040/httpd.bin    

I can see the site response when using:

$ curl -v http://127.0.0.1:81 
$ vi /etc/hosts

# The following lines are desirable for IPv4 capable hosts
127.0.0.1 magento-centos8-1 magento-centos8-1
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4

When trying to http://138.197.235.67 or http://138.197.235.67:81 redirects me to http://127.0.0.1/index.php/

What am i missing?

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.

×
1 answer

After some research, found the solution.

Change the Apache httpd.conf file usually at /etc/httpd/conf/http.conf file as below and restart Apache. You site should load from http://STATIC_IP

<VirtualHost *:81>
    ServerName STATIC_IP
    ServerAlias STATIC_IP
    DocumentRoot "/opt/magento-2.3.5-1/apps/magento/htdocs"

    Include "/opt/magento-2.3.5-1/apps/magento/conf/httpd-app.conf"
</VirtualHost>

In the above example:

  1. I used Port 81 for Apache (usually it will be 80).
  2. DocumentRoot is where your website files are installed.
Submit an Answer