不卡AV在线|网页在线观看无码高清|亚洲国产亚洲国产|国产伦精品一区二区三区免费视频

學(xué)習(xí)啦 > 學(xué)習(xí)電腦 > 選購與維護(hù) > 電腦組裝教程 > Apache服務(wù)器編譯安裝與簡(jiǎn)單配置

Apache服務(wù)器編譯安裝與簡(jiǎn)單配置

時(shí)間: 林澤1002 分享

Apache服務(wù)器編譯安裝與簡(jiǎn)單配置

  Apache是世界使用排名第一的Web服務(wù)器軟件。它可以運(yùn)行在幾乎所有廣泛使用的計(jì)算機(jī)平臺(tái)上,由于其跨平臺(tái)和安全性被廣泛使用,是最流行的Web服務(wù)器端軟件。下面是學(xué)習(xí)啦小編跟大家分享的是Apache服務(wù)器編譯安裝與簡(jiǎn)單配置,歡迎大家來閱讀學(xué)習(xí)。

  Apache服務(wù)器編譯安裝與簡(jiǎn)單配置

  工具/原料

  Linux操作系統(tǒng)(演示使用的為CentOS 6.5)

  Apache源碼包和較新版本的apr和apr-util (下載地址:http://pan.baidu.com/s/1kTmmGDL 密碼:pdn7)

  請(qǐng)先自行安裝好編譯環(huán)境:yum groupinstall "Development Tools" "Development Libraries"

  依賴pcre-devel 可以直接yum -y install pcre-devel (下載地址:http://pan.baidu.com/s/1i3IeSdB 密碼:pbp5)

  方法/步驟

  1首先下載最新版的Apache源碼包,因?yàn)?.4版的httpd需要較新版本的apr支持,所以需要先安裝新版本的apr以及apr-util。可以自行百度下載,也可以使用我提供的分享鏈接。

  2編譯安裝apr:

  # tar xf apr-1.5.1.tar.bz2

  # cd apr-1.5.1

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

  # make && make install

  編譯安裝apr-util:

  # tar xf apr-util-1.5.4.tar.bz2

  # cd apr-util-1.5.4

  # ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

  # make && make install

  編譯安裝httpd-2.4.10:

  tar xf httpd-2.4.4.tar.bz2

  # cd httpd-2.4.4

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

  --sysconfdir=/etc/httpd --enable-so --enable-ssl \

  --enable-cgi --enable-rewrite --with-zlib --with-pcre \

  --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util \

  --enable-modules=most

  # make && make install

  ./configure之后如果不確定配置成功沒,可以輸入echo $?來查看返回值,

  如果返回值為0 則繼續(xù)執(zhí)行make && make install

  Apache編譯安裝成功后安裝路徑為:/usr/local/apache

  配置文件路徑為:/etc/httpd/httpd.conf

  然后為Apache添加服務(wù)腳本:

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

  添加進(jìn)環(huán)境變量:

  # echo 'export PATH=$PATH:/usr/local/apache/bin' > \

  /etc/profile.d/httpd.sh

  # chmod +x /etc/profile.d/httpd.sh

  # source /etc/profile.d/httpd.sh

  編輯配置文件:

  # vim /etc/httpd/httpd.conf

  添加 ServerName localhost

  然后保存退出

  然后執(zhí)行服務(wù)腳本啟動(dòng)httpd :

  # service httpd start

  查看是否正常監(jiān)聽80端口:

  # netstat -anpt | grep "80"

  如果想確保正常訪問網(wǎng)頁請(qǐng)關(guān)閉SElinux和iptables防火墻

  或者自行添加iptables規(guī)則,我這里只臨時(shí)關(guān)閉。

  # setenforce 0

  # service iptables stop

  然后瀏覽器輸入你的主機(jī)名或IP地址來訪問你的web服務(wù)

  如何瀏覽器出現(xiàn)了大大的 It works! 那么恭喜你!你的apache服務(wù)器搭建成功了,你的網(wǎng)頁文檔目錄在 /usr/local/apache/htdocs 中

  如果想把a(bǔ)pache服務(wù)加入到開機(jī)自啟,可以修改服務(wù)啟動(dòng)腳本:

  # vim /etc/init.d/httpd

  在第二行下添加:# chkconfig:235 85 15

  # description: This is apache server!

  加入開機(jī)自啟:

  # chkconfig --add httpd

  其中235代表在第2,3,5運(yùn)行級(jí)別下會(huì)開機(jī)啟動(dòng)

  85和15代表開機(jī)和關(guān)機(jī)的啟動(dòng)順序,數(shù)值越大代表啟動(dòng)的優(yōu)先級(jí)越低

  后啟動(dòng)的一般要先關(guān)閉,參數(shù)可以隨你的喜好調(diào)整

  description后的內(nèi)容可以隨意寫

  對(duì)apache服務(wù)器的配置文件httpd.conf的簡(jiǎn)單介紹與設(shè)置:

  配置文件路徑為:/etc/httpd/httpd.conf

  用vim編輯器打開這個(gè)文件,以下是各選項(xiàng)意義:

  ServerRoot "/usr/local/apache" // Apache的安裝目錄

  ServerName localhost // 服務(wù)名稱,可以填主機(jī)名

  Listen 80 // 服務(wù)監(jiān)聽端口,默認(rèn)80

  LoadModule // 服務(wù)啟動(dòng)需要加載的模塊

  User daemon // apache進(jìn)程執(zhí)行者

  Group deamon // 執(zhí)行者的屬組

  ServerAdmin you@example.com // 管理員的郵箱地址

  DocumentRoot "/usr/local/apache/htdocs" // 網(wǎng)站根目錄

  ErrorLog "logs/error_log" // Apache運(yùn)行產(chǎn)生的錯(cuò)誤日志

  LogLevel warn // 指定ErrorLog會(huì)記錄的錯(cuò)誤的級(jí)別

  DirectoryIndex index.html // 網(wǎng)站目錄索引文件

  當(dāng)設(shè)置完配置文件后,如果想知道配置是否正確可以使用:

  # httpd -t 或者:# service httpd configtest

  如果輸出為:Syntax OK

  則證明配置文件沒有問題,然后就可以重啟服務(wù)了:

  # httpd -k restart 或者:# service httpd restart

  或者只提醒服務(wù)重新讀取配置文件:

  # httpd -k graceful 或者:# service httpd graceful

  如果想關(guān)閉服務(wù):

  # httpd -k stop 或者:# service httpd stop

  以上便是我對(duì)Apache服務(wù)器的編譯安裝及簡(jiǎn)單配置的全部?jī)?nèi)容了,在今后還會(huì)發(fā)布Apache的詳細(xì)配置,比如虛擬主機(jī),用戶認(rèn)證等。以后還會(huì)陸續(xù)發(fā)布FTP,Samba,Mysql,NFS等服務(wù)包括LAMP與LNMP的編譯安裝與配置。

Apache服務(wù)器編譯安裝與簡(jiǎn)單配置相關(guān)文章:

1.Nginx服務(wù)器的編譯安裝與配置

2.網(wǎng)站服務(wù)器Apache的常用配置

3.linux下配置web+ftp服務(wù)器全教程

4.linux下配置管理Apache服務(wù)器

5.Linux怎么搭建常用服務(wù)器

6.LINUX下配置管理APACHE服務(wù)器的方法

7.服務(wù)器上怎么安裝linux系統(tǒng)

2837505