1. 程式人生 > >編譯安裝httpd-2.4.38

編譯安裝httpd-2.4.38

efi magic dem com makefile pat tran open lin

1、下載源碼並解壓縮
[root@centos7 data]#wget http://mirrors.shu.edu.cn/apache//httpd/httpd-2.4.38.tar.bz2
--2019-03-03 12:45:15-- http://mirrors.shu.edu.cn/apache//httpd/httpd-2.4.38.tar.bz2
Resolving mirrors.shu.edu.cn (mirrors.shu.edu.cn)... 202.121.199.235
Connecting to mirrors.shu.edu.cn (mirrors.shu.edu.cn)|202.121.199.235|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7035030 (6.7M) [application/x-bzip2]
Saving to: ‘httpd-2.4.38.tar.bz2’

100%[====================================================================================>] 7,035,030 6.38MB/s in 1.1s

2019-03-03 12:45:16 (6.38 MB/s) - ‘httpd-2.4.38.tar.bz2’ saved [7035030/7035030]

[root@centos7 data]#wget http://mirror.bit.edu.cn/apache//apr/apr-1.6.5.tar.bz2
--2019-03-03 12:47:04-- http://mirror.bit.edu.cn/apache//apr/apr-1.6.5.tar.bz2
Resolving mirror.bit.edu.cn (mirror.bit.edu.cn)... 114.247.56.117
Connecting to mirror.bit.edu.cn (mirror.bit.edu.cn)|114.247.56.117|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 855393 (835K) [application/octet-stream]
Saving to: ‘apr-1.6.5.tar.bz2’

100%[====================================================================================>] 855,393 --.-K/s in 0.1s

2019-03-03 12:47:04 (6.43 MB/s) - ‘apr-1.6.5.tar.bz2’ saved [855393/855393]
[root@centos7 data]#wget http://mirror.bit.edu.cn/apache//apr/apr-util-1.6.1.tar.bz2
--2019-03-03 12:48:00-- http://mirror.bit.edu.cn/apache//apr/apr-util-1.6.1.tar.bz2
Resolving mirror.bit.edu.cn (mirror.bit.edu.cn)... 114.247.56.117
Connecting to mirror.bit.edu.cn (mirror.bit.edu.cn)|114.247.56.117|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 428595 (419K) [application/octet-stream]
Saving to: ‘apr-util-1.6.1.tar.bz2’

100%[====================================================================================>] 428,595 --.-K/s in 0.1s
2019-03-03 12:48:00 (3.48 MB/s) - ‘apr-util-1.6.1.tar.bz2’ saved [428595/428595]
tar xvf apr-1.6.5.tar.bz2
tar xvf apr-util-1.6.1.tar.bz2
tar xvf httpd-2.4.38.tar.bz2
[root@centos7 data]#ls
apr-1.6.5.tar.bz2 apr-util-1.6.1.tar.bz2 httpd-2.4.38.tar.bz2
[root@centos7 data]#ls
apr-1.6.5 apr-1.6.5.tar.bz2 apr-util-1.6.1 apr-util-1.6.1.tar.bz2 httpd-2.4.38 httpd-2.4.38.tar.bz2
2、 將三個源碼合並
[root@centos7 data]#mv apr-1.6.5 httpd-2.4.38/srclib/apr
[root@centos7 data]#mv apr-util-1.6.1 httpd-2.4.38/srclib/apr-util
[root@centos7 data]#ls httpd-2.4.38/srclib/
apr apr-util Makefile.in
3、 安裝相關包 yum install gcc gcc-c++ glibc glibc-devel pcre-devel openssl-devel expat-devel
4、編譯安裝[root@centos7 httpd-2.4.38]#1、 cd httpd-2.4.38/
./configure --prefix=/app/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-included-apr --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
2、make && make install
configure: summary of build options:
Server Version: 2.4.38
Install prefix: /app/httpd24
C compiler: gcc -std=gnu99
CFLAGS: -g -O2 -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS:
LIBS:
C preprocessor: gcc -E
此時,為了避免沖突,我們把本機yum安裝的httpd卸載,不然都走80端口會沖突。
[root@centos7 httpd-2.4.38]#cd /app/
[root@centos7 app]#ls
httpd24
[root@centos7 app]#cd httpd24/
[root@centos7 httpd24]#ls
bin build cgi-bin conf error htdocs icons include lib logs man manual modules
[root@centos7 httpd24]#ls bin/
ab apr-1-config apxs dbmmanage envvars-std htcacheclean htdigest httpd:主配置文件 logresolve
apachectl:系統啟動文件 apu-1-config checkgid envvars fcgistarter htdbm htpasswd httxt2dbm rotatelogs
5、[root@centos7 httpd24]#vim /etc/profile.d/env.sh 將變量寫入文件
PS1="[\e[1;32m][\u@\h \W]\$[\e[0m]"
PATH=/app/httpd24/bin:$PATH
[root@centos7 httpd24]#. /etc/profile.d/env.sh
[root@centos7 httpd24]#echo $PATH
/app/httpd24/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
6、嘗試啟動:[root@centos7 httpd24]#apachectl
AH00558: httpd: Could not reliably determine the server‘s fully qualified domain name, using centos7.localdomain. Set the ‘ServerName‘ directive globally to suppress this message
[root@centos7 ~]#ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 :::80 :::
7、因為配置已經寫入文件中
[root@centos7 ~]#cd /app/httpd24/htdocs/
[root@centos7 htdocs]#ls
index.html
[root@centos7 htdocs]#cat index.html
<html><body><h1>It works!</h1></body></html>
技術分享圖片
8、此時在進程中顯示是demon服務,我們要把它改為Apache服務:修改文件
[root@centos7 httpd24]#ls
bin build cgi-bin conf error htdocs icons include lib logs man manual modules
[root@centos7 httpd24]#cd conf
[root@centos7 conf]#ls
extra httpd.conf magic mime.types original
[root@centos7 conf]#vim httpd.conf
User apache Group apache
[root@centos7 conf]#apachectl restart
[root@centos7 conf]#ps aux
apache 58161 0.0 0.1 101620 1924 ? S 14:33 0:00 /app/httpd24/bin/httpd
apache 58162 0.0 0.1 101620 1924 ? S 14:33 0:00 /app/httpd24/bin/httpd
apache 58163 0.0 0.1 101620 1924 ? S 14:33 0:00 /app/httpd24/bin/httpd
apache 58164 0.0 0.1 101620 1924 ? S 14:33 0:00 /app/httpd24/bin/httpd
apache 58165 0.0 0.1 101620 1924 ? S 14:33 0:00 /app/httpd24/bin/httpd
9、[root@centos7 conf]#cd /etc/init.d/
[root@centos7 init.d]#ls
functions netconsole network README
[root@centos7 init.d]#vim /etc/rc.local
/app/httpd24/bin/apachectl
[root@centos7 init.d]#ll /etc/rc.d/rc.local
-rw-r--r--. 1 root root 500 Mar 3 14:37 /etc/rc.d/rc.local
[root@centos7 init.d]#chmod +x /etc/rc.d/rc.local
[root@centos7 init.d]#reboot
[root@centos7 ~]#ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 :::80 :::

編譯安裝httpd-2.4.38