配置RHEL3 下的PHP开发环境
1、### zlib ### libpng支持包### zlib-1.2.3.tar.gz ###
#tar zxvf zlib-1.2.3.tar.gz
#cd zlib-1.2.2
#./configure((注意,如以前没有安装zlib,可以不指定路径否则要指定新安装路径!))
#make
#make install
2、### OpenSSL ###openssl-0.9.7g.tar.gz###
#tar zxvf openssl-0.9.7g.tar.gz
#cd openssl-0.9.7g
#./config --prefix=/usr/local/ssl \
--openssldir=/usr/local/ssl \
#make
#make install
#ln -s /usr/local/ssl /usr/lib/ssl
##### OpenSSL ##方法二备用###
cd openssl-0.9.7g
./config --prefix=/usr/local/ssl \
--openssldir=/usr/local/ssl \
shared \
zlib
make
make install
ln -s /usr/local/ssl /usr/lib/ssl
3、### libxml #### libxml2-2.6.16.tar.gz###
安装libxml
# tar -zxvf libxml2-2.6.16.tar.gz
# cd libxml2-2.6.16
# ./configure (xml默认安装就可以,不要指定路径了,因为安装时php可能找不到它,PHP5只支持libxml2-2.5.10以上版本)
# make
# make install
4、### jpeg ### jpegsrc.v6b.tar.gz ###
安装jpeg方法一
# tar -zxvf jpegsrc.v6b.tar.gz
# cd jpeg-6b/
# ./configure --prefix=/usr/local/jpeg
# make
# make install-lib
-----------------------------------------
##### Jpeg ##方法二###
cd jpeg-6b
mkdir /usr/local/jpeg
mkdir /usr/local/jpeg/bin
mkdir /usr/local/jpeg/lib
mkdir /usr/local/jpeg/include
mkdir /usr/local/jpeg/man
mkdir /usr/local/jpeg/man/man1
./configure --prefix=/usr/local/jpeg --enable-shared
(注意:这里configure后面参数一定要带--enable-shared参数,不然,不会生成共享库)
make
make install
5、###freetype###freetype-2.1.10.tar.gz###
# tar zxvf freetype-2.1.10.tar.gz
# cd freetype-2.1.10
# ./configure --prefix=/usr/local/freetype
# make
# make install
----------------------
6、###安装libpng###libpng-1.2.8.tar.gz ###
# tar -zxf libpng-1.2.8.tar.gz
# cd libpng-1.2.8
# ./configure --prefix=/usr/local/libpng (提示找不到命令script)
# make
# make install
(注意:如果提示找不到命令script则先执行)
cp scripts/makefile.linux makefile
7、### GD Library ### gd-2.0.33.tar.gz ###
# tar -zxvf gd-2.0.33.tar.gz
#cd gd-2.0.33
#./configure --prefix=/usr/local/gd \
--with-jpeg=/usr/local/jpeg \
--with-freetype=/usr/local/freetype \
--with-png \
--with-zlib
#make
#make install
8、###libiconv###libiconv-1.10.tar.tar###
libiconv安装
# tar -zxvf libiconv-1.10.tar.tar
# cd libiconv-1.10
# ./configure --prefix=/usr/local/libiconv
# make
# make install
(将iconv.h连接到php的安装源程序中,否则会php make会出错,不知道为什么)
# cd /usr/src/php-5.1.2/ext/iconv/
# link /usr/local/libiconv/include/iconv.h iconv.h
9、### Apache ## httpd-2.0.54 ###
cd httpd-2.0.54 (php5安装环境需要apache2.0.46以上版本,下载时注意!)
#./configure --prefix=/usr/local/apache --enable-module=so
(./configure --prefix=/usr/local/apache --enable-so --enable-ssl)
#make
#make install
修改Apache配置文件/etc/httpd/conf/httpd.conf:
更改首页:
DirectoryIndex index.html index.php
找到AddType application/x-gzip .gz .tgz
加入:
AddType application/x-httpd-php .php
保存就可以了
10、#######安装MySql数据库5.0.27#######
直接安装RPM包即可。
MySQL-client-standard-5.0.27-0.rhel3.i386.rpm
MySQL-devel-standard-5.0.27-0.rhel3.i386.rpm
MySQL-server-standard-5.0.27-0.rhel3.i386.rpm
MySQL-shared-standard-5.0.27-0.rhel3.i386.rpm
[root@localhost standard-5.0.27-0.rhel3]# rpm -ivh MySQL-*
启动数据库
service mysql start
Starting MySQL SUCCESS!
service mysql status检查状态
Usage: /etc/init.d/mysql {start|stop|restart|reload} [ MySQL server options ]
登陆数据库:
mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 5.0.27-standard
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
测试
mysql> select version(); #查看版本
+-----------------+
| version() |
+-----------------+
| 5.0.27-standard |
+-----------------+
1 row in set (0.05 sec)
mysql> show databases; #查看数据库
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.02 sec)
11、###安装php5:###php-5.2.0.tar.gz###
# tar -zxvf php-5.2.0.tar.gz
# cd php-5.2.0
# ./configure \
--prefix=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-xml \
--with-mysql \
--with-freetype-dir=/usr/local/freetype \
--with-gd=/usr/local/gd \
--with-zlib \
--with-jpeg-dir=/usr/local/jpeg \
--with-png-dir=/usr/local/libpng \
--with-iconv=/usr/local/libiconv \
--with-config-file-path=/usr/local/lib \
--disable-debug \
--enable-safe-mode \
--enable-trans-sid \
--enable-memory-limit \
--enable-short-tags \
--disable-posix \
--enable-exif \
--enable-ftp \
--enable-sockets
如果出现如下证明快成功了。
+--------------------------------------------------------------------+
│License:│
│This software is subject to the PHP License, available in this│
│distribution in the file LICENSE. By continuing this installation│
│process, you are bound by the terms of this license agreement.│
│If you do not agree with the terms of this license, you must abort│
│the installation process at this point.│
+--------------------------------------------------------------------+
# make
# make install
(安装libxml的时候如果指定了路径,make的时候可能出错,所以,我安装的时候没指定!)
复制PHP.INI文件到正确位置在PHP目录下运行
#cp php.ini-dist /usr/local/php/lib/php.ini
编辑apache配置文件httpd.conf
#vi /usr/local/apache/conf/httpd.conf (注意:为安装目录下配置文件)
要改的有如下几处:
一般都在
#AddType application/x-tar .tgz
下加一行
#LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
如果你搜索其它地方没有以下这行
LoadModule php5_module modules/libphp5.so
请把上面的#号去掉
找到DirectoryIndex index.html在后面加index.php把index.php做为默认页
找到# don't use Group #-1 on these systems!
把下面的用户名和组改为
User apache
Group apache
再找#ServerName 把#去掉,后面的IP改成你的IP.
找到DocumentRoot "/usr/local/apache2/htdocs"把/usr/local/apache2/htdocs改为你存放网页文件的路径
设置中文网页无乱码
找到AddDefaultCharset iso8859-1把后面的iso8859-1改为gb2312或者是干脆off
启动apache# /usr/local/apache/bin/apachectl start
(此处不能用 service httpd restart 手工编译和RPM包安装不同。)
--------------------------------------------------------------------
##### Zend Optimizer #####
cd ZendOptimizer-2.5.10-linux-glibc21-i386
./install
Cd data
Cp ZendOptimizer.so /usr/local/lib
配置相应的php.ini目录,修改你所需的项。
测试
编辑文件index.php
<?Phpinfo();?>
放入/usr/local/apache/htdocs就可以看到php信息,说明你的配置就正确了。