|
|
Redhat9.0下 配置 Apache + MySQL + PHP
1. 下载软件:
httpd-2.0.49.tar.gz
mysql-standard-4.1.1-alpha-pc-linux-i686.tar.gz
php-4.3.7.tar.gz
把下载的三个软件包放到/usr/local目录下(个人习惯),解压
tar -xzpvf mysql-standard-4.1.1-alpha-pc-linux-i686.tar.gz
tar -xzpvf php-4.3.7.tar.gz
tar -xzpvf httpd-2.0.49.tar.gz
2. 安装MySQL
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /usr/local
shell> ln -s mysql-standard-4.1.1-alpha-pc-linux-i686 mysql
shell> cd mysql
shell> scripts/mysql_install_db
shell> chown -R root .
shell> chown -R mysql data
shell> chgrp -R mysql .
shell> bin/mysqld_safe --user=mysql &
使它自启动:
Shell>echo "/usr/local/mysql/bin/mysqld_safe &" >>/etc/rc.d/rc.local
3. 安装Apache
shell> cd httpd-2.0.49
shell> ./configure --prefix=/usr/local/httpd --enable-so
shell> make
shell> make install
使用如下命令启动Apache服务:
shell> /usr/local/httpd/bin/apachectl start
如果启动成功,将启动命令加入rc.local,使之在系统启动时自动运行:
shell> echo “/usr/local/httpd/bin/apachectl start &” >> /etc/rc.d/rc.local
停止Apache服务,并继续安装PHP:
shell> /usr/local/httpd/bin/apachectl stop
4.安装PHP
shell> cd php-4.3.7
shell>
./configure--with-apx2=/usr/local/httpd/bin/apxs--with-mysql=/usr/local/mysql
shell> make
shell>make install
cp php.ini-dist /usr/local/lib/php.ini
这种安装方式是将PHP作为Apache的SAPI模块来进行安装,它仅是其中的一种安装方式,更多的方法请参阅相关文档。
5.PHP和Apache安装后的基本配置
Apache的配置文件是/usr/local/httpd/conf/httpd.conf,编辑httpd.conf 文件,找Add Type application/x-tar .tgz 在下面添加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
同时修改DirectoryIndex为:
DirectoryIndex index.html index.htm index.php index.php3
PHP的配置文件是/usr/local/lib/php.ini,编辑php.ini文件来配置PHP的选项。特别注意的是,安装完成后register_globals变量默认设置为Off,需要将它改成On。否则会出现PHP读不到post的数据的现象。 |
|