Linux Web
1、rpm包方式的web
1.1 安裝
1.2 配置
1.2.1 虛擬機器主機
1.3 整合php,mysql
1.4 整合ftp服務
2、源碼編譯的web
2.1 安裝
2.2 配置
2.2.1 虛擬機器主機
2.3 整合php,mysql
2.4 整合ftp服務
----------------
1、安裝系統(rpm包方式的)
資料分割配置(硬碟為80G)
/boot 200M
/ 10G
swap 2G
/home 剩餘所有的
*/home裡面是給使用者所使用的空間,以後虛擬機器主機都開這裡
選擇全球資訊網伺服器---現在自訂
添加ftp服務,nfs服務,電子郵件服務,網路基礎設施伺服器中添加bind三個
進行安裝
*DNS如果單獨做了伺服器了。就不用裝了
安裝完成後要做的
1、配置ip
setup裡面配置
2、關閉防火牆
setup裡面關閉
3、關閉SELinux
vi /etc/selinux/config
改
SELINUX=disabled
4、重啟
------------------------------------
進入系統,啟動httpd服務並測試
測試出現測試頁面證明apache裝好了
------------------------------------
apache 的設定檔
/etc/httpd/conf/httpd.conf #主設定檔
/etc/httpd/conf.d #擴充設定檔存放的目錄
manual.conf #協助手冊配置(建議關閉)
php.conf #php配置
ssl.conf #ssl加密訪問配置
welcome.conf #歡迎頁面配置
perl.conf #perl配置
webalizer.conf #日誌分析配置
wsgi.conf #wsgi支援
/etc/httpd/conf/httpd.conf #設定檔部分內容說明
ServerTokens OS
ServerRoot "/etc/httpd" #httpd的主要檔案存放目錄
PidFile run/httpd.pid #運行檔案位置
Timeout 60 #客戶連線逾時時間為60秒
#保活訪問
KeepAlive On #改為開啟
MaxKeepAliveRequests 100 #每個ip最多的串連是100個
KeepAliveTimeout 15 #每個最長時間是15秒
串連數控制
<IfModule prefork.c> #進程方式控制
StartServers 8 #開啟幾個服務進程
MinSpareServers 5 #最小5個
MaxSpareServers 20 #最大20個
ServerLimit 256 #上限是256個
MaxClients 256 #每個最多串連用戶端數量
MaxRequestsPerChild 4000 #每個最多的請求數是4000
</IfModule>
<IfModule worker.c> #線程方式
StartServers 4 #4個服務端
MaxClients 300 #每線程最多300
MinSpareThreads 25 #最小線程是25個
MaxSpareThreads 75 #最多線程是75
ThreadsPerChild 25 #預設為25
MaxRequestsPerChild 0 #最大請求無限制
</IfModule>
Listen 80 #伺服器監聽連接埠預設為80
#拓展模組。自己查
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
...
Include conf.d/*.conf #擴充的設定檔
User apache #apache的使用者身份
Group apache #apache的組身份
ServerAdmin root@localhost #伺服器管理員的郵件地址
UseCanonicalName Off #沒用的
DocumentRoot "/var/www/html" #預設網站頁面存放目錄
<Directory /> #網站/目錄的許可權
Options FollowSymLinks #支援串連
AllowOverride None
</Directory>
<Directory "/var/www/html"> #預設網站頁面存放目錄許可權
Options Indexes FollowSymLinks #網站索引,支援串連
AllowOverride None #存取控制
Order allow,deny #先允許再拒絕
Allow from all #允許所有
# Deny from ip #拒絕某個ip的訪問
</Directory>
<IfModule mod_userdir.c> #個人首頁支援
UserDir disabled
</IfModule>
DirectoryIndex index.html index.html.var #目錄索引頁面名稱
#存取控制檔案.htaccess功能
AccessFileName .htaccess
<Files ~ "^\.ht">
Order allow,deny
Deny from all
Satisfy All
</Files>
AddDefaultCharset UTF-8 #預設頁面編碼為UTF-8
----------------------------------------------
添加ServerName web1.amao.com
1、個人首頁支援“http://ip/~使用者名稱”訪問個人首頁
a、修改設定檔,支援這種訪問
vi /etc/httpd/conf/httpd.conf
找到
<IfModule mod_userdir.c>
#
# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#
UserDir disabled #去掉某個使用者的訪問
#
# To enable requests to /~user/ to serve the user's public_html
# directory, remove the "UserDir disabled" line above, and uncomment
# the following line instead:
#
#UserDir public_html #使用者的預設頁面的目錄
</IfModule>
修改為
<IfModule mod_userdir.c>
#
# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#
UserDir disabled root
#
# To enable requests to /~user/ to serve the user's public_html
# directory, remove the "UserDir disabled" line above, and uncomment
# the following line instead:
#
UserDir public_html
</IfModule>
去掉下列內容前面的#號,並在Indexes前面加“-”號
<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit
Options MultiViews -Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
b、添加使用者,並建立個人首頁的目錄
adduser test #添加使用者
cd /home/test
mkdir public_html #在使用者目錄裡面建立個人首頁使用的目錄
chown test.test public_html #配置個人首頁使用的目錄的許可權
chmod o+x /home/test #給使用者主目錄添加其他使用者列出許可權(不加就打不開)
cd /home/test/public_html
echo "test" > index.html
c、重啟服務並測試
service httpd restart
瀏覽器輸入http://ip/~test測試
--------------------------------------------------------------------
基於名稱的虛擬機器主機(重點)
1、做DNS
vi /etc/named.conf
改3個any
vi /etc/named.rfc1912.zones
添加
zone "amao.com" {
type master;
file "amao.com.hosts";
};
-----------------
cd /var/named/
cp named.localhost amao.com.hosts
vi amao.com.hosts
添加
www IN A 你的web伺服器的ip
---------
chown root.named amao.com.hosts
service named restart
---------------------------------------------
再添加個agou.com的網域名稱
2、在apache的設定檔中添加虛擬機器主機(先把個人首頁做出了再做這個)
vi /etc/httpd/conf/httpd.conf
在檔案最後添加
NameVirtualHost 192.168.100.1 #名稱虛擬機器主機開在那個ip上
NameVirtualHost 192.168.100.1
<VirtualHost 192.168.100.1>
ServerName www.amao.com
DocumentRoot /home/amao/public_html
</VirtualHost>
<VirtualHost 192.168.100.1>
ServerName www.agou.com
DocumentRoot /home/agou/public_html
</VirtualHost>
3、建立amao使用者,agou使用者,做法和個人首頁做法一樣
4、重啟服務,瀏覽器輸入
http://www.amao.com
http://www.agou.com
測試
本文出自 “王道--旭忠著(MakeWong)” 部落格