共計(jì) 1631 個(gè)字符,預(yù)計(jì)需要花費(fèi) 5 分鐘才能閱讀完成。
這篇文章主要介紹 SUSE Linux 如何配置 Apache,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
在安裝 SUSE 時(shí)選擇安裝了 Apache(現(xiàn)在是 Apache2 版本)或是在 SUSE 光盤(pán)中選擇安裝 Apache,當(dāng)然也可以到網(wǎng)上下載 Apache 的 *** 版用 RPM 格式直接安裝或是手動(dòng)編譯安裝,那么在終端中可以輸入下列命令對(duì) Apache 進(jìn)行操作 (終端中的 #表示命令提示符,而文件中的# 一般表示注釋):
啟動(dòng) Apache 服務(wù)器:
#/usr/sbin/rcapache2 start
重啟 Apache 服務(wù)器:
#/usr/sbin/rcapache2 restart
停止 Apache 服務(wù)器:
#/usr/sbin/rcapache2 stop
大多數(shù)的 Web 服務(wù)器上不會(huì)只放一個(gè)站點(diǎn),這樣就需要我們配置 Apache 來(lái)支持虛擬主機(jī)。而在新版 SUSE 中,Apache 已經(jīng)改成模組化,只要簡(jiǎn)單的修改幾個(gè)配置文件就可以在建立帳號(hào)時(shí), 網(wǎng)站就對(duì)應(yīng)的到位置。而不用去修改 http.conf 一個(gè)個(gè)建對(duì)應(yīng) /home 的位置, 建完還要重新啟動(dòng) Apache。步驟如下:
1. 修改 /etc/sysconfig/apache2
#vi /etc/sysconfig/apache2
找到 APACHE_MODULES
在 *** 面加上 vhost_alias,保存重新編譯 apach3 的設(shè)定檔讓 apache2 載入 vhost 模組
#SuSEconfig ——module apache2
2. 在 /etc/apache2/vhosts.d/ 建立一個(gè)新檔叫 vhost.conf 內(nèi)容如下:
#vi /etc/apache2/vhosts.d/vhost.conf
UseCanonicalName Off
ErrorLog /var/log/apache2/error_log
CustomLog /var/log/apache2/access_log common
VirtualDocumentRoot /home/vhost/%0/public_html
VirtualScriptAlias /home/vhost/%0/public_html/cgi-bin
AddHandler cgi-script .cgi
Options ExecCGI
SetHandler cgi-script
默認(rèn)應(yīng)該是 /home/%0/public_html
/home 的后面沒(méi) vhost
為管理方便所以多建一層目錄,這樣 home 看起來(lái)就干凈多了。
3. 修改 default-server.conf
vi default-server.conf
找到 ScriptAlias XXXXXX,注釋掉這一段
#ScriptAlias /cgi-bin/ /srv/www/cgi-bin/
# /srv/www/cgi-bin should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
#
# AllowOverride None
# Options +ExecCGI -Includes
# Order allow,deny
# Allow from all
#
如果沒(méi)有需要多建目錄的,這邊 apache2 restart 就可以直接跳過(guò)下面 4 的動(dòng)作
4. 若有多建一層還要繼續(xù)修改 mod_userdir.conf
#vi mod_userdir.conf
5. 重新啟動(dòng) apache2
#rcapache2 restart
以后要建立網(wǎng)站,只要建立新 USER 時(shí),目錄直接建成 domain 方式就可以了
例如
ABC USER 的目錄建成 /home/vhost/www.xyz.com
apache 就會(huì)自動(dòng)去 /home/vhost/www.xyz.com/public_html/ 目錄下讀網(wǎng)站資料了。
以上是“SUSE Linux 如何配置 Apache”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注丸趣 TV 行業(yè)資訊頻道!