Centos7 源码安装apache
Apache源码安装
一、下载最新版apache:
[root@apache ~]# wget https://downloads.apache.org/httpd/httpd-2.4.52.tar.bz2
二、解压
[root@apache ~]# tar -xf httpd-2.4.52.tar.bz2
三、下载GCC及其他插件
yum install apr apr-devel apr-util apr-util-devel -y && yum -y install gcc-c++ -y
四、编译./configure
[root@weblogic1 httpd-2.4.52]# ./configure --prefix=/usr/local/apache --with-pmp=worker
模块解释:
--prefix=/usr/local/apache/ 指定安装路径
--enable-rewrite 预编译Apache,启用rewrite规则
--enable-so 启用动态加载库;
--enable-ssl 启用ssl功能
--with-mpm=prefork|worker|event() 指定工作模式
--enable-mpms-shared=all 也可以编译为三种都支持,通过修改配置来更换。
config.status: creating include/ap_config_auto.h
config.status: executing default commands
configure: summary of build options:
Server Version: 2.4.52
Install prefix: /usr/local/apache
C compiler: gcc -std=gnu11
CFLAGS: -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS:
LIBS:
C preprocessor: gcc -E
[root@test httpd-2.4.52]# make -j4 (使用4个内核编译,提升编译速度。(根据内核数量添加))
make[4]: 离开目录“/root/apache/httpd-2.4.52/modules/mappers”
make[3]: 离开目录“/root/apache/httpd-2.4.52/modules/mappers”
make[2]: 离开目录“/root/apache/httpd-2.4.52/modules”
make[2]: 进入目录“/root/apache/httpd-2.4.52/support”
make[2]: 离开目录“/root/apache/httpd-2.4.52/support”
[root@test httpd-2.4.52]# make install
Installing configuration files
mkdir /usr/local/apache/conf
mkdir /usr/local/apache/conf/extra
mkdir /usr/local/apache/conf/original
mkdir /usr/local/apache/conf/original/extra
Installing HTML documents
mkdir /usr/local/apache/htdocs
Installing error documents
mkdir /usr/local/apache/error
Installing icons
mkdir /usr/local/apache/icons
mkdir /usr/local/apache/logs
Installing CGIs
mkdir /usr/local/apache/cgi-bin
Installing header files
mkdir /usr/local/apache/include
Installing build system files
mkdir /usr/local/apache/build
Installing man pages and online manual
mkdir /usr/local/apache/man
mkdir /usr/local/apache/man/man1
mkdir /usr/local/apache/man/man8
mkdir /usr/local/apache/manual
make[1]: 离开目录“/root/apache/httpd-2.4.52”
[root@weblogic1 apache]# /usr/local/apache/bin/apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.184.150. Set the 'ServerName' directive globally to suppress this message
解决办法:
修改配置文件vim /etc/httpd/conf/httpd.conf
#ServerName www.example.com:80
修改为
ServerName localhost:80
重启服务
五、验证
[root@weblogic1 apache]# ps -ef | grep httpd
root 13762 1 0 19:24 ? 00:00:00 /usr/local/apache/bin/httpd -k start
daemon 13763 13762 0 19:24 ? 00:00:00 /usr/local/apache/bin/httpd -k start
daemon 13764 13762 0 19:24 ? 00:00:00 /usr/local/apache/bin/httpd -k start
daemon 13765 13762 0 19:24 ? 00:00:00 /usr/local/apache/bin/httpd -k start
root 19484 111716 0 19:39 pts/3 00:00:00 grep --color=auto httpd
[root@weblogic1 apache]# curl 192.168.184.151
It works!