{"title": "CentOS\u4e0b\u7f16\u8bd1\u5b89\u88c5nginx+php", "update_time": "2013-10-20 20:28:10", "tags": "centos nginx php", "pid": "228", "icon": "linux.png"}
本文说明在CentOS 5下如何编译安装nginx。nginx版本8.55 ,php版本5.3.21 1.安装相关的软件包 ``` yum install -y gcc autoconf curl freetype gd jpegsrc libiconv libmcrypt libpng yum install -y libxml2 mhash ncurses openssl openssl-devel pcre-devel zlib-devel yum install libmcrypt-devel yum install -y curl-devel ``` 2.下载nginx ``` wget http://nginx.org/download/nginx-0.8.55.tar.gz tar -xzvf nginx-0.8.55.tar.gz cd nginx-0.8.55 ``` 3.添加ngix账号 ``` useradd -s /bin/false nginx ``` 4.编译安装nginx ``` ./configure --prefix=/opt/nginx-0.8.55 \ --with-http_stub_status_module \ --with-http_gzip_static_module make make install cd /opt && ln -sf nginx-0.8.55 nginx && cd - ``` 5.下载安装php 5.3.21 ``` wget http://www.php.net/get/php-5.3.21.tar.bz2/from/cn2.php.net/mirror tar -xjvf php-5.3.21.tar.bz2 cd php-5.3.21 ``` 6.编译php 编辑configure文件,在第60335行后,添加如下行,否则configure出错(这个应该是configure脚本的bug, 在安装了64位的mysql后,MYSQL_LIB_DIR却被错误地指到了/usr/lib/mysql) MYSQL_LIB_DIR='/usr/lib64/mysql' 接下来编译安装。 ``` ./configure --prefix=/opt/php-5.3.21 \ --with-config-file-path=/opt/php-5.3.21/etc \ --enable-fpm --with-fpm-user=nginx \ --with-fpm-group=nginx \ --with-zlib \ --with-libxml-dir \ --with-curl \ --with-xmlrpc \ --with-openssl \ --with-mhash \ --with-mcrypt \ --with-pear \ --enable-mbstring \ --enable-sysvshm \ --enable-zip \ --with-mysql \ --with-mysql-sock \ --with-pgsql=/opt/postgresql \ --with-pdo-mysql ``` 其中一些参数可以根据实际情况调整。如我编译安装了postgresql,我需要加入postgresql的php库的支持,就加上了--with-pgsql=/opt/postgresql, 而我的mysql是用系统yum安装的,则直接加上--with-mysq即可。 好了,整个编译安装过程到此结束。