1. Compile and install Apache. Step 1: Create the path for storing the source code package: [root @ wei ~] Mkdir-Pusrlocalsrcapac
1. steps for compiling and installing Apache:
1. create a path for storing the source code package: [root @ wei ~] # Mkdir-P/usr/local/src/apache/
2. go to the path: [root @ wei ~] # Cd/usr/local/src/apache/
3. download source package: [root @ wei apache] # wget http://mirror.bjtu.edu.cn/apache/httpd/httpd-2.2.25.tar.gz if there is no wget command first download and install wget software in the redhat series with yum-y install wget, use the apt-get Command in ubuntu
4. unzip the source package: [root @ wei apache] # tar zxvf after the httpd-2.2.25.tar.gz is decompressed, you will see the decompressed folder httpd-2.2.25 in the current path
5. enter the httpd-2.2.25 folder: [root @ wei apache] # cd httpd-2.2.25
6. generate makefile File: [root @ wei httpd-2.2.25] #. /configure -- prefix =/usr/local/apache-2.2.25 -- enable-so -- enable-MoD-shared = most -- with-mpm = worker. make sure that you have installed the tool before performing this step. GCC compiler
7. Compile: [root @ wei httpd-2.2.25] # make
8. Installation: [root @ wei httpd-2.2.25] # make install
9. start Apache service: [root @ wei httpd-2.2.25] #/usr/local/apache-2.2.25/bin/apachectl start note that the apachectl file in this path is the control script of apache service
10. add the service to the system startup item: echo "/usr/local/apache-2.2.25/bin/apachectl start">/etc/rc. local is optional.
11. Add apache to the system service. in the future, you can use the service to control apache startup and stop for easy operation.
This step is an optional addition step:
1. copy an apache control script to the system service directory: grep-v "#"/usr/local/apache-2.2.25/bin/apachectl>/etc/init. d/apache
2. modify the script to support the chkconfig command vi/etc/init. d/apache and insert the following line at the beginning of the file.
#! /Bin/sh
# Chkconfig: 2345 85 15
3. exit the vi editor and add the script execution permission chmod + x/etc/init. d/apache.
4. add the Apache service to the system service: chkconfig -- add apache
5. check whether the service is effective chkconfig -- list apache. if the output is similar to the following results, it indicates that the service is effective: apache 0: off 1: off 2: on 3: on 4: on 5: on 6: off now, you can easily operate the apache service and start the Apache service: service apache start
Stop Apache service: service apache stop
Run the following command to disable automatic startup: chkconfig apache off
Run the following command to change the startup running level to 3 and 5: chkconfig -- level 35 apache on
II. test results: if "It works" is displayed on the host where Apache is accessed by other computer browsers, modify the firewall settings of the host where Apache is located to allow access configuration on port 80: (1) modify firewall settings: Enter the Command/sbin/iptables-I INPUT-p tcp -- dport 80-j ACCEPT in Shell.
(2) save the above settings:/etc/rc. d/init. d/iptables save
(3) restart the firewall:/etc/init. d/iptables restart