Apache網站服務器:做爲LAMP架構的前端,是一款功能強大、穩定性好的Web服務器程序,該服務器直接面向用戶提供網站訪問,發送網頁、圖片等文件內容。html
實驗要求:前端
手工編譯安裝Apache服務器,使宿主機能夠訪問搭建的Apache服務器網站c++
實驗環境:正則表達式
1、須要的軟件包apache
http-2.4.2.tar.gz vim
apr-1.4.6.tar.gz 服務器
apr-util-1.4.1.tar.gz 架構
2、主要目錄和文件ide
主頁存放路徑: /usr/local/apache/htdocs/index.html優化
主配置文件路徑:/usr/local/apache/conf/httpd.conf
服務腳本路徑:/usr/local/apache/bin/apachectl
實驗步驟:
1、下載安裝環境包
mount.cifs //192.168.100.102/gongxiang /abc
tar xzvf http-2.4.2.tar.gz -C /opt
tar xzvf apr-1.4.6.tar.gz -C /opt (支持Apache上層應用跨平臺,提供底層接口庫)
tar xzvf apr-util-1.4.1.tar.gz -C /opt
cp -R apr(解壓後的文件夾) /opt/httpd-2.4.2/srclib/apr
cp -R apr-util(解壓後的文件夾) /opt/httpd-2.4.2/srclib/apr-util
2、安裝譯碼器
安裝 gcc 、 gcc-c++ 、 make 、 pcre、pcre-devel 四個包
(pcre : 一個Perl庫,支持正則表達式)
3、安裝軟件包
cd /opt/httpd-2.4.2
./configure \
--prefix=/usr/local/apache \ #指定安裝路徑
--enable-so \ #讓 Apache 能夠支持DSO模式
--enable-rewrite \ #支持 URL 重寫
--enable-mods-shared=most \ #告訴編譯器將全部標準模塊都動態編譯爲DSO模塊
--with-mpm=worker \ # 讓apache以worker方式運行
--disable-cgid \ # 禁止用一個外部 CGI 守護進程執行CGI腳本
--disable-cgi # 禁止編譯 CGI 版本的 PHP
make
make install
4、優化httpd開機自動加載服務
grep -v "#" /usr/local/apache/bin/apachectl > /etc/init.d/httpd
vi /etc/init.d/httpd 在文件最前面插入下面的行
#!/bin/sh
# chkconfig:2345 85 15
# description:Apache is a World Wide Web server. chmod +x /etc/init.d/httpd
chkconfig --add httpd
chkconfig --list httpd
chkconfig --level 35 httpd on
5、修改httpd配置文件
創建軟鏈接便於管理vim /etc/httpd.conf
Listen:IPV4
ServerName:主機名.域名
service httpd stop
service httpd start
實驗內容:
1、下載安裝環境包
2、安裝譯碼器
3、安裝軟件包
4、優化httpd開機自動加載服務
5、修改httpd配置文件