linux centos 安装httpd-2.4.12

2 篇文章 0 订阅
2 篇文章 0 订阅

// 所有的技术,本人均拿  51kxd.com  这个本人的小网站来验证


编译软件准备:
yum install -y cmake gcc gcc-c++




假设:
pcre 安装在: /home/datum/program/pcre
apr安装在: /home/datum/program/apr-suite/apr
apr-util安装在 /home/datum/program/apr-suite/apr-util
apr-iconv安装在/home/datum/program/apr-suite/apr-iconv
apache http server(httpd)安装在 /home/datum/program/httpd 


1, 下载各个应用(版本可能会更新,如果下载不了,将Url中的文件名去掉,在浏览器中下载最新的,可用的版本)
wget http://mirrors.cnnic.cn/apache//httpd/httpd-2.4.12.tar.gz
wget http://archive.apache.org/dist/apr/apr-iconv-1.2.1.tar.gz
wget http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz
wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-10.21.tar.bz2
wget https://nchc.dl.sourceforge.net/project/pcre/pcre/8.39/pcre-8.39.tar.bz2


2,解压各个压缩包,示例:
tar -zxvf apr-iconv-1.2.1.tar.gz
tar -zxvf apr-1.5.2.tar.gz
tar -jxvf pcre-8.39.tar.bz2
tar -zxvf apr-util-1.5.4.tar.gz


3,设置安装路径并安装(各个命令在执行前,需要进入到安装程序解压后的目录中再执行./configure)
# 创建软链接
ln -s /home/datum/program/apr-suite/apr-util/lib/libexpat.so /usr/lib/libexpat.so


./configure --prefix=/home/datum/program/pcre --enable-utf8 && make && make install
./configure --prefix=/home/datum/program/apr-suite/apr  --with-pcre=/home/datum/program/pcre && make && make install
./configure --prefix=/home/datum/program/apr-suite/apr-iconv --with-apr=/home/datum/program/apr-suite/apr && make && make install
./configure --prefix=/home/datum/program/apr-suite/apr-util --with-apr=/home/datum/program/apr-suite/apr --with-apr-iconv=/home/datum/program/apr-suite/apr-iconv/bin/apriconv && make && make install
./configure --prefix=/home/datum/program/httpd --with-apr=/home/datum/program/apr-suite/apr --with-apr-util=/home/datum/program/apr-suite/apr-util --with-pcre=/home/datum/program/pcre --enable-mods-shared=all --enable-proxy --enable-proxy-connect --enable-proxy-ftp --enable-proxy-http --enable-proxy-ajp --enable-proxy-balancer --enable-rewrite --enable-status && make && make install


4,启动,运行
cd /home/datum/program/httpd/bin
./httpd -k start
./httpd -k restart


5,访问
http://192.168.1.177/

6,扩展

安装php5:  

下载: wget http://117.143.109.173/cache/cn2.php.net/distributions/php-5.6.29.tar.gz?ich_args2=139-12105308022867_998332835cfbdf31c4772aaa7ac30c07_10001002_9c886c28d6cbf8d49f32518939a83798_9b725b0adc412edb7eb6c19fc8775139

重命名:mv php-5.6.29.tar.gz?ich_args2=139-12105308022867_998332835cfbdf31c4772aaa7ac30c07_10001002_9c886c28d6cbf8d49f32518939a83798_9b725b0adc412edb7eb6c19fc8775139 php-5.6.29.tar.gz

解压:tar -zxvf php-5.6.29.tar.gz

进入目录:cd php-5.6.29

编译并安装:

./configure --prefix=/home/datum/program/php5 --with-config-file-path=/home/datum/program/php5/etc --with-apxs2=/home/datum/program/httpd/bin/apxs --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib --with-libxml-dir --with-gd --with-iconv --with-curl --with-png-dir --with-jpeg-dir --enable-sockets --enable-mbstring --enable-inline-optimization --enable-zend-multibyte --with-freetype-dir  && make && make install


常用命令:

进入httpd/bin 目录中

启动: ./apachectl start

重启: ./apachectl restart

停止: ./apachectl stop

在浏览器中直接输入ip即可验证是否启动成功。启动成功时,默认显示内容: 

It works!




常见问题:


一,AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using justin.lijun. Set the 'ServerName' directive globally to suppress this message

解决: 编辑httpd.conf文件,将ServerName www.example.com:80前的“#”号去掉


二,页面显示:

Forbidden

You don't have permission to access / on this server.


查看日志,报错: AH00035: access to / denied (filesystem path '/home/datum/program') because search permissions are missing on a component of the path

解决:检查/home/datum/program 的权限,ll -a /home/datum/program 显示:drwxrwx---.  8 root   manager       4096 10月 17 12:30 ..,检查用户daemon所在的组:daemon : daemon root bin adm lp

经过分析,发现daemon用户没有/home/datum/program的权限。将daemon用户添加到组manager中即可:gpasswd -d daemon manager 重启httpd:  ./apachectl restart

最后访问页面,发现解决。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值