Home > php教程 > php手册 > PHP教程:Linux下PHP服务器的安装与配置

PHP教程:Linux下PHP服务器的安装与配置

WBOY
Release: 2016-06-21 09:00:35
Original
987 people have browsed it

1、#cp httpd-2.0.47.tar.gz 到/usr/local/
2、#tar zxvf php-4.3.3.tar.gz
3、#cd php-4.3.3
4、#./configure --with-mysql --with-apxs2=/usr/local/apache/bin/apxs
   #./configure -with-apache=/path/to/apache/dir -with-mysql=/usr/local/mysql
5、#make
6、#make install  (一边等待一边保佑吧)
7 、#cp php.ini-dist /usr/local/lib/php.ini
8 、#vi /usr/local/apache2/conf/httpd.conf
9 、在AddType application/x-tar.tgz下面,添加以下内容:
AddType application/x-httpd-php .php
LoadModule php4_module /var/www/modules/libphp4.so (如果没有的话加上)
10 、#vi /usr/local/apache2/htdocs/test.php

echo phpinfo();
?>
11 、浏览http://ip/test.php。出现php信息。恭喜这一步成功了。

PHP和Apache安装后的基本配置
1.Apache的配置
Apache的配置文件是/usr/local/apache2/conf/httpd.conf,编辑httpd.conf 文件,在文件结尾加上以下两行:
LoadModule php4_module modules/libphp4.so
AddType application/x-httpd-php .php .php3
同时修改DirectoryIndex为:

DirectoryIndex index.htm
DirectoryIndex index.html
DirectoryIndex index.php
DirectoryIndex index.php3
DirectoryIndex index.php4

Apache的配置内容比较丰富,其它Apache相关配置请参考Apache的相关文档。
2.PHP的配置
Apache的配置文件是/usr/local/lib/php.ini,编辑php.ini文件来配置PHP的选项。特别注意的是,安装完成后register_globals变量默认设置为Off,需要将它改成On。否则会出现PHP读不到post的数据的现象。
zlib.output_compression=On
register_globals=On
其它PHP的选项请参考相关文档。
3.测试
可以写一个简单的PHP文件来测试安装,文件包含下列一行:
将其保存为/usr/local/apache2/htdocs/info.php,启动Apache,然后在浏览器中浏览。



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template