Remarks: Apache official website Download http://www.apache.org/Download the required packages for the experiment and unzip to the specified folder to start the experimentFirst copy the extracted Apr and Apr-util to the designated folder.
cp -R cp -R apr /opt/httpd-2.4.2/srclib/aprcp -R apr-util /opt/httpd-2.4.2/srclib/apr-util
Install the build environment (using the Yum repository installation, you need to build a yum warehouse in advance, how to create a yum warehouse in my previous article)
yum install gcc gcc-c++ make pcre pcre-devel -y
Compile and install ApachePre-installation configuration first
./configure --prefix=/usr/local/apache \ //安装路径--enable-so \ //使用动态模块加载--enable-rewrite \ //重写--enable-mods-shared=most \ //启用模块--with-mpm=worker \ //使用多处理模块--disable-cgid \ //开启通用网关接口--disable-cgi
Installation
make //编译(转换成二进制语言)make install //编译安装
Service optimizationFor ease of administration, we want to add the HTTPD service to the system startup item
We filter the script file with a single command and then add it to the/etc/init.d folder. The script file is not complete yet, and we need to make additional modifications to it.
grep -v "#" /usr/local/apache/bin/apachectl > /etc/init.d/httpd
Use the Vim editor to modify the file and insert the following in the first line
#!/bin/sh# chkconfig:2345 85 15# description:Apache is a World Wide Web server
Now this file does not have execute permission, we need to take the right action
chmod +x /etc/init.d/httpd
Add httpd Service
chkconfig --add httpd
Set the port to self-start in the character interface and graphical interface
chkconfig --level 35 httpd on
View service port Information
chkconfig --list httpd
To facilitate our management of Apache, we can create a soft connection to the/etc directory for the httpd.conf file
ln -s /usr/local/apache/conf/httpd.conf /etc/httpd.conf
Editing a configuration file httpd.conf
Open service
service httpd start
See if the service is open successfully
netstat -ntap | grep 80
Implementing host Access