顯示廣告
隱藏 ✕
Disp BBS guest 註冊 登入(i) 負載稍重
看板 Knuckles_note
作者 Knuckles (站長 那克斯)
標題 [CentOS] Apache 安裝與設定
時間 2013年09月09日 Mon. AM 11:53:23


安裝環境: Linode 的 CentOS 6.5 64bit

新版 CentOS 7 請改至 [CentOS] Apache 安裝與設定 (CentOS 7) - KnucklesNote板 - Disp BBS


◎ 安裝 Apache

$ yum install httpd

CentOS 6.5 安裝的是 apache 2.2


啟動 httpd
$ service httpd start

用瀏覽器連看看能不能看到 Apache 的預設畫面
[圖]
 


設定 Apache 服務隨系統一起啟動

$ chkconfig httpd on

確認 Apache 自動啟動有打開

$ chkconfig --list httpd
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

確認2--5要為on



◎ 修改apache設定檔

$ vim /etc/httpd/conf/httpd.conf

# 接收或傳送時,當持續連線等待超過設定的秒數,連線就中斷
Timeout 60

# 設定是否使用保持連線
KeepAlive Off
MaxKeepAliveRequests 100 #設為0即無限制
KeepAliveTimeout 15


# prefork預設值
<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers    20
ServerLimit       256
MaxClients        256
MaxRequestsPerChild  4000
</IfModule>

# 依server的等級調整數字,例如
<IfModule prefork.c>
ServerLimit       1000
StartServers       8
MinSpareServers    10
MaxSpareServers    64
MaxClients        1000
MaxRequestsPerChild  10000
</IfModule>

# 注意ServerLimit要放在第一項才有用

# apache程序的使用者與群組
User apache
Group apache

# 設定ServerName
#ServerName www.example.com:80 改為 server的IP位址:80
ServerName xxx.xxx.xxx.xxx:80

#網頁根目錄預設存放的地方
DocumentRoot "/var/www/html"

# 網址沒有指定檔名時,預設開啟的檔名
# 預設 DirectoryIndex index.html index.html.var
# 刪除用不到的 index.html.var 再加上常用的 index.htm
# 不用加 index.php 因為在 /etc/httpd/conf.d/php.conf 裡會加
DirectoryIndex index.html index.htm




重新啟動 apache
# service httpd reload


===== 錯誤解決記錄 =====

◎ 剛安裝完啟動 httpd 時出現

Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using x.x.x.x for ServerName

只要修改設定檔 /etc/httpd/conf/httpd.conf
將 #ServerName www.example.com:80 改為 server的IP位址:80 即可
ServerName xxx.xxx.xxx.xxx:80


--
※ 作者: Knuckles 時間: 2013-09-09 11:53:23
※ 編輯: Knuckles 時間: 2017-02-14 14:54:00
※ 看板: KnucklesNote 文章推薦值: 0 目前人氣: 0 累積人氣: 1389 
分享網址: 複製 已複製
e)編輯 d)刪除 ^x)轉錄 同主題: =)首篇 [)上篇 ])下篇