Home > Operation and Maintenance > Apache > How to install apache on centos7

How to install apache on centos7

步履不停
Release: 2019-07-26 09:30:02
Original
14166 people have browsed it

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.

How to install apache on centos7

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
Copy after login

Once the installation is complete, enable and start the Apache service:

sudo systemctl enable httpd
sudo systemctl start httpd
Copy after login

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
Copy after login

We can check the status and version of the Apache service by:

sudo systemctl status httpd
Copy after login

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
Copy after login
sudo httpd -v
Copy after login

Output:

Server version: Apache/2.4.6 (CentOS)
Server built:  Oct 19 2017 20:39:16
Copy after login

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 httpd
Copy after login

To start again, type:

sudo systemctl start httpd
Copy after login

Restart the Apache service:

$sudo systemctl restart httpd
Copy after login

While doing some Reload the Apache service after configuration changes:

$sudo systemctl reload httpd
Copy after login

If you want to disable the Apache service to start on boot:

$sudo systemctl disable httpd
Copy after login

and re-enable it:

$sudo systemctl enable httpd
Copy after login
More 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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template