RHEL 6 LAMP(一)

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
測試

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章