RHCE7學習筆記37——Apache配置與管理

來源:互聯網
上載者:User

標籤:rhce7學習筆記37——apache配置與管理

一、Httpd.conf設定檔主要參數


    ServerRoot:


    Listen:添加除80之外的監聽連接埠,如808,需要加入selinux的上下文,

 [[email protected] ~]# semanage port -a -t http_port_t -p tcp 808

     

    Include:載入的模組
[[email protected] ~]# httpd -M 查看載入的模組

        

    ServerName:佈建網站名,標記不同的網站;

        

    DocumentRoot:網站主目錄


    Directory:目錄

<Directory "/var/www/html/iso">    Options Indexes FollowSymLinks ----Index指index.html不存在,則列出訪問資源,FollowSymLinks是否允許軟連結訪問;    AllowOverride None :是否允許.htaccess檔案的內容覆蓋httpd.conf    Allow open access:     Require all granted     或者Require all denied         Require ip 192.168.1.10         Require local</Directory>


    

[[email protected] test]# htpasswd -mc .htpasswd tom
 .htaccess 1 AuthName "test"  2 AuthType Basic  3 AuthUserFile /etc/httpd/conf/.htpasswd  4 require user redhat
<IfModule dir_module>     DirectoryIndex index.html </IfModule>

    

    設定訪問別名:

Alias /webpath /full/filesystem/path

   



        動態網頁:


    CGI: 公用網關介面

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"


    WSGI:web server gateway interface


    SSI:server side include 預設的尾碼名需為:shtml shtm



    地址修正,頁面跳轉:

            URL:網域名稱+URI

 RewriteEngine on RewriteRule ^/test$ /test/ [R]

        

二、配置虛擬機器主機


    1、基於主機名稱

  <VirtualHost *:80>      #ServerAdmin [email protected]      DocumentRoot /var/www/html/baidu      ServerName www.baidu.com      ServerAlias www1.baidu.com     # ErrorLog "/var/log/httpd/dummy-host.example.com-error_log"     # CustomLog "/var/log/httpd/dummy-host.example.com-access_log" common  </VirtualHost>

    2、基於IP地址

  <VirtualHost IP地址:80>      #ServerAdmin [email protected]      DocumentRoot /var/www/html/baidu      ServerName www.baidu.com      ServerAlias www1.baidu.com     # ErrorLog "/var/log/httpd/dummy-host.example.com-error_log"     # CustomLog "/var/log/httpd/dummy-host.example.com-access_log" common  </VirtualHost>


    3、基於連接埠




三、配置HTTPS


    Https -- http + ssl(or tls)


    伺服器端進入/etc/pki/tls/certs目錄,產生測試用的認證和私密金鑰:

[[email protected] certs]# make test.crt

    

    安裝ssl模組:

yum install mod_ssl.x86_64 -y

    編輯虛擬機器主機設定檔

    

 43 <VirtualHost *:443> 44     #ServerAdmin [email protected] 45     DocumentRoot /var/www/html/sg 46     ServerName www.sg.com 47     ServerAlias www1.sg.com 48     SSLEngine on 49     SSLCertificateFile /etc/httpd/conf/sg.crt 50     SSLCertificateKeyFile /etc/httpd/conf/sg.key 51    # ErrorLog "/var/log/httpd/dummy-host.example.com-error_log" 52    # CustomLog "/var/log/httpd/dummy-host.example.com-access_log" common 53 </VirtualHost>

    

 32 <VirtualHost *:80> 33     #ServerAdmin [email protected] 34     DocumentRoot /var/www/html/sg 35     ServerName www.sg.com 36     ServerAlias www1.sg.com 37     RewriteEngine on 38     RewriteRule ^/(.*)  https://www.sg.com/$1 [L,R] 39    # ErrorLog "/var/log/httpd/dummy-host.example.com-error_log" 40    # CustomLog "/var/log/httpd/dummy-host.example.com-access_log" common 41 </VirtualHost>


本文出自 “平凡之路” 部落格,請務必保留此出處http://linjohn.blog.51cto.com/1026193/1614491

RHCE7學習筆記37——Apache配置與管理

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.