注意:已经有更好的安装方法,适用于CentOS、ubuntu等Linux系统。
安装新方法
http://blog.csdn.net/yankai0219/article/details/8001210 欢迎大家参考
文章内容 一、安装所需要的程序、库 1.检查系统中是否有以下程序库 2.编译php所需的支持库 3、编译安装MySQL 5.5.3-m3 4、编译安装PHP(FastCGI模式) 5、编译安装PHP5扩展模块 二、配置php、php-fpm、nginx 1、修改php.ini文件 2、配置eAccelerator加速PHP 3、创建php-fpm配置文件 4、启动php-fpm 三、安装Nginx 1.2.3 1、确认有PCRE库 2、安装Nginx 3、创建Nginx日志目录 4、创建Nginx配置文件 5、启动Nginx 四、测试Nginx对PHP的解析功能 |
我所安装的系统:CentOS-6.2-i386-bin-DVD中的desktop系统
以下教程不算完整,其中mysql并不能成功编译到php中,但是此教程与http://blog.s135.com/nginx_php_v6/相比,有所完善,当然也有所不足,还请指正。
注意事项:
1.一 检测系统中是否含有程序库,不要一口气利用yum -s install进行安装,如果进行此操作,那么yum and rpm再之后就不能使用,如果使用会提示 段错误。
2. make make install 两句话可以合二为一 即:make && make install
3.编译mysql时,采用mysql-5.5.5-m3.tar.gz,不要采用mysql-5.5.3-m3.tar.gz,因为有错误mysql-5.5.3-m3.tar.gz
4.教程中出现的灰色字体内容,读者自行添加,不影响Nginx+PHP的使用。
1.检查系统中是否有以下程序库
4、编译安装PHP(FastCGI模式)
gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-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 openldap openldap-devel nss_ldap openldap-clients openldap-servers |
其中
红色字体:表示没有安装
粗体:表示我的系统中没有这些,需要通过
yum install curl-devel e2fsprogs-devel openldap-servers |
注意:xxx与xxx-devel尽量版本一致。比如libjpeg-6b-46.el6.i686 和libjpeg-devel-6b-46.el6.i686
2.编译php所需的支持库
我将下面所需的tar.gz文件都下载到/home/username/download/文件夹下
技巧:可以将make与make install两条命令二合一 make && make install
tar zxvf libiconv-1.13.1.tar.gz cd libiconv-1.13.1/ ./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.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 ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config tar zxvf mcrypt-2.6.8.tar.gz cd mcrypt-2.6.8/ /sbin/ldconfig ./configure make make install cd ../ |
到此位置,关机系统备份一次
3、编译安装MySQL 5.5.3-m3
采用mysql-5.5.5-m3.tar.gz,不要采用5.5.3,因为该版本有错误
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
tar zxvf mysql-5.5.5-m3.tar.gz
cd mysql-5.5.5-m3/
./configure --prefix=/usr/local/webserver/mysql/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase,myisammrg
make && make install
chmod +w /usr/local/webserver/mysql
chown -R mysql:mysql /usr/local/webserver/mysql
cd ../
/usr/sbin/useradd -g mysql mysql
tar zxvf mysql-5.5.5-m3.tar.gz
cd mysql-5.5.5-m3/
./configure --prefix=/usr/local/webserver/mysql/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase,myisammrg
make && make install
chmod +w /usr/local/webserver/mysql
chown -R mysql:mysql /usr/local/webserver/mysql
cd ../
4、编译安装PHP(FastCGI模式)
注意1:本想尝试高版本php,但是没有相应的diff.gz,因此只能采用该版本
注意2:由于不能解决MySQL的问题,因此configure时去掉mysql部分,即去掉红色部分
tar zxvf php-5.2.14.tar.gz
gzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.2.14 -p1
cd php-5.2.14/
./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-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-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap
make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-dist /usr/local/webserver/php/etc/php.ini
cd ../
编译后出现错误
gzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.2.14 -p1
cd php-5.2.14/
./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-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-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap
make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-dist /usr/local/webserver/php/etc/php.ini
cd ../
在编译php对mysqli的支持的时候出现了如下错误:
checking whether to enable embedded MySQLi support… no
checking for mysql_set_server_option in -lmysqlclient… no