linux構建動態WEB服務器配置篇
2020-07-08 13:01:15
供稿:網友
Apache配置文件
重要配置選項
ServerRoot 服務器運行的根目錄
MaxClients 能同時訪問服務器的客戶機數量
DocumentRoot 服務器共享文件的起始位置
listen 服務器監聽的端口
ServerAdmin 管理員的信箱
User&Group 服務器運行者的身份
ErrorLog 出錯日志文件
DirectoryIndex 默認文件夾索引文件
AddDefaultCharset 默認返回頁面的編碼
Alias 為目錄設置訪問別名
查看Apache內部默認模塊 /usr/local/apache2/bin/httpd -l
目錄控制語句
<Directory /> #默認根目錄
Options Indexes Follow Symlink #可以使用index文件
AllowOverride None #不能被復蓋
</Director>
以上沒有權限語句,所有向上的訪問都不能執行
<Directory /usr/local/apache2/htdocs>
Options Follow Symlink
AllowOverride None #不能被復蓋
Order allow.deny
Allow from all #任何地址都能訪問,Allow,Deny
</Directory>
測試CGI
配置文件選項
ScriptAlias /cgi-bin “/usr/local/apache2/cgi-bin/”
編寫cgi文件
/usr/local/apache2/cgi-bin/<cgifile>
確認cgi程序是apache用戶可以執行的
#chgrp apache /usr/local/apache2/cgi-bin/<cgifile>
#chmod 750 /user/local/apache2/cgi-bin/<cgifile>
測試cgi程序的執行效果
#links http://localhost/cgi-bin/<cgifile>
激活SSL模塊
創建私鑰和證書文件
#cd /etc; mkdir ssl.crt server.key
#openssl genrsa -out /etc/ssl.key/server.key 1024
#openssl req -new -x509 -key /
/etc/ssl.key/server.key -out /etc/ssl.crt/server.crt
編輯/etc/ssl.conf
重新啟動web服務器
#/usr/local/apache2/bin/apachectl stop
#/usr/local/apache2/bin/apachectl startssl
(修改啟動腳本/etc/rc.local中的相應的命令)