YUM 安装 rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm yum install php71w php71w-mysql php71w-odbc php71w-common php71w-embedded php71w-pgsql php71w-xml php71w-ldap php71w-fpm php71w-gd php71w-pdo php71w-devel php71w-mbstring php71w-mcrypt php71w-cli php71w-json php71w-imap php71w-bcmath mod_php71w php71w-pear rpm -qa |grep php systemctl start php-fpm.service netstat -lntup | grep 9000 whereis php-fpm 编译安装 yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel groupadd -g 58 nginx useradd -u 58 -g 58 -M nginx -s /sbin/nologin cd /usr/local/src wget http://cn2.php.net/distributions/php-7.1.11.tar.gz tar zxvf php-7.1.11.tar.gz cd php-7.1.11 ./configure --prefix=/usr/local/php7 --exec-prefix=/usr/local/php7 --bindir=/usr/local/php7/bin --sbindir=/usr/local/php7/sbin --includedir=/usr/local/php7/include --libdir=/usr/local/php7/lib/php --mandir=/usr/local/php7/php/man --with-config-file-path=/usr/local/php7/etc --with-mysql-sock=/var/run/mysql/mysql.sock --with-mcrypt=/usr/include --with-mhash --with-openssl --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --enable-fastcgi --with-fpm-user=nginx --with-fpm-group=nginx --without-gdbm --disable-fileinfo make && make install make test ##不是必须 ll /usr/local/php7/lib/php/extensions/no-debug-non-zts-20160303/ 直接使用编译后未经优化处理的配置 cp php.ini-production /usr/local/php7/etc/php.ini cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf 修改配置文件 vim /usr/local/php7/etc/php.ini ######避免PHP信息暴露在http头中 expose_php = Off ######避免暴露php调用mysql的错误信息 display_errors = Off ######在关闭display_errors后开启PHP错误日志(路径在php-fpm.conf中配置) log_errors = On ######设置PHP的扩展库路径 extension_dir = "/usr/local/php7/lib/php/extensions/no-debug-non-zts-20160303/" ######设置PHP的opcache和mysql动态库 zend_extension=opcache.so extension=mysqli.so extension=pdo_mysql.so ######设置PHP的时区 date.timezone = PRC ######开启opcache [opcache] opcache.enable=1 ######设置PHP脚本允许访问的目录(需要根据实际情况配置) open_basedir = /etc/nginx/html; vim /usr/local/php7/etc/php-fpm.conf ######设置错误日志的路径 error_log = /var/log/php-fpm/error.log ######引入www.conf文件中的配置 include=/usr/local/php7/etc/php-fpm.d/*.conf vim /usr/local/php7/etc/php-fpm.d/www.conf ######设置用户和用户组 user = nginx group = nginx ######根据nginx.conf中的配置fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;设置PHP监听 ; listen = 127.0.0.1:9000 #####不建议使用(看自己设置情况) listen = /var/run/php-fpm/php-fpm.sock ######开启慢日志 slowlog = /var/log/php-fpm/$pool-slow.log request_slowlog_timeout = 10s ######设置php的session目录(所属用户和用户组都是nginx) php_value[session.save_handler] = files php_value[session.save_path] = /var/lib/php/session echo -e ‘\nexport PATH=/usr/local/php7/bin:/usr/local/php7/sbin:$PATH\n‘ >> /etc/profile && source /etc/profile mkdir -p /var/log/php-fpm/ && mkdir -p /var/run/php-fpm && cd /var/run/ && chown -R nginx:nginx php-fpm mkdir -p /var/lib/php/session chown -R nginx:nginx /var/lib/php chmod +x /etc/init.d/php-fpm chkconfig --add php-fpm chkconfig php-fpm on php-fpm -t service php-fpm start ps -aux | grep php ##php-fpm进程数和进程用户nginx都是由www.conf中pm.start_servers和user的值分别决定的 root 26007 0.0 0.0 182016 6324 ? Ss 13:36 0:00 php-fpm: master process (/usr/local/php7/etc/php-fpm.conf) nginx 26008 0.0 0.0 182016 5884 ? S 13:36 0:00 php-fpm: pool www nginx 26009 0.0 0.0 182016 5884 ? S 13:36 0:00 php-fpm: pool www
时间: 2024-10-18 04:24:19