配置apache结合php vim /usr/local/apache2/conf/httpd.conf 找到: AddType application/x-gzip .gz .tgz 在该行下面添加: AddType application/x-httpd-php .php 找到: <IfModule dir_module> DirectoryIndex index.html </IfModule> 将该行改为: <IfModule dir_module> DirectoryIndex index.html index.htm index.php </IfModule> 找到: #ServerName www.example.com:80 修改为: ServerName localhost:80 如果执行这条命令: [root@localhost php-5.3.28]# /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 写入: <?php echo "php解析正常"; ?> 保存后,继续测试:
curl localhost/1.php
|