標籤:apache
系統內容:Ubuntu
1. 查看 apache2 版本
? ~ apachectl -vServer version: Apache/2.4.7 (Ubuntu)Server built: Apr 3 2014 12:20:25
2.重啟 apache
#重啟 apachesudo /etc/init.d/apache2 restart#開啟 apachesudo /etc/init.d/apache2 start#關閉 apachesudo /etc/init.d/apache2 stop
3.開啟 htaccess 用於存取控制。開啟 apache 設定檔,我的是 /etc/apache2/apache2.conf,因為我的 web 目錄在 /var/www 下,所以找到設定檔中的對應目錄,並把 AllowOverride 選項改為 All. AllowOverride 表示允許存在於.htaccess 檔案中的指令類型,None 表示不搜尋該目錄下的.htaccess檔案,All 表示在 .htaccess 檔案中可以使用所有的指令。
<Directory /var/www/>Options Indexes FollowSymLinksAllowOverride AllRequire all granted</Directory>
4.重啟時出現 AH00558: apache2: Could not reliably determine the server‘s fully qualified domain name, using 127.0.1.1. Set the ‘ServerName‘ directive globally to suppress this message。
開啟設定檔,加上 ServerName 的定義
#開啟設定檔sudo vim /etc/apache2/apache2.conf#在其中加上這一句ServerName localhost:80
5.重啟時出現 (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
網上給出了各種方法:
http://ubuntuforums.org/showthread.php?t=1636667
http://stackoverflow.com/questions/10160339/starting-apache-fails-could-not-bind-to-address-0-0-0-080
結果都發現不起作用,因為根本就找不到佔用了 80 連接埠的進程。
最後發現是因為在 apache2.conf 同一級目錄下的 ports.conf, 裡面已經有 Listen 80 了,然後在 apache2.conf 裡面有
Include ports.conf
即是包含了 ports.conf 檔案,所以是重複定義了,難怪會出錯。。。。
解決方案是:這一句不用寫了....或者 Listen 另一個連接埠
Ps:假如寫了 Listen 23333, Apache 就會為你開啟這個連接埠,不用自己先去開啟。
6. 出現問題 AH00548: NameVirtualHost has no effect and will be removed in the next release
從 Apache 2.3.11 開始的版本,這一句已經不需要了,刪之。。。。
待續。
Apache 學習筆記