Ubuntu16.04 apache2.4 修改默認根目錄

 Ubuntu16.04 默認 apt-get install apache2 安裝的apache2.4
apache2.4配置根目錄文件在 
/etc/apache2/sites-available/000-default.conf
默認是 var/www/htmlphp

能夠改爲想要的目錄,好比/home/judge/etc/web

默認主頁的配置在
/etc/apache2/mods-available/dir.conf
能夠爲以下格式:index.html  index.cgi  index.pl  index.php index.xhtml index.htm
能夠修改成 ***.html等html

修改默認根目錄以後會報兩個錯誤web

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.158.209. Set the 'ServerName' directive globally to suppress this messageapache

以及服務器

訪問localhost:80 報 404 You don't have permission to access / on this server.dom

解決辦法:ide

第一個問題: 其實提示中已經說了讓set ServeerName,因此ui

在/etc/apache2目錄下,打開apache2.conf文件,加一句:ServerName localhost:80this

第二個問題:spa

網頁上顯示404說沒有權限訪問這個服務器

仍是apache2.conf文件,找到

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Order deny,allow
        allow from all
        #Require all denied
</Directory>

把Require all denied這一句註釋掉,加上 allow from all 最後重啓apache,發現已經正常了。

相關文章
相關標籤/搜索