最近在學習php,新手的我遇到各種各樣的問題,將問題和解決方案一一列出來,希望能幫到大家。我沒有用WAMPServer整合安裝包,而是單獨安裝apache2.4+php7.1.9+mysql5.5(曆史遺留)。按照網上的教程安裝好後配置httpd.conf,成功跑起第一個頁面。由於apache預設的項目根目錄是htdocs,感覺不是很方便,於是想配置多跟根目錄,那麼問題來了。由於以前沒接觸過apache和php,首先遇到的問題是配置Directory時遇到了問題:
<Directory "E:/phpworkspace"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all</Directory>
重啟的時候報錯了:Invalid command '\xa1\xa1\xa1\xa1Order', perhaps misspelled or defined by a module not included in the server configuration
解決方案:
所以這裡要注意在Apache2.4的安裝中,如果要在檔案中添加授權所有許可權的命令,要使用:
Require all granted
而不是:
Order allow,deny
Allow from all
同意的道理,如果是禁止所有許可權要使用:
Require all denied
而不是:
Order deny,allow
Deny from all
問題:
上圖中標記的DocumentRoot看起來是一樣的,但是使用注釋的那行卻報錯:
Invalid command'\xa1\xa1\xa1\xa1ServerName',perhaps misspelled or defined by a module not included in the server configuration
解決辦法:檢查是不是使用了全形字元。哈哈…哈哈…哈……