十周第二次课

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

1、Apache和PHP结合

002UASMrzy7605pjKJv15&690.jpg

配置httpd支持php

•httpd主配置文件/usr/local/apache2.4/conf/httpd.conf

•vim/usr/local/apache2.4/conf/httpd.conf//修改以下4个地方

ServerName

Requirealldenied

AddTypeapplication/x-httpd-php.php

DirectoryIndexindex.htmlindex.php

•/usr/local/apache2.4/bin/apachectl-t//测试语法

•/usr/local/apache2.4/bin/apachectlstart//启动服务

•netstat-lntp

•curllocalhost

•vim/usr/local/apache2.4/htodcs/test.php//增加如下内容

<?php

echo123;

?>

•curllocalhost/test.php

配置http支持PHP http的主配置文件为/usr/local/apache2.4/conf/httpd.conf

这里需要修改配置文件中的4处,分别为:
ServerName
Requirealldenied
AddTypeapplication/x-httpd-php.php
DirectoryIndexindex.htmlindex.php

步骤:
修改ServerName

示例:运行下面的命令时出现疑似错误的东西,其实它是个警告,那么改怎么去除呢

[root@centos001~]#/usr/local/apache2.4/bin/apachectlrestart AH00558:httpd:Couldnotreliablydeterminetheserver\'sfullyqualifieddomainname,usingfe80::20c:29ff:fe34:4a63.Setthe\'ServerName\'directivegloballytosuppressthismessage

解决方法:编辑这个文件,然后重启就没有了
进入配置文件后搜索ServerName

#进入配置文件 [root@centos001~]#vim/usr/local/apache2.4/conf/httpd.conf #搜索 /ServerName

 

错误1:视屏中遇到的错误,取消掉注释后重启服务,还是有问题