Linux上安裝Apache服務器


 

 

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

 httpd-2.4.29.tar.gz

#創建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

編譯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

 

apr-1.6.3.tar.gz

./configure --prefix=/usr/local/apr
make && make install

 

 

apr-util-1.6.1.tar.gz

./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

 

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

pcre-8.38.zip

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

make && make install

 

然后安裝Apache:

./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

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM