一、软件环境
CentOS 5.4 :
Nginx 0.8 :
PHP 5.2.10 :
MySQL 5.4.15 : http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.45.tar.gz/from/http://mysql.ntu.edu.tw/
二、安装
1. 准备工作
这一步我称它为“准备工作”,其实是安装一些系统编译及其他环境
yum -y install patch make gcc gcc-c++ gcc-g77 flex bison libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel
#安装编码格式转换库
wget
tar -zxvf libiconv-1.13.tar.gz
cd libiconv-1.13
./configure --prefix=/usr/local
make && make install
cd ..
#安装libmcrypt库
wget
tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make && make install
ldconfig
cd libltdl
./configure --enable-ltdl-install
make && make install
cd ../../
#安装php-mhash扩展库
wget
tar -zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure
make && make install
cd ..
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
wget
tar -zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
./configure
make && make install
cd ..
2. 安装MySQL
tar -zxvf mysql-5.1.54.tar.gz
cd mysql-5.1.54
./configure --prefix=/usr/local/mysql --enable-assembler --with-charset=utf8 --enable-thread-safe-client --with-extra-charsets=all --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile
make && make install
cd ..
#添加mysql用户和用户组
groupadd mysql
useradd -g mysql mysql
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
/usr/local/mysql/bin/mysql_install_db --user=mysql
chown -R mysql /usr/local/mysql/var
chgrp -R mysql /usr/local/mysql/.
#设置mysql开机自启动
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
chkconfig --level 345 mysql on
#增加mysql动态链接库文件
echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
echo "/usr/local/lib" >>/etc/ld.so.conf
ldconfig
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
#添加root密码
/etc/init.d/mysql start
/usr/local/mysql/bin/mysqladmin -u root password root
/etc/init.d/mysql restart
/etc/init.d/mysql stop
#去掉mysql集群服务
chkconfig mysql-ndb off
chkconfig mysql-ndb-mgm off
3. 安装PHP
#我们用php-fpm来管理fastcgi
wget
tar -zxvf php-5.2.10.tar.gz
gzip -cd php-5.2.10-fpm-0.5.11.diff.gz | patch -d php-5.2.10 -p1
! 这里我们要先将autoconf降低版本,否则可能会出现: buildconf: Your version of autoconf likely contains buggy cache code.
yum -y install autoconf213
export PHP_AUTOCONF=/usr/bin/autoconf2.13
cd php-5.2.10
./buildconf --force
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --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 --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-ftp --without-pear
make ZEND_EXTRA_LIBS='-libiconv'
make install
cp php.ini-dist /usr/local/php/etc/
4. 安装nginx
#安装pcre (Perl Compatible Regular Expressions正则表达式库)
wget
tar -zxvf pcre-7.9.tar.gz
cd pcre-7.9
./configure
make && make install
cd ..
tar -zxvf nginx-0.8.35.tar.gz
cd nginx-0.8.35
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
#有关nginx.conf和php-fpm.conf的配置可以参照:nginx.conf 和 php-fpm.conf
5. 测试
我们先来写一个脚本
vi /etc/init.d/run
写入以下内容
ulimit -SHn 51200
/usr/local/php/sbin/php-fpm start
/usr/local/nginx/sbin/nginx
启动测试:
chown 0755 /etc/init.d/run
/etc/init.d/run
/etc/init.d/mysql start
好了,在/var/www/localhost下写个phpinfo测试下吧!
阅读(343) | 评论(0) | 转发(1) |