準備工作
centos6 關閉防火墻 service iptables stop;chkconfig iptables off 永久關閉防火墻
centos7 關閉防火墻 systemctl stop firewalld;systemctl disable firewalld
關閉SELinux
setenforce 0 臨時關閉
cat /etc/selinux/config 要永久關閉得該文件
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three two values:
# targeted – Targeted processes are protected,
# minimum – Modification of targeted policy. Only selected processes are protected.
# mls – Multi Level Security protection.
SELINUXTYPE=targeted
將 SELINUX=enforcing 改成 SELINUX=disabled
這是詳細步驟
1.安裝在哪
2 要定制的功能
c語言源碼編譯三大步
1. ./configure
(1) 通過選項傳遞參數,指定啟用特性、安裝路徑等;執行時會參考用戶的
指定以及Makefile.in文件生成Makefile
(2) 檢查依賴到的外部環境,如依賴的軟件包
2. make 根據Makefile文件,構建應用程序
3. make install 復制文件到相應路徑
安裝工具 安裝包組
第一步 安裝包組”Development tools”
第二步 下載源碼包 httpd-2.2.34.tar.bz2
第三步 解壓源碼包 放在 /usr/local/src 命令 tar xvf httpd-2.2.34.tar.bz2
第四步 進入解壓的httpd-2.2.34 目錄下
第五部 ls 查看有沒有configure腳本 和 Makefile.in
第六步 查看幫助手冊 cat README
第七步 查看安裝手冊 cat INSTALL
第八步 ./configure –help 查看腳本的–help 可以看見要啟用那些 禁用那些
注 將所有程序放在一個文件夾./configure –prefix=/app –sysconfdir=/etc/httpd22 –disable-env –enable-charset-lite –enable-ssl
將配置文件單獨放出來 –sysconfdir=/etc/httpd22 默認不放在/app下 建議不要太獨立
第九步 執行 ./configure –prefix=/app –sysconfdir=/etc/httpd22 –disable-env –enable-charset-lite –enable-ssl
第十步 執行以后會自動檢測要那些依賴包沒有安裝完成
例:no OpenSSL headers found
在編譯安裝的時候一般缺開發包 devel 例如:openssl-devel.i686
第十一步 yum install openssl-devel 安裝缺的依賴包
第十二步 在執行./configure \–prefix=/app –sysconfdir=/etc/httpd22 –disable-env –enable-charset-lite –enable-ssl
第十三步 會在次檢測依賴包 ,在安裝
第十四步 echo $? 檢測上一次命令有沒有成功 0代表成功
第十五步 執行make 執行的時候會花一段時間 建議為了加速訪問 可以啟用并行的編譯,并行編譯依賴CPU的個數
第十六步 執行make -j 4 有幾顆CPU就加幾顆
第十七步 執行的時候可能會花很多時間 讓程序執行完就休眠一秒報警
make -j 4 && echo -e “\a” && sleep 1 && echo -e “\a” && sleep 1 && echo -e “\a” && sleep 1 && echo -e “\a” && sleep 1 && echo -e “\a” && sleep 1 && echo -e “\a” && sleep 1
第十八步 執行完./configure 會生成一個 Makefile 文件
第十九步 執行make install
第二十步 查看已經生成 /app 和/etc/httpd22 文件夾
第二十一步 檢查安裝的效果 要執行 /app/bin/apachectl start
第二十二步 要執行apachectl start 可以絕對路徑,也可以把/app/bin文件夾放到$PATH變量下
vim /etc/profile.d/env.sh
PATH=/app/bin:$PATH 將/app/bin加入 $PATH變量
. /etc/profile.d/env.sh 讓程序生效
第二十三 步執行 apachectl start
第二十四步 ss -ntl 檢查80端口有沒有打開
第二十五步 在瀏覽器輸入ip 檢查有沒有成功
注 :網站的主站點的網頁放在了 /app下的 htdocs文件夾下的 index.html 文件
cat /app/htdocs/index.html 可以更改
注 centos 7 安裝 httpd2.4的包
centos 6 安裝 httpd2.2的包
這是一鍵安裝的腳本
腳本編寫
cen=`cat /etc/centos-release |grep -o ” [0-9]” |grep -o “[0-9]”`
[ $cen -eq 7 ] && echo `systemctl stop firewalld` && `systemctl disable firewalld` || echo `service iptables stop` `chkconfig iptables off`
sleep 3
yum group install “Development tools” -y
yum install pcre-devel -y
yum install apr-util-devel -y
yum install apr-devel -y
sleep 3
cd /usr/local/src/
[ $cen -eq 7 ] && echo `tar xvf httpd-2.4.25.tar.bz2` || echo `tar xvf httpd-2.2.34.tar.bz2`
sleep 3
[ $cen -eq 7 ] && echo `bash /usr/local/src/httpd-2.4.25/configure –prefix=/app`
[ $cen -eq 6 ] && echo `bash /usr/local/src/httpd-2.2.34/configure –prefix=/app`
sleep 3
make -j 4 && echo -e “\a” && sleep 1 && echo -e “\a” && sleep 1 && echo -e “\a”
sleep 3
make install
echo “PATH=/app/bin:$PATH” >> /etc/profile.d/env.sh && echo `. /etc/profile.d/env.sh`
apachectl start
本文來自投稿,不代表Linux運維部落立場,如若轉載,請注明出處:http://www.www58058.com/96856
更新:在腳本里面加入自動下載Apache源碼包
cd /usr/local/src
[ $cen -eq 7 ] && echo `wget http://archive.apache.org/dist/httpd/httpd-2.4.25.tar.gz` || echo `wget http://archive.apache.org/dist/httpd/httpd-2.2.34.tar.gz`