基础依赖库的安装
yum -y install gcc automake autoconf libtool make yum -y install gcc gcc-c++ glibc yum -y install libmcrypt-devel mhash-devel libxslt-devel yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel yum -y install zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel yum -y install ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel yum -y install krb5 krb5-devel libidn libidn-devel openssl openssl-devel
php 安装
wget http://cn2.php.net/distributions/php-5.6.9.tar.gz tar -zvxf php-5.6.9.tar.gz cd php-5.6.9 ./configure --prefix=/usr/local/php --with-openssl --enable-fpm --with-mcrypt --enable-mbstring --enable-pdo --enable-pdo-mysql --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-mysqli --with-gd --enable-gd-native-ttf --with-png-dir --with-freetype-dir=/usr/include/freetype2/freetype/ --with-jpeg-dir --with-config-file-path=/usr/local/php/etc/php.ini ##错误1开始 # error libmcrypt wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz tar -zxvf libmcrypt-2.5.7.tar.gz cd libmcrypt-2.5.7 ./configure make make install # error libmcrypt ##错误1结束 ##再次执行 php 的 configure ##错误2开始 #Don't know how to define struct flock on this system, set --enable-opcache=no vi /etc/ld.so.conf + /usr/local/lib :wq ldconfig -v ##错误2结束 ##再次执行 php 的 configure make all install
php配置文件初始化
cp php.ini-development /usr/local/php/etc/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
php-fpm 配置及优化
##编辑php-fpm.cnf文件 使用sock方式 ;listen = 127.0.0.1:9000 listen = /dev/shm/php-cgi.sock 打开以下配置 listen.owner = nobody listen.group = nobody listen.mode = 0660 php-fpm初始/空闲/最大worker进程数 pm.max_children = 300 pm.start_servers = 20 pm.min_spare_servers = 5 pm.max_spare_servers = 35 最大处理请求数是指一个php-fpm的worker进程在处理多少个请求后就终止掉,master进程会重新respawn一个新的。 这个配置的主要目的是避免php解释器或程序引用的第三方库造成的内存泄露。 pm.max_requests = 10240
php-fpm 关闭及启动
pkill php-fpm /usr/local/php/sbin/php-fpm -c /usr/local/php/etc/php.ini
打赏
微信扫一扫,打赏作者吧~