本文使用软件版本:
Nginx: nginx-1.0.5
MySQL: mysql-5.0.40
PHP : php-5.2.10
libmcrypt: libmcrypt-2.5.7
mhash ; mhash-0.8.15
mcrypt: mcrypt-2.6.8
其他rpm软件使用CentOS5.5自带rpm包
Nginx:
下载
- # wget http://nginx.org/download/nginx-1.0.5.tar.gz
安装:
安装依赖:
- # yum -y install zlib-devel pcre-devel openssl-devel
编译安装:
- # ./configure --prefix=/usr/local/nginx\
- --with-openssl=/usr/include/openssl\ #启用ssl
- --with-pcre\ #启用正规表达式)
- --with-http_stub_status_module #安装可以查看nginx状态的程序
- # make && make install
Nginx的启动,停止
- # /usr/local/nginx/sbin/nginx 启动nginx
- # kill –HUP `cat /usr/local/nginx/logs/nginx.pid` 重新启动
- # kill -9 `cat /usr/local/nginx/logs/nginx.pid` 停止nginx
Mysql:
安装依赖
- # yum –y install ncurses-devel
安装:
- # useradd –M –s /sbin/nologin mysql
- # tar –zxvf mysql-5.0.40
- # ./configure --prefix=/usr/local/mysql --with-ssl --with-readline --with-big-tables --enable-assembler
- # make && make install
- # cp support-files/mymedium.cnf /etc/my.cnf
- # cp support-files/mysql.server /etc/init.d/mysqld
- # chmod +x /etc/init.d/mysqld
- # cd /usr/local/mysql
- # bin/mysql_install_db –user=mysql
- # chown –R root.mysql ./
- # chown –R mysql var/
- # ln –sf /usr/local/mysql/bin/mysql /usr/bin
- # echo ‘/usr/local/msyql/lib/mysql’ >> /etc/ld.so.conf
- # ldconfig
- # for b in `ls /usr/local/mysql/include/mysql/`:
- > do
- > ln –s /usr/local/mysql/include/mysql/”$b” /usr/include/”$b”
- > done
PHP:
安装rpm依赖:
- # yum –y install libxml2-devel curl-devel libpng-devel openldap-devel
安装源码包依赖:
- # wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
- # tar –zxvf libmcrypt-2.5.7.tar.gz
- # cd libmcrypt-2.5.7
- # ./configure
- # make && make install
- # ldconfig
- # wget http://downloads.sourceforge.net/project/mhash/mhash/0.8.15/mhash-0.8.15.tar.gz?r=
- &ts=1312522467&use_mirror=cdnetworks-kr-1
- # tar –zxvf mhash-0.8.15.tar.gz
- # cd mhash-0.8.15
- # ./configure
- # make &&make install
为了一下能正常安装,为上面装的两个软件的lib建立软连接
- # for b in `ls /usr/local/lib/libmcrypt.*`:
- > do
- > file=`echo “$b” | awk –F/ ‘{print $5}’`
- > ln –s “$b” /usr/lib/”$file”
- >done
- # for b in `ls /usr/local/lib/libmhash.*`:
- > do
- > file=`echo “$b” | awk –F/ ‘{print $5}’`
- > ln –s “$b” /usr/lib/”$file”
- > done
- # wget http://cdnetworks-kr-1.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.
- tar.gz
- # tar –zxvf mcrypt-2.6.8.tar.gz
- # cd mcrypt-2.6.8
- # ./configure
- # make && make install
安装FPM补丁
下载:
- # wget http://php-fpm.org/downloads/php-5.2.10-fpm-0.5.11.diff.gz
打补丁
- # gzip -d php-5.2.10-fpm-0.5.11.diff.gz
- # cd php-5.2.10
- # patch -p1 < ../php-5.2.10-fpm-0.5.11.diff
编译安装PHP:
- # tar -zxvf php-5.2.10.tar.bz2
- # cd php-5.2.10
- # ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql/ --with-zlib --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --with-curl --with-curlwrappers --enable-fpm --enable-fastcgi --with-mcrypt --with-gd --with-openssl --with-mhash --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc -enable-zip --enable-soap
- # make && make install
为PHP创建配置文件并启动php-cgi:
- # cp php.ini-dist /usr/local/php/php.ini
- # ln –s /usr/local/php/bin/php /usr/bin/php
- # vi /usr/local/php/etc/php-fpm.conf # 去掉64 和66行的注释,使用nobody用户启动
- 63 <value name="user">nobody</value>
64
65 Unix group of processes
66 <value name="group">nobody</value>- # /usr/local/php/sbin/php-fpm start # 启动phpcgi默认绑定本地端口127.0.0.1:9000
然后修改nginx.conf:
- # vi /usr/local/nginx/conf/nginx.conf
- 在server{
- ….
- }
- 里添加
- location ~ \.php$ {
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
- include fastcgi_params;
- include fastcgi.conf;
- }
重启nginx