In this article, we will show How to Install and Setup the Apache Web Server on CentOS 7 VPS server.

The Apache HTTP server is the most widely used web server in the digital world. It provides us with many powerful features including robust media support, dynamically loadable modules, and extensive integration with other popular software.

We will need the following to complete this article also:

You can purchase your hosting from Cloudsurph.comCloudsurph hosting is a reliable hosting option for business and personal projects. We offer insight and help on system configuration issues and code errors or bugs.

Installing Apache

Apache is a default software repository within CentOS 7, which means we can install it with the yum package manager. Love to Code? We’re Your Helping Partner, click here for  Buy Our Service

As the non-root sudo user is configured in the prerequisites, update the local Apache httpd package index to consider the latest upstream changes: IF you want then buy a good, reliable, secure web hosting service  from here: click here

[root@ronykayes ~]# sudo yum update httpd

When the packages are updated, then install the Apache package:

[root@ronykayes ~]# sudo yum install httpd

When completed the installation, yum will install Apache and all required are dependencies. Now we can do this by enabling firewalld’s http service with the following below command: Love to Code? We’re Your Helping Partner, click here for  Buy Our Service

[root@ronykayes ~]# sudo firewall-cmd --permanent --add-service=http

Here, if you plan to configure Apache to serve content over HTTPS, you will also want to open up port 443 by enabling the https service:

[root@ronykayes ~]# sudo firewall-cmd --permanent --add-service=https

After then, reload the firewall to enter these new rules into effect:

[root@ronykayes ~]# sudo firewall-cmd --reload

After the firewall is active, you are ready to start your service and need to check the web server.

Checking Web Server

Apache does not start automatically on CentOS7 once the installation is completed. You will need to start the Apache process manually by the following command: IF you want then buy a good, reliable, secure web hosting service  from here: click here

[root@ronykayes ~]# sudo systemctl start httpd

Now, need to verify that the service is running with the following command:

[root@ronykayes ~]# sudo systemctl status httpd

Here you will see an active status your service is running:

The service appears to have started successfully as you can see from this output. However, the best way is to test and this is to request a page from Apache.

Now, you can access the default Apache landing page to confirm that the software is running properly through your VPS IP address.

If you do not know your VPS server’s IP address, you can get it a few different ways from the command line interface.

You can type the following at your server’s command prompt:

[root@ronykayes ~]# hostname -I

When you have your VPS server’s IP address, open any browser and enter it into your browser’s address bar:

http://your_server_ip

You will see the default CentOS 7 Apache web testing page:

Managing the Apache Process

Now, you have your web server up and running, so let’s go over some basic management by commands.

To stop your web server, type the following code:

[root@ronykayes ~]# sudo systemctl stop httpd

Now for start the web server when it is stopped, type the following code:

[root@ronykayes ~]# sudo systemctl start httpd

To stop and then start the service again, type the following code:

[root@ronykayes ~]# sudo systemctl restart httpd

Here, if you are simply making configuration changes, the Apache can often reload without dropping connections. So, here we need to use the following command:

[root@ronykayes ~]# sudo systemctl reload httpd

By default, Apache is configured to start automatically when the server boots and if this is not what you want, disable this behavior by typing the following code:

Now, for re-enabling the service to start up at boot, type the following code:

[root@ronykayes ~]# sudo systemctl enable httpd

That’s it, now Apache will start automatically when the server boots again. By the default configuration for Apache will allow our server to host a single website. If you plan on hosting multiple domains on your VPS server, then you will need to configure virtual hosts on your Apache web server.

That’s it. If you enjoyed reading this article and have more questions please reach out to our support team via live chat or email and we would be glad to help you. we provide server hosting for all types of need and we can even get your server up and running with the service of your choice.