# tar -jxvf gd-2.0.35.tar.bz2
# cd gd-2.0.35
# ./configure --prefix=/usr/local/www/gd --with-png --with-freetype --with-jpeg --with-zlib --with-fontconfig
# make
#如果GD报错:configure.ac:64: warning: macro `AM_ICONV' not found in library
你就make clean一下,然后再make
# make install
# tar -jxvf httpd-2.2.14.tar.bz2
# cd httpd-2.2.14
# cd srclib/apr
# ./configure --prefix=/usr/local/www/apr --enable-threads --enable-other-child --enable-static
# make && make install
# cd ../apr-util
# ./configure --prefix=/usr/local/www/apr-util --with-apr=/usr/local/www/apr
# make && make install
# cd ../..
# ./configure --prefix=/usr/local/www/apache --enable-so --enable-rewrite --with-apr=/usr/local/www/apr --with-apr-util=/usr/local/www/apr-util
# make
# make install
然后 vi /etc/rc.d/init.d/httpd 添加(#!/bin/sh下面)
# chkconfig: 2345 10 90
# description: Activates/Deactivates Apache Web Server
最后,运行chkconfig把Apache添加到系统的启动服务组里面:
# chkconfig --add httpd
# chkconfig httpd on
五、安装PHP
# tar -jxvf php-5.2.12.tar.bz2
# cd php-5.2.12
# ./configure --prefix=/usr/local/www/php --with-apxs2=/usr/local/www/apache/bin/apxs --with-mysql=/usr/local/www/mysql --with-gd=/usr/local/www/gd --with-config-file-path=/usr/local/www/php --enable-mbstring=all --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --with-zlib --enable-sockets --enable-soap --enable-exif --with-zlib-dir--with-bz2 --with-libxml-dir
# make
# make install
# cp php.ini-dist /usr/local/www/php/php.ini
整合apache与php
# vi /usr/local/www/apache/conf/httpd.conf
找到AddType application/x-gzip .gz .tgz在其下加以下内容
AddType application/x-httpd-php .php
查找:(设置WEB默认文件)
DirectoryIndex index.html
改成:
DirectoryIndex index.php index.html index.htm
保存退出
service httpd restart
然后在目录中建一个文件用来测试php情况
在htdocs目录下建一个测试页
vi index.php
<?php
phpinfo();
?>
保存退出
重启apache
六、安装PHP扩展
1、安装eaccelerator加速软件
eaccelerator是php的加速软件,使用后php的执行效率会有很大幅度的提升。
# tar jxvf eaccelerator-0.9.5.3.tar.bz2
# cd eaccelerator-0.9.5.3
# /usr/local/www/php/bin/phpize
# ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/www/php/bin/php-config
# make
# make install
# tar -zxvf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
# cp ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp/ZendOptimizer.so /usr/local/www/php/lib/php/extensions/no-debug-non-zts-20060613/
# vi /usr/local/www/php/php.ini
[Zend Optimizer]
zend_optimizer.optimization_level=1
zend_optimizer.encoder_loader=0
zend_extension="/usr/local/www/php/lib/php/extensions/no-debug-non-zts-20060613/ZendOptimizer.so"
在浏览器中打开phpinfo()那个测试页,如果出现以下内容,证明安装成功!
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
with eAccelerator v0.9.5.3, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies
3、安装PDO_MYSQL
# tar zxvf PDO_MYSQL-1.0.2.tgz
# cd PDO_MYSQL-1.0.2/
# /usr/local/www/php/bin/phpize
# ./configure --with-php-config=/usr/local/www/php/bin/php-config --with-pdo-mysql=/usr/local/www/mysql
# make
# make install
# vi /usr/local/www/php/php.ini
添加
extension_dir = "/usr/local/www/php/lib/php/extensions/no-debug-non-zts-20060613/"
extension="pdo_mysql.so"
#tar zxvf pcre-8.0.tar.gz
#cd pcre-8.0
#./configure
#make && make install
4、安装nginx
# tar zxvf nginx-0.7.64.tar.gz
# cd nginx-0.7.64
# ./configure --with-http_stub_status_module --with-google_perftools_module --prefix=/usr/local/www/nginx --user=www --group=www
# make && make install
修改nginx的配置文件
我这里是把原先的重命名然后新建了一个nginx.conf
---------------------------------------------------
user www;
worker_processes 8;
pid logs/nginx.pid;
google_perftools_profiles /var/tmp/tcmalloc;
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
}
http{
include mime.types;
default_type application/octet-stream;
#!/bin/bash
# Startup script for the nginx Web Server
# chkconfig: - 85 15
# description: nginx is a World Wide Web server. It is used to serve
# HTML files and CGI.
# processname: nginx
# pidfile: /usr/local/www/nginx/logs/nginx.pid
# config: /usr/local/www/nginx/conf/nginx.conf
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
NGINX_HOME=/usr/local/www/nginx/sbin
NGINX_CONF=/usr/local/www/nginx/conf
if [ ! -f "$NGINX_HOME/nginx" ]
then
echo "nginxserver startup: cannot start"
exit
fi
case "$1" in
'start')
$NGINX_HOME/nginx -c $NGINX_CONF/nginx.conf
echo "nginx start successful"
;;
'stop')
killall -TERM nginx
;;
esac