CentOS7之編譯安裝apache

1、安裝 gcc、gcc-c++、make等編譯工具

【其中】可以使用yum安裝  或者  通過該網址https://www.lmonkey.com/tools/linux下載

2、apr 、apr-util、httpd、pcre、zlib的.tar.gz源碼包安裝

【其中】可以使用wget下載。將apr、apr-util複製到httpd的srclib對應的目錄下,如下所示:

cp -a /root/lamp/apr /root/httpd/srclib/apr
cp -a /root/lamp/apr-util /root//httpd/srclib/apr-util

看報錯是否需要安裝expat-devel,如果需要yum進行安裝

pcre、zlib安裝:直接./configure

httpd安裝:(參考如下)

./configure \
--prefix=/usr/local/http2 \
--sysconfdir=/etc/httpd \
--enable-mods-shared=all 
或者
./configure  \
--prefix=/usr/local/apache2  \
--sysconfdir=/usr/local/apache2/etc \
--with-included-apr  \
--enable-so   \
--enable-deflate=shared  \
--enable-expires=shared \
--enable-rewrite=shared  \
--enable-ssl
或者
./configure \
--prefix=/usr/local/apache \
-with-pcre=/usr/local/pcre/bin/pcre-config \
-with-include-apr

3、啓動httpd服務

apache httpd啓動關閉,以及設置開機啓動

/usr/sbin/httpd -k start或者/usr/sbin/apachectl start

4、關閉防火牆

下面是red hat/CentOs7關閉防火牆的命令!

1:查看防火狀態

systemctl status firewalld

service  iptables status

2:暫時關閉防火牆

systemctl stop firewalld

service  iptables stop

3:永久關閉防火牆

systemctl disable firewalld

chkconfig iptables off

4:重啓防火牆

systemctl enable firewalld

service iptables restart  

5:永久關閉後重啓

//暫時還沒有試過

chkconfig iptables on

5、配置動態獲取ip

6、httpd設置爲開機自啓動

生成軟連接ln -s /usr/sbin/apachectl /bin/apachectl

自啓動配置文件:/etc/rc.d/rc.local

7、備註:

httpd安裝目錄爲
/usr/local/xxx

過濾顯示內容
cat httpd.conf |grep -v '#' | grep -v '^$'|cat -n

添加用戶
useradd mysql
useradd -r -s /sbin/nologin mysql

給文件添加權限
chmod u+x,g+x,o+x /usr/local/mysql
chmod +755 /usr/local/mysql

給文件添加用戶及用戶所在組
chown -R mysql.mysql /usr/local/mysql

如無此命令,請安裝:
如無此命令安裝yum install yum-utils

下載軟件包、以及依賴到指定目錄:
yumdownloader –resolve –destdir=/root/rpm/ net-tools

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章