Install the Apache service program (the package name of the apache service is called httpd)
Check if Apache is already installed on Linux. If so, you don’t need to install it.
Install through the yum install httpd -y command or rpm -qa|grep httpd
After the installation is complete, the command to start the service is systemctl start httpd (you can start it in any directory)
Visit the page to see if the installation is successful. The default port is 80, so you can directly access the server address. If the following page appears, the installation is successful.
So our apache service is installed!
Some configuration file directories after installing the service in this city
Configuration file: vim /etc/httpd/conf/httpd.conf
Need to modify the default directory of the configuration file
You can download the file to the local for modification first, or modify it directly on the server
Change these two paths to the path you need to configure. When modifying, it is recommended to shut down the server. The command is systemctl stop httpd
After the change, you can restart and then the visit will be issued. Or visit the test123 page to visit the path you configured will be 403
The query log will look like this
AH01275: Can't open directory for index
The reason for the problem is that SELinux in the Linux system is closed and accessed.
There are three statuses of SELinux: Enforcing, Permissive and Disabled.
1. Introduction to the three modes of SELinux
Enforcing: mandatory mode. It means that SELinux is running and has begun to restrict the verification relationship between domain/type.
Permissive: Permissive mode. It means that SELinux is running, but it does not restrict the verification relationship between domain/type. Even if the verification is incorrect, the process can still operate on the file. However, if the verification is incorrect, a warning will be issued
Disabled: Closed mode. SELinux did not actually run the
getenforce command to view the current operating mode of SELinux
Executing the setenforce 0 command will temporarily close SELinux, which can be executed, but SELinux will still restore the original state when the server is restarted next time.
If you want to turn off permanently, you need to find the configuration file of SELnux and set it to disable. /etc/selinux/config The configuration file under this path is changed to disable
Then just visit
There is a place to pay attention to if there is still a problem with access, when the following error occurs
You need to modify the following configuration file conf.d/welcome.conf This file is modified
The following are the problems I encountered during the installation
If you don’t want to access all the files under your configuration folder through ip and port, you can only access a single file, and you can’t access the path. This can be achieved by configuring the httpd.conf file.
Modify Options Indexes FollowSymLinks to Options FollowSymLinks, just remove Indexes.
The effect is that the access path fails