Source installation lamp (1): apache

The server has been reset, and I want to install the latest software, record it here


environment:

LSB Version:	:core-4.1-amd64:core-4.1-noarch
Distributor ID:	CentOS
Description:	CentOS Linux release 7.2.1511 (Core) 
Release:	7.2.1511
Codename:	Core

Target:

Apache 2.4.33
PHP 7.2.4
mysql 5.7.21


let's start;)


Apache

1. Install the compilation environment
2. Download the source package and unzip it
3. Configure, compile, install
4. Test
5. Add system services, start up, add system commands

1.    yum -y install gcc gcc- gcc++ zlib zlib-devel cmake 

2.    wget http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.33.tar.bz2

        tar -xjvf httpd-2.4.33.tar.bz2 (if error, check if bzip2 is installed)

3. Download and install dependencies apr, apr-util, pcre, compile and install apache

          wget http://archive.apache.org/dist/apr/apr-1.5.0.tar.gz
         tar -zxvf apr-1.5.0.tar.gz
          cd apr-1.5.0
         ./configure --prefix=/usr/local/apr/
         make && make install

         wget http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz
         tar -zxvf apr-util-1.5.4.tar.gz
         cd apr-util-1.5.4
         ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/

         make && make install

         wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.39/pcre-8.39.tar.gz
         tar -zxvf pcre-8.39.tar.gz
         cd pcre-8.39
         ./configure --prefix=/usr/local/pcre/

         make && make install


        cd httpd-2.4.33

    ./configure --prefix=/www/apache/httpd  --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/   --enable-rewrite --enable-so --enable-headers --enable-expires --with-mpm=worker --enable-modules=most --enable-deflate

    make && make install


--prefix=/www/apache/httpd indicates the installation path of apache 

 --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/ Indicates the installation path of dependencies

--enable-rewrite provides a more tender rewrite of URL rules, that is, converts to other desired URL addresses based on known URL addresses

--enable-so activates the DSO (Dynamic Shared Objects) of the apache service, that is, the shared module can be compiled and installed in the DSO mode in the future, but the module itself cannot be compiled in the DSO mode.

--enable-headers provides to allow control over HTTP request headers.

--enable-expires activates Xun Yu to control the HTTP "Expires:" and "Cache-Control:" header content through the configuration file, that is, to provide the client browser cache settings for website pictures, js, css and other content. This is one of the important options for apache tuning.

--with-mpm=worker Select the mode of apache mpm as worker mode. The principle for the worker mode is that more threads are used to process requests, so more concurrent requests can be processed. And the overhead of system resources Xiaoyu is based on the MPM prefork of the process. If this parameter is not specified, the default mode is the prefork process mode. This is one of the important options for apache tuning.

--enable-deflate provides support for compressed transfer encoding of content, generally sites with html, js, css and other content. Using this parameter will increase the transmission speed and improve the experience of the visitor. In a production environment, this is one of the important options for apache tuning.


4. Test

centos7 uses systemctl instead of chkconfig to manage services, and the firewall is also replaced from iptables to firewalld  

First turn off the firewall with systemctl:  

systemctl stop firewalld.service  

systemctl disable firewalld.service 

 
Enter /www/apache/httpd/bin , backup and modify httpd.conf
cp httpd.conf httpd.conf.bak
vim httpd.conf 
Search ServerName 
remove the preceding # and modify it to ServerName localhost:80

cd ../httpd/bin
./apachectl start

browser access.

It works!

5. Add boot up:

Copy the apachectl file to /etc/init.d, and then add the link to /etc/rc.d/rc5.d


cp /www/apache/httpd/bin/apachectl /etc/init.d/httpd

ln -s /etc/init.d/httpd /etc/rc.d/rc5.d/S85httpd


接下来加入系统服务:

运行chkconfig –list 发现列表中没有httpd,通过chkconfig –add httpd来添加,可能会提示httpd服务不支持chkconfig,需要编辑/etc/rc.d/init.d/httpd

在文件末尾添加以下注释信息:
# chkconfig: 345 85 15
# description: Activates/Deactivates Apache Web Server

运行chkconfig –list,httpd 就存在了

可以使用service httpd start 和 service httpd stop来启动和停止服务。


加入环境变量:

 vi /etc/profile
找到export行,在下面新增加一行,内容为:export PATH=$PATH:/www/apache/httpd/bin
注:= 等号两边不能有任何空格。这种方法最好,除非手动强制修改PATH的值,否则将不会被改变。

source /etc/profile




Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324591850&siteId=291194637