【Linux】Apache服務配置

來源:互聯網
上載者:User

標籤:Tlog   mon   option   master   module   .bashrc   命令別名   3.2   roo   

一. URL 統一資源定位器
    http://www.sina.com.cn:80/admin/index.html
二. 環境安裝
    LAMP 源碼包編譯安裝  版本可以自訂     生產環境  安全 穩定     開發環境            LAMP 二進位包安裝 yum 
三. 相關檔案
   設定檔位置                /usr/local/apache2/etc/httpd.conf               /usr/local/apache2/etc/extra/httpd-*.conf   網頁檔案預設儲存位置              /usr/local/apache2/htdocs/   日誌儲存位置               /usr/local/apache2/logs/   Tlog(切割輪替)        vim /etc/logrotate.conf        /usr/local/apache2/logs/access_log {            daily            rotate 30        }        /usr/local/apache2/logs/error_log {            daily            rotate 30        }    logrotate -f  /etc/logrotate.conf   手動執行檔案    cd /usr/local/apache2/logs/    ls 
四. 設定檔
命令別名 aliasvim /root/.bashrcalias sto=‘/usr/local/apache2/bin/apachectl stop‘alias sta=‘/usr/local/apache2/bin/apachectl start‘source /root/.bashrcstosta實驗1  目錄別名    擴充網站目錄  增加伺服器    1.修改主設定檔    vim /usr/local/apache2/etc/httpd.conf    453 Include etc//extra/httpd-autoindex.conf    2.配置子設定檔    vim /usr/local/apache2/etc/extra/httpd-autoindex.conf     29 Alias /www/ "/usr/local/apache2/www/"     30      31 <Directory "/usr/local/apache2/www/">     32     Options Indexes     33     AllowOverride None     34     Require all granted     35 </Directory>     3.建立www目錄       mkdir /usr/local/apache2/www/      vim /usr/local/apache2/www/index.html       hello  /usr/local/apache2/www/              4.重啟服務  測試         sto        sta        測試  192.168.183.251/www/實驗2 虛擬機器主機     1.網域名稱解析  (檔案解析)  (windows)      C:\Windows\System32\drivers\etc\hosts     192.168.183.251    www.sina.com     192.168.183.251    www.sohu.com    2.網站網域名稱規劃      mkdir -p /share/sina/      mkdir  /share/sohu/      vim /share/sina/index.html      vim /share/sohu/index.html    3.修改設定檔     vim /usr/local/apache2/etc/httpd.conf     465 Include etc//extra/httpd-vhosts.conf    4.修改子設定檔     vim /usr/local/apache2/etc/extra/httpd-vhosts.conf      23 <Directory "/share/sina/">      24       Options Indexes      25       AllowOverride None      26       Require all granted      27 </Directory>      28           29 <Directory "/share/sohu/">      30       Options Indexes      31       AllowOverride None      32       Require all granted      33 </Directory>       35 <VirtualHost 192.168.183.251>      36     ServerAdmin [email protected]      37     DocumentRoot "/share/sina/"      38     ServerName www.sina.com      39     ErrorLog "logs/sina-error_log"      40     CustomLog "logs/sina-access_log" common      41 </VirtualHost>      42       43 <VirtualHost 192.168.183.251>      44     ServerAdmin [email protected]      45     DocumentRoot "/share/sohu/"      46     ServerName www.sohu.com      47     ErrorLog "logs/sohu-error_log"      48     CustomLog "logs/sohu-access_log" common      49 </VirtualHost>    5.重啟服務  測試    sto    sta    測試  www.sina.com   www.sohu.com    實驗3 rewrite 重寫/重新導向          www.sina.com -> www.sohu.com   (301 永久重新導向)    1.修改設定檔    vim /usr/local/apache2/etc/httpd.conf    147 LoadModule rewrite_module modules/mod_rewrite.so    2.修改子設定檔(虛擬機器主機檔案)    vim /usr/local/apache2/etc/extra/httpd-vhosts.conf     23 <Directory "/share/sina/">     24       Options Indexes FollowSymLinks     25       AllowOverride All     26       Require all granted     27 </Directory>    3.建立許可權檔案.htaccess     vim /share/sina/.htaccess       1 RewriteEngine on         2 RewriteCond %{HTTP_HOST} www.sina.com       3 REwriteRule .* http://www.sohu.com    4.重啟服務  測試      sto      sta      測試  www.sina.com -> www.sohu.com      網頁檔案跳轉      1.修改.htaccess           index().html    index.php      vim /share/sina/.htaccess       1 RewriteEngine on         2 REwriteRule index(\d+).html index.php?id=$1      2.建立index.php        vim /share/sina/index.php         1 <?php  echo "rewrite" ?>      3.重啟服務 測試      sto      sta      測試  www.sina.com/index5.html

【Linux】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.