yum -y install gcc automake autoconf libtool make
yum -y install gcc gcc-c++ glibc
yum -y install libmcrypt-devel mhash-devel libxslt-devel 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
安装php
wget http://kr1.php.net/distributions/php-5.5.1.tar.gz
./configure --prefix=/usr/local/php --enable-fastcgi --enable-fpm --with-mcrypt --with-zlib --enable-mbstring --disable-pdo --with-curl --disable-debug --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-gd --with-jpeg
编译出错,提示没有libmcrypt,下载安装
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
然后再编译
继续出错
configure: error: Don't know how to define struct flock on this system, set --enable-opcache=no
同样的系统,在另一台安装没有这个错误,暂时不用opcache了
查找系统文件名
rpm -qa file
查找安装位置
rpm -ql file
启动php-fpm
[root@localhost /]# /usr/local/php/sbin/php-fpm
直接启动会出错: ERROR: failed to open configuration file '/usr/local/php/etc/php-fpm.conf': No such file or directory
解决:
[root@localhost /]# cd /usr/local/php/etc/
[root@localhost /]# cp php-fpm.conf.default php-fpm.conf
启动正常
启动nginx
[root@localhost /]# /usr/local/nginx/sbin/nginx
执行ps aux | grep php可以看到1个主进程、2个子进程,一共3个进程。
php-fpm默认使用的端口号是9000(可以在php-fpm.conf中修改:listen = 127.0.0.1:9000)
telnet 127.0.0.1 9000会发现9000这个端口确实是打开状态,至此php-fpm已经安装完成,再在/etc/rc.local中增加下面这句:
/usr/local/sbin/php-fpm
作用是让php-fpm开机自动启动。
常用操作:
重启php-fpm:kill -USR2 `ps aux | grep php-fpm | grep master | awk '{print $2}'`
这样的写法就是先用ps aux找到php-fpm的主进程的进程ID,然后发信号告诉系统重启
接下来是nginx中的设置:
找到站点的server配置段,增加如下这一段:
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;
}
}
重启nginx:
[root@localhost /]# /usr/local/nginx/sbin/nginx -s reload
共同学习,写下你的评论
评论加载中...
作者其他优质文章