httpd主配置:/usr/local/httpd/conf/httpd.conf;php
檢查配置是否有語法錯誤:/usr/local/httpd/bin/apachectl -thtml
從新加載配置文件:/usr/local/httpd/bin/apachectl graceful #不重啓服務,只從新加載配置,配置有誤加載不成功apache
配置中修改的地方:vim
1.搜「ServerName」,將「#ServerName www.example.com:80」的#號去掉。可解決命令啓動時報的警告「AH00558:httpd:could not reliably determine the server's fully qualified domain name .....」瀏覽器
#2.搜「Require」,注意搜出來上一行是「AllowOverride none」;將「Require all denied」的denied改爲granted。防止禁止訪問。服務器
3.搜「AddType」,增長一行「AddType application/x-httpd-php .php」;解析php;若不加此行,後續在/usr/local/httpd/htdocs/添加php文件時,界面直接顯示php文件的代碼。app
4.搜「DirectoryIndex」,在「DirectoryIndex index.html」後增長 「index.php」;增長一行增長索引頁dom
1. cd /usr/local/httpd/htdocs/curl
2. vim 1.php #打印PHP相關信息ide
<?php
phpinfo();
?>
3. 瀏覽器訪問: ip:端口/1.php
一臺服務器可訪問多個網站,每一個網站都是一個虛擬主機
概念:域名(主機名);DNS;解析域名;hosts
任何一個域名解析到這臺服務器,均可以訪問的虛擬主機就是默認虛擬主機
/usr/local/httpd/conf/httpd.conf 搜索httpd-vhost;去掉前面#;便可定義多個servername
/usr/local/httpd/conf/extra/httpd-vhosts.conf
ServerAdmin 定義管理員郵箱,可刪除
DocumentRoot 定義網站根目錄,可修改
ServerName 定義servername,可修改
ServerAlias 定義別名,可修改
ErrorLog 指定錯誤日誌,可修改
CustomLog 指定訪問日誌,可修改
到對應網站根目錄下建立index.php文件
並從新加載配置
使用curl命令測試