Apache和PHP结合、Apache默认虚拟主机

摘要:11.14/11.15 Apache和PHP结合 httpd主配置文件/usr/local/apache2.4/conf/httpd.conf # vim /usr/local/apache2.4/conf/httpd.conf //修改以下4个地方 ServerName Require all denied修改为allow AddType application/x-httpd-php .php//增加到AddType处 Direc....

11.14/11.15Apache和PHP结合 httpd主配置文件/usr/local/apache2.4/conf/httpd.conf #vim/usr/local/apache2.4/conf/httpd.conf//修改以下4个地方

002UASMrzy7605pjKJv15&690.jpg
ServerName
Requirealldenied修改为allow
AddTypeapplication/x-httpd-php.php//增加到AddType处
DirectoryIndexindex.htmlindex.php//增加一个索引页 /usr/local/apache2.4/bin/apachectlstart//启动服务 #/usr/local/apache2.4/bin/apachectl-t//测试语法是否正确 #/usr/local/apache2.4/bin/apachectlgraceful//重新加载配置文件的命令 是否加载php5的module 4个地方是否配置了 #vim/usr/local/apache2.4/htodcs/1.php//增加如下内容

<?php phpinfo(); ?>

ctrl+r直接输入命令,可以查找历史命令 11.16/11.17Apache默认虚拟主机 一台服务器可以访问多个网站,每个网站都是一个虚拟主机 概念:域名(主机名)、DNS、解析域名、hosts 任何一个域名解析到这台机器,都可以访问的虚拟主机就是默认虚拟主机 vim/usr/local/apache2/conf/httpd.conf//搜索httpd-vhost,去掉# vim/usr/local/apache2/conf/extra/httpd-vhosts.conf//改为如下 <VirtualHost*:80> ServerAdminadmin@aminglinux.com DocumentRoot"/data/wwwroot/aming.com" ServerNameaming.com ServerAliaswww.aming.com ErrorLog"logs/aming.com-error_log" CustomLog"logs/aming.com-access_log"common </VirtualHost> <VirtualHost*:80> DocumentRoot"/data/wwwroot/www.123.com" ServerNamewww.123.com </VirtualHost> #/usr/local/apache2/bin/apachectl–t #/usr/local/apache2/bin/apachectlgraceful mkdir-p/data/wwwroot/aming.com/data/wwwroot/www.123.com echo"aming.com">/data/wwwroot/aming.com/index.html//网站默认的主页就是index.html echo"123.com">/data/wwwroot/123.com/index.html curl-x127.0.0.1:80aming.com/