首页 > 系统 > Linux > 正文

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

2020-02-06 17:20:03
字体:
来源:转载
供稿:网友

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,然后在浏览器中浏览。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表