Linux
下
Apache2
+
php5
+MySQL
的整合
1、安装软件版本
软件
|
安装文件
|
安装目录
|
APACHE
|
httpd-2.2.6.tar.gz
|
/usr/local/apache2
|
PHP
|
php-5.2.5.tar.gz
|
/usr/local/php
|
MYSQL
|
mysql-5.0.45-linux-i686.tar.gz
|
/usr/local/mysql
|
2、安装
APAHCE2
(
HTTP
)
# tar –zxvf
httpd-2.2.6.tar.gz
# cd httpd-2.2.6
# ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-module-so --enable-ssl
# make
# make install
# cd httpd-2.2.6
# ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-module-so --enable-ssl
# make
# make install
编译安装完成后,启动apache ,测试一下是否安装成功。
# cd /usr/local/apache2/bin
# ./apachectl start //如果没有报错,就说明安装成功。
# ./apachectl start //如果没有报错,就说明安装成功。
3、安装
PHP
# tar -zxvf
php-5.2.5.tar.gz
# cd php-5.2.5
#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/lib --enable-track-vars --with-xml
# make //编译装载的文件
# cd php-5.2.5
#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/lib --enable-track-vars --with-xml
# make //编译装载的文件
# make test
//查 看一下是否安装成功。
# make install //安装编译好的文件
# make install //安装编译好的文件
注:
·
apache
和
mysql
是根据你安装的目录名变,如:
apache
为
/usr/local/apache2/bin/apxs
、
MySQL
为
=/usr/local/mysql
;
·
enable-track-vars
表示为启动
cookie
的
get/post
等追踪功
能
4、配置
APACHE
安装完成后,修改apache的配置文件httpd.conf,在相应的位置做以下的修改:
· 将ServerAdmin
mailto:linux@linuxidc.com
一行改为您的邮箱地址
· 将DocumentRoot "/usr/local/apache2/htdocs"
此处为html文件主目录
· 将Options Indexes FollowSymLinks MultiViews
中的"Indexes"去掉,Indexes是为了列出访问地址下所有的文件,包括Html、JSP、PHP、CSS、Image等等。
· 设置apache的默认文件名次序,DirectoryIndex index.php index.htm default.php default.phtml default.php3 default.html default.htm
· 在Addtype中加入这两句:
AddType application/x-httpd-php .php .php3
AddType application/x-httpd-php-source .phps
重启apache即可。
5、测试
PHP
编写 info.php文件,内容如下:
<?php phpinfo(); ?>
//显示PHP的所有信息
将其存放在刚才设置的apache的文档路径下,在浏览器中输入:
http://127.0.0.1/info.php,即可看到php 的配置信息。如果报错,请先查看该文件的权限设置,如果不行则查看日志。
6、
设置
APACHE
的开机自动启动
:
# cd /etc/rc.d/init.d
# ln -s /usr/local/apache/bin/apachectl httpd
# chmod 700 httpd
# vi httpd
# ln -s /usr/local/apache/bin/apachectl httpd
# chmod 700 httpd
# vi httpd
键入"i"进入插入状态,把文件头的部分的chkconfig 和 description修改成如下所示:
# chkconfig: 2345 10 90
# description: Activates/Deactivates Apache Web Server
# description: Activates/Deactivates Apache Web Server
键入":"进入命令行状态,输入"wq"(存盘退出命令)。
最后,运行chkconfig把Apache添加到系统的启动服务组里面。
# /sbin/chkconfig --del httpd
# /sbin/chkconfig --add httpd
# /sbin/chkconfig --add httpd
注:在
Linux
下安装
PHP或者执行开启Apache程序时可能会发生如下错误
cannot restore segment prot after reloc: Permission deni
ed
该问题是由于
SELinux
的权限控制,解决办法有两个
1、
使用
chcon
命令
chcon -t
texrel_shlib_t
文件的地址
示例
: chcon -t texrel_shlib_t /usr/local/rsi/idl_6.1/bin/bin.linux.x86/*.so
2
、
禁止掉
SELinux
更改
/etc/sysconfig/selinux
文件的内容为
SELINUX=disabled
//
好象没有成功。
关于
SELinux
具体情况可能参考: