简介
采用yum安装lamp简单,快捷,在工作中也得到了普遍应用。但是如果我们需要某些特定模块功能,以及制定安装位置等,就需要用到编译安装了,接下来将编译安装lamp之apache.
系统环境及服务版本
centos6.7
服务器IP:10.220.5.166/24
apr-1.5.2
apr-util-1.5.4
httpd-2.4.20
关闭安全服务
[root@ken ~]# setenforce 0
安装依赖包
[root@ken ~]# yum install gcc gcc-c++ ncurses-devel ncurses pcre pcre-devel openssl-devel zlib-devel -y
上传httpd包以及依赖包
上传apr,apr-util,以及httpd安装包
[root@ken ~]# rz z waiting to receive.**B0100000023be50 [root@ken ~]# ls apr-1.5.2.tar.gz apr-util-1.5.4.tar.gz httpd-2.4.20.tar.gz
安装apr以及apr-util
1.解压apr,apr-util安装包
[root@ken ~]# tar -xf apr-util-1.5.4.tar.gz [root@ken ~]# tar -xf apr-1.5.2.tar.gz
2.编译安装apr
[root@ken ~]# cd apr-1.5.2 [root@ken apr-1.5.2]# ./configure --prefix=/usr/local/apr [root@ken apr-1.5.2]# make && make install
3.编译安装apr-util
[root@ken apr-1.5.2]# cd .. [root@ken ~]# cd apr-util-1.5.4 [root@ken apr-util-1.5.4]# ./configure --with-apr=/usr/local/apr/ --prefix=/usr/local/apr-util [root@ken apr-util-1.5.4]# make && make install
安装apache
[root@ken apr-util-1.5.4]# cd .. [root@ken ~]# tar xf httpd-2.4.20.tar.gz [root@ken ~]# cd httpd-2.4.20 [root@ken httpd-2.4.20]# ./configure > --prefix=/usr/local/httpd2.4/ > --sysconfdir=/etc/httpd2.4/conf/ > --enable-so > --enable-ssl > --enable-cgi > --enable-rewrite > --enable-zlib > --enable-pcre > --with-apr=/usr/local/apr > --with-apr-util=/usr/local/apr-util > --with-mpm=event > --enable-deflate > --enable-mpms-shared=all > --enable-modules=all && make && make install
导出相关程序
1.查看编译安装后生成的文件
[root@ken httpd-2.4.20]# ls /usr/local/httpd2.4/ bin/ build/ cgi-bin/ error/ htdocs/ icons/ include/ logs/ man/ manual/ modules/
2.导出二进制程序
[root@ken httpd-2.4.20]# vim /etc/profile.d/httpd.sh export PATH=$PATH:/usr/local/httpd2.4/bin [root@ken httpd-2.4.20]# source /etc/profile
3.导入头文件
[root@ken httpd-2.4.20]# ln -sv /usr/local/httpd2.4/include/ /usr/include/httpd `/usr/include/httpd' -> `/usr/local/httpd2.4/include/'
4.导出库文件
[root@ken httpd-2.4.20]# echo "/usr/local/httpd2.4/lib/">>/etc/ld.so.conf.d/httpd.conf
5.导出帮助文档
[root@ken httpd-2.4.20]# echo "MANPATH /usr/local/httpd2.4/man">>/etc/man.config
防火墙放行访问80端口的流量
[root@ken ~]# iptables -A INPUT -p tcp --dport 80 -d 10.220.5.166 -j ACCEPT
启动apache
[root@ken ~]# apachectl start [root@ken ~]# ss -tnl #查看80端口是否启动 State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:33029 *:* LISTEN 0 50 *:3306 *:* LISTEN 0 128 :::50671 :::* LISTEN 0 128 :::111 :::* LISTEN 0 128 *:111 *:* LISTEN 0 128 :::80 :::* LISTEN 0 128 :::22 :::* LISTEN 0 128 *:22 *:* LISTEN 0 100 ::1:25 :::* LISTEN 0 100 127.0.0.1:25 *:*
浏览器测试
输入服务器ip地址
测试成功!