linux中安装apache服务器,Linux上安装Apache服务器

http://httpd.apache.org/download.cgi

fz.gif

#创建httpd用户

groupadd httpd

useradd -g httpd -s /sbin/nologin -M httpd

tar zxvf httpd-2.4.29.tar.gz

cd httpd-2.4.29

./configure --prefix =/usr/local/apache

make && make install

fz.gif

编译apache时可能会出错:

#./configure --prefix……检查编辑环境时出现:

checking for APR... no

configure: error: APR not found . Please read the documentation

解决办法:

安装 apr  apr-util  pcre

https://apr.apache.org/download.cgi

./configure --prefix=/usr/local/apr

make && make install

./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config

make && make install

编译apr-util时报错:make[1]: *** [xml/apr_xml.lo] Error 1

解决方法:yum -y install expat-devel

注意选择下载pcre或者pcre2

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

pcre-8.38.zip

./configure --prefix=/usr/local/pcre

make && make install

然后安装Apache:

fz.gif

./configure --prefix=/usr/local/apache/ --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/

make && make install

/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ParserCreate‘

/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_GetErrorCode‘

/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetUserData‘

/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ErrorString‘

/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetEntityDeclHandler‘

/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ParserFree‘

/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetElementHandler‘

/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_StopParser‘

/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_Parse‘

/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetCharacterDataHandler‘

collect2: ld returned 1 exit status

make[2]: *** [htpasswd] Error 1

make[2]: Leaving directory `/root/zhouw/package/httpd-2.4.29/support‘

make[1]: *** [all-recursive] Error 1

make[1]: Leaving directory `/root/zhouw/package/httpd-2.4.29/support‘

make: *** [all-recursive] Error 1

fz.gif

make 时上面报错,尝试用 apr-1.5.2 版本

下载地址: http://archive.apache.org/dist/apr/

wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz

wget http://archive.apache.org/dist/apr/apr-util-1.5.2.tar.gz

安装方法与上面 1.6版本一样,果然成功了。应该是 CentOS7 才支持 apr-1.6 版本。

安装完成后,切到安装目录,/usr/local/apache

# vim conf/httpd.conf  #配置“Listen”和“ServerName”属性;

Listen 80

ServerName localhost

# ./bin/apachectl configtest

Syntax OK

# 启动httpd

/usr/local/apache/bin/apachectl start | stop | restart

或者:

cp /usr/local/apache/bin/apachectl /etc/init.d/httpd

/etc/init.d/httpd start

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值