How to install apache for centos7
How to install apache for centos7? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.
Apache HTTP server is the most popular Web server in the world. It is a free open source and cross-platform HTTP server that provides powerful features and can be extended through a variety of modules. The following instructions describe how to install and manage an Apache Web server on a CentOS 7 machine.
Install Apache
Apache is available in the default CentOS repository and is easy to install. On CentOS and RHEL, Apache packages and services are called httpd. To install the package, run the following command:
Sudo yum install httpd
After the installation is complete, enable and start the Apache service:
Sudo systemctl enable httpdsudo systemctl start httpd
If you are running a firewall, you also need to open HTTP and HTTPS ports 80 and 443:
Sudo firewall-cmd-permanent-zone=public-add-service=httpsudo firewall-cmd-permanent-zone=public-add-service=httpssudo firewall-cmd-reload
We can check the status and version of the Apache service in the following ways:
Sudo systemctl status httpd
Output:
Httpd.service-The Apache HTTP Server Loaded: loaded (/ usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2018-04-26 07:13:07 UTC; 11s ago Docs: man:httpd (8) man:apachectl (8) Main PID: 3049 (httpd) Status: "Total requests: 0; Current requests/sec: 0 Current traffic: 0 B/sec "CGroup: / system.slice/httpd.service ├─ 3049 / usr/sbin/httpd-DFOREGROUND ├─ 3050 / usr/sbin/httpd-DFOREGROUND ├─ 3051 / usr/sbin/httpd-DFOREGROUND ├─ 3052 / usr/sbin/httpd-DFOREGROUND ├─ 3053 / usr/sbin/httpd-DFOREGROUND └─ 3054 / usr/sbin/httpd-DFOREGROUNDsudo httpd-v
Output:
Server version: Apache/2.4.6 (CentOS) Server built: Oct 19 2017 20:39:16
Finally, to verify the installation, open your server IP address http://YOUR_IP in the browser of your choice
Use systemctl to manage Apache services
We can manage Apache services like any other system unit.
To stop the Apache service, run:
Sudo systemctl stop httpd
To start again, type:
Sudo systemctl start httpd
Restart the Apache service:
$sudo systemctl restart httpd
Reload the Apache service after making some configuration changes:
$sudo systemctl reload httpd
If you want to disable the Apache service to start at startup:
$sudo systemctl disable httpd
And re-enable it:
Will sudo systemctl enable httpd be helpful to you after reading the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.