Home >Operation and Maintenance >Apache >How to install apache on centos7
Apache HTTP server is the most popular web server in the world. It is a free, open source and cross-platform HTTP server that offers powerful functionality and can be extended through various modules. The following instructions describe how to install and manage the Apache web server on a CentOS 7 machine.
Installing Apache
Apache is available in the default CentOS repository and installation is very simple. On CentOS and RHEL, the Apache package and service is called httpd. To install the package, run the following command:
sudo yum install httpd
Once the installation is complete, enable and start the Apache service:
sudo systemctl enable httpd sudo systemctl start httpd
If you are running a firewall, you will also need to open HTTP and HTTPS ports 80 and 443:
sudo firewall-cmd --permanent --zone=public --add-service=http sudo firewall-cmd --permanent --zone=public --add-service=https sudo firewall-cmd --reload
We can check the status and version of the Apache service by:
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 -DFOREGROUND
sudo 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
Use systemctl to manage the Apache service
## in a browser of your choice #We can manage the Apache service like any other system unit. To stop the Apache service, run:sudo systemctl stop httpdTo start again, type:
sudo systemctl start httpdRestart the Apache service:
$sudo systemctl restart httpdWhile doing some Reload the Apache service after configuration changes:
$sudo systemctl reload httpdIf you want to disable the Apache service to start on boot:
$sudo systemctl disable httpdand re-enable it:
$sudo systemctl enable httpdMore Apache For related technical articles, please visit the
Apache Tutorial column to learn!
The above is the detailed content of How to install apache on centos7. For more information, please follow other related articles on the PHP Chinese website!