Report this

What is the reason for this report?

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

Posted on May 26, 2020

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?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

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.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.