- 安装gcc编译器
yum -y install gcc yum -y install gcc-c++ yum -y install make automake
- 创建用户
useradd www
- 安装 nginx
安装依赖的库
yum -y install pcre-devel openssl openssl-devel
下载nginx
wget http://nginx.org/download/nginx-1.0.6.tar.gz tar -xvf nginx-1.0.6.tar.gz ./configure --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_perl_module make && make install
注:若make出现如下错误:
Can’t locate ExtUtils/Embed.pm in @INC (@INC contains: /usr/lib/perl5/5.10.0/i386-linux-thread-multi /usr/lib/perl5/5.10.0 /usr/local/lib/perl5/site_perl/5.10.0/i386-linux-thread-multi /usr/local/lib/perl5/site_perl/5.10.0 /usr/lib/perl5/vendor_perl/5.10.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.10.0 /usr/lib/perl5/vendor_perl /usr/local/lib/perl5/site_perl .)
yum -y install perl-devel perl-ExtUtils-Embed
- 安装 mysql
下载地址
wget http://mysql.mirrors.hoobly.com/Downloads/MySQL-5.5/mysql-5.5.15-linux2.6-i686.tar.gz
具体安装配置参看 mysql安装指南。
- 安装php
安装依赖的库
yum -y install libxml2-devel yum -y install libcurl libcurl-devel yum -y install libxslt libxslt-devel yum -y install libjpeg-6b libjpeg-devel-6b yum -y install libpng libpng-devel yum -y install freetype freetype-devel
注意:libjpeg 可能后面的centos 版本名字有变化,可以使用yum search libjpeg 查询
手动安装libmcrypt
wget http://ncu.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz tar -xvf libmcrypt-2.5.8.tar.gz ./configure && make && make install
下载php源文件
wget http://www.php.net/distributions/php-5.3.8.tar.gz
编译安装php
./configure --enable-fpm --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-config-file-path=/etc --with-openssl=/usr --with-curl --with-libxml-dir --enable-soap --with-xsl --with-gd --with-jpeg-dir --with-zlib-dir --with-freetype-dir --with-png-dir --enable-mbstring --with-iconv --enable-magic-quotes --enable-inline-optimization --enable-ftp --enable-fastcgi -with-mcrypt --enable-force-cgi-redirect --enable-short-tags --disable-debug --with-mysqli=/usr/local/mysql/bin/mysql_config make && make install
注意:如果是64位系统,可能会出现“Cannot find OpenSSL’s libraries”,解决办法是做一个软链接:ln -s /usr/lib64/libssl.so /usr/lib/
安装后 copy php.ini-production 到 /ect/php.ini
php-fpm的配置文件
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
修改fpm主配置文件,将运行的用户和组改为www, 去掉前面的;
vi /usr/local/php/etc/php-fpm.conf user = www group = www pm.start_servers = 20 pm.min_spare_servers pm.max_spare_servers
启动php-fpm
/usr/local/php/sbin/php-fpm
修改nginx.conf的配置,修改 fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
中的/scripts为自己php的根目录,例如 fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/$fastcgi_script_name;
启动 nginx
/usr/local/nginx/sbin/nginx
或者重启nginx
kill -HUP `cat /usr/local/nginx/logs/nginx.pid` 或 /usr/local/nginx/sbin/nginx -s reload