二、安装PHP 5.2.6(FastCGI模式) 1、编译安装PHP 5.2.6所需的支持库:
tar zxvf libiconv-1.12.tar.gz
cd libiconv-1.12/
./configure --prefix=/usr/local/
make
make install
cd ../
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../
tar zxvf mhash-0.9.9.tar.gz
cd mhash-0.9.9/
./configure
make
make install
cd ../
cp /usr/local/lib/libmcrypt.* /usr/lib
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
tar zxvf mcrypt-2.6.7.tar.gz
cd mcrypt-2.6.7/
./configure
make
make install
cd ../
-----------------------------------------------------------------
2、编译安装MySQL 5.1.56
useradd -g mysql
./configure --with-mysqld-user=mysql --prefix=/usr/local/webserver/mysql5 --with-charset=gbk --with-extra-charset=all --without-isam --exec-prefix=/usr/local/webserver/mysql5 --with-unix-socket-path=/usr/local/webserver/mysql5/var/mysql.sock
make;make install
/usr/local/webserver/mysql5/bin/mysql_install_db --user=mysql
cp /usr/local/webserver/mysql5/share/mysql/my-medium.cnf /usr/local/webserver/mysql5/var/my.cnf
cp /usr/local/webserver/mysql5/share/mysql/mysql.server /etc/init.d/mysqld
chmod 700 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
chown mysql:mysql -R /usr/local/webserver/mysql5/
vi /usr/local/webserver/mysql5/var/my.cnf
# 添加 max_connections=1000
service mysqld start
ln -s /usr/local/webserver/mysql5/bin/mysql_config /usr/bin/mysql_config
ln -s /usr/local/webserver/mysql5/bin/mysql /sbin/mysql
ln -s /usr/local/webserver/mysql5/bin/mysqladmin /sbin/mysqladmin
#配置库文件搜索路径
echo "/usr/local/webserver/mysql5/lib/mysql" >> /etc/ld.so.conf
ldconfig -v
#添加/usr/local/mysql/bin到环境变量PATH中
export PATH=$PATH:/usr/local/webserver/mysql5/bin
-----------------------------------------------------------------
3、编译安装PHP(FastCGI模式)
yum install openldap-devel
tar zxvf php-5.3.0.tar.gz
gzip -cd /mnt1/php-5.3.0-fpm-0.5.12.diff.gz | patch -d php-5.3.0 -p1
cd php-5.2.6/
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-liconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-debug --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl
sed -i 's#-lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt#& -liconv#' Makefile
make
make install
cp php.ini-dist /usr/local/webserver/php/etc/php.ini
cd ../
tar jxvf eaccelerator-0.9.6.tar.bz2
/usr/local/webserver/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-pdo-mysql=/usr/local/webserver/mysql
make
make install
cd ../
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
make
make install
cd ../
tar zxvf imagick-2.2.2.tgz
cd imagick-2.2.2/
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
cd ../
----------------------------------------------------------------
若看到相关的php信息页面,则证明php也配置成功!!
4、编译安装PHP5扩展模块
tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5/
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
cd ../
----------------------------------------------------------------
5、修改php.ini文件
手工修改:查找/usr/local/webserver/php/etc/php.ini中的extension_dir = "./"
修改为extension_dir = extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/
并在此行后增加以下几行,然后保存:
extension = "memcache.so"
extension = "pdo_mysql.so"
extension = "imagick.so"
再查找output_buffering = Off
修改为output_buffering = On
-----------------------------------------------------------------
6、配置eAccelerator加速PHP:
mkdir -p /usr/local/webserver/eaccelerator_cache
vi /usr/local/webserver/php/etc/php.ini
4、创建Nginx配置文件
在/usr/local/webserver/nginx/conf/目录中创建nginx.conf文件:
rm -f /usr/local/webserver/nginx/conf/nginx.conf
vi /usr/local/webserver/nginx/conf/nginx.conf
user www www;
worker_processes 8;
error_log /usr/local/webserver/nginx/logs/nginx_error.log crit;
pid /usr/local/webserver/nginx/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 65535;
events
{
use epoll;
worker_connections 65535;
}
http
{
include mime.types;
default_type application/octet-stream;
#charset gb2312;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
#以下两个选项用于防止网络阻塞
tcp_nopush on;
tcp_nodelay on;