Setup and configuration methods for Apache under CentOS7

  • 2020-06-19 12:31:09
  • OfStack

A few days ago I installed Nginx, and just for fun I installed Apache again. Apache was installed very well. Make a learning record and share experience here.

1. Install httpd

1. First check whether httpd has been installed in the system under 1. If nothing is found, it is not installed. If # ES10en-ES11en finds rpm registration, delete it.


#rpm -qa | grep httpd

2. I installed it directly using yum (the dependency package will be installed automatically) for simplicity.


yum -y install httpd

3. Check the installation version of ES20en-ES21en. After successful installation, find the configuration file location and configure httpd


#find / -name "httpd.conf"

4. Of course, it is better to make a backup of the original configuration file, such as:


#cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.origin 

2. Configure the Apache file

1. Pay particular attention to this configuration, which is a new default value for Apache 2.4 and rejects all requests!


<Directory />
 AllowOverride none
 Require all denied
</Directory> 

Change none to ALL, centos USES vi or vim for editing, enter/query content in instruction mode, enter, you can find the content and then modify it. (vim find tutorial: http: / / jingyan baidu. com article / 219 f4bf793a0c2de442d38f1 html)

2. Configure the WEB site

As my web page file is by default


Listen 8080
<VirtualHost *:8080>
  DocumentRoot "/var/www/html"
  ServerName localhost:8080
  <Directory "/var/www/html">
    AllowOverride All
    Options FollowSymLinks Includes ExecCGI
    Require all granted
  </Directory>
</VirtualHost>

3. Add firewall ports

I'm using the default firewall firewall of centos7 and adding port 8080.


#firewall-cmd --permanent --zone=public --add-port=8080-8081/tcp  -- Permanent add port 
#fire-cmd --permanent --zone=public --list-ports  -- View the open end 
#systemctl restart firewalld.service // You need to restart the service to take effect after changing the configuration 

Of course, if you're using a cloud server, you'll also need to add port support to the console (I covered this in the INSTALLATION and configuration of mysql).

4, test,

On his window browser input 192.168 x. x: 8080 / index html parse it out html files in the server path.

conclusion

Above is the site to introduce CentOS7 Apache installation configuration method, I hope to help you, if you have any questions welcome to leave a message, this site will reply you in time!


Related articles: