1. Enter apache's website at https://www.apache.org/, click Download
2. Select as shown
3. Select httpd
4. Download two packages, 2.2 for CentOS6 and 2.4 for CentOS7
1. CentOS6
1. Enter the command rz and a dialog box will pop up to transfer the windows file to linux.
2. In the pop-up dialog box, select Package--->Add--->OK.Be careful to keep the software on the desktop as much as possible. I put the software on the D drive, then add it through a shortcut on the desktop and the file passed to linux will be damaged.The incoming file will be stored in the current directory.
The /usr/local/src/directory is mostly where software source packages are stored, so move it to this directory, but it's not absolutely recommended.
3. Unzip the incoming file
4. The following compilation requires scripts in the httdp directory, so I use cd httpd to switch the directory to http
.configure This is a script file that specifies a list of parameters such as the installation path, the configuration file path, and so on.
--prefix software installation path
--Installation path of sysconfigdir configuration file
There are more parameters to see through. /configure --help
5. $? You can query whether the execution of the previous command was successful or failed.This command lets you see if. /configure was successful, and if prompted to install the package, install it as prompted.
echo $? 0 executed successfully for the previous command and 1 failed for the previous command.
6. If the previous command was executed, then execute make to install me based on the configuration builder make install I will write the two commands together here
7. Check the installation directory, and apache is now installed
8. Software configuration, the next steps are not installation category, in order to test the installation problem, simply configure the software and then test.
-
Set environment variable to write apache installation directory in front, setting this path takes precedence over the path in the system
[root@centos6 htdocs]echo 'export PATH=/app/httpd22/bin:$PATH' >/etc/profile.d/https22.sh [root@centos6 htdocs]. /etc/profile.d/https22.sh [root@centos6 htdocs]echo $PATH
The variables in the confirmation box are at the top, so they take precedence over the system variables.
- Open Service
- Check if port 80 is enabled
- Enter 127.0.0.1 on this machine to see if the http service is available, and when the page is displayed, the service starts successfully
- Pages can only be accessed locally at this time and firewalls should be turned off to provide services relatively outside
- Open the page with another computer to verify the service is OK
2. One-Click Deployment Script
This script works with centos6 and centos7.Links: http://pan.baidu.com/s/1gfu0qiv Password: j2qf
[root@centos7 httpd]# cat install.sh #!/bin/bash # -------------+-------------------- # * Filename : install.sh # * Revision : 2.0 # * Date : 2017-08-05 # * Author : Aubin # * Description : install httpd # * www.shuaiguoxia.com # -------------+--------------------- rm -rf /var/run/yum.pid #mkdir mkdir /etc/yum.repos.d/back/ #back default repo mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/back #new repo cat > /etc/yum.repos.d/aubin.repo <<end [aubin] name=aubin baseurl=http://mirrors.sohu.com/centos/\$releasever/os/\$basearch enable=1 gpgcheck=0 end #remove old httpd yum remove httpd -y #install Package yum groupinstall "Development tools" -y yum install apr-devel.x86_64 apr-util-devel.x86_64 openssl-devel -y #judge version ver=`cat /etc/centos-release | grep [[:digit:]] -o|head -1` if [ $ver -eq 6 ] then tar xf httpd-2.2.34.tar.bz2 cd ./httpd-2.2.34 ./configure --prefix=/app/httpd22/ --sysconfdir=/etc/httpd22/ --enable-ssl make && make install /app/httpd22/bin/apachectl start echo 'export PATH=/app/httpd22/bin:$PATH' > /etc/profile.d/httpd22.sh . /etc/profile.d/httpd22.sh echo "MANPATH /app/httpd22/man" >> /etc/man.config else tar xf httpd-2.4.27.tar.bz2 cd ./httpd-2.4.27 ./configure --prefix=/app/httpd24/ --sysconfdir=/etc/httpd24/ --enable-ssl make && make install /app/httpd24/bin/apachectl start echo 'export PATH=/app/httpd24/bin:$PATH' > /etc/profile.d/httpd24.sh . /etc/profile.d/httpd24.sh echo "MANPATH /app/httpd24/man" >> /etc/man_db.conf fi echo "Installation Complete !! Ctrl+c exit music" play ./music.wav &>/dev/null