skip to Main Content

Now, I want to run an Apache web server using the Compute Engine on Google Cloud.
In order to do it, after creating a Linux VM, I installed Apache.

However, I received a "Connection Refused error", although I use an External IP which is suggested by the Compute Engine.

Please tell me what to do to run an Apache web server.

Specifically, I ran the following commands to install Apache after creating a Linux VM and clicking SSH.

$ sudo yum -y update
$ sudo -i
# timedatectl set-timezone Asia/Tokyo
# yum -y install httpd
# httpd -v
Server version: Apache/2.4.6 (CentOS)
# systemctl start httpd
# systemctl enable httpd

After running these commands on Google Console above and clicking the External IP, however, I could not run Apache.

In addition to that, I have already checked the Guides in the Compute Engine to ensure that my VM instance has the correct tags and that the correct firewall rule exists.

Also, I could not run Apache means two screenshots below.
Even if I click the External IP on the VM instance, My Chrome browser shows ERR_CONNECTION_REFUSED.

image description_1

image description_2

And, if I run sudo service httpd status, Google Console shows the "image_description_3" below.

image description_3

Thank you.

2

Answers


  1. Chosen as BEST ANSWER

    Copy and paste the External IP that the VM Instance suggests in the location bar of your browser and press the return key.

    Then you will see the default screen of Apache like this.

    enter image description here

    At a first glance, it looks like you should click the External IP directly. However, as far as I know, this way doesn't work out.


  2. First, check the status of Apache HTTP server run the command:

    “systemctl status httpd”

    If the Apache HTTP server is in inactive status run the command:

    “systemctl start httpd”

    Second, make sure that you have a set the GCP firewall. You may refer to this GCP documentation on how to create firewall rules or run the gcloud command below in the cloud shell:

    "gcloud compute –project=PROJECT_ID firewall-rules create apache-http –direction=INGRESS –priority=1000 –network=default –action=ALLOW –rules=tcp:80 –source-ranges=0.0.0.0/0"

    *replace the PROJECT_ID with your project_id

    Lastly, if you have configured a firewall inside your VM instance (OS Level) make sure that you have an open port for http.

    To check the firewall run the command:

    “systemctl status firewalld”

    To list the open port in firewalld run the command:

    “firewall-cmd –zone=public –list-all”

    To add the http to firewalld run the command:

    “firewall-cmd –zone=public –add-service=http”

    You may refer to this documentation about firewalld

    Once all is set try to check the external IP address of your VM instance again.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search