配置php和apache结合,测试php
[*] 配置apache结合php
vim /usr/local/apache2/conf/httpd.conf
找到:
AddType application/x-gzip .gz .tgz
在该行下面添加:
AddType application/x-httpd-php .php
找到:
DirectoryIndex index.html
将该行改为:
DirectoryIndex index.html index.htm index.php
找到:
#ServerName www.example.com:80
修改为:
ServerName localhost:80
[*] 如果执行这条命令:
# /usr/local/apache2/bin/apachectl -t
报错:Syntax error on line 356 of /usr/local/apache2/conf/httpd.conf:
AddType requires at least two arguments, a mime type followed by one or more file extensions
原因:没有添加或格式错误AddType application/x-httpd-php .php(php .php中加一定加空格,不然报错)
[*] 测试解析php
vim /usr/local/apache2/htdocs/1.php
写入:
保存后,继续测试:
[*] curl localhost/1.php
页:
[1]