标签:lis date listen php错误日志 开启 mod ldap get deb
yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel openldap openldap-devel libxslt libxslt-devel
cp -frp /usr/lib64/libldap* /usr/lib/
ln -s /usr/lib64/liblber* /usr/lib/
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.2.0.tar.gz
tar -zxvf php-7.2.0.tar.gz
cd php-7.2.0/
./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-libxml-dir=/usr --with-iconv-dir --with-mhash --with-openssl --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --with-ldap=shared --with-ldap-sasl --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --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 --with-fpm-user=nginx --with-fpm-group=nginx --without-gdbm --disable-fileinfo --with-xsl
make && make install
ll /usr/local/php7/lib/php/extensions/no-debug-non-zts-20170718/
直接使用编译后未经优化处理的配置
cp php.ini-production /usr/local/php7/etc/php.ini
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
修改配置文件
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-20170718/"
######设置PHP的opcache和mysql动态库
zend_extension=opcache.so
extension=mysqli.so
extension=pdo_mysql.so
extension=ldap.so
######设置PHP的时区
date.timezone = PRC
######开启opcache
[opcache]
opcache.enable=1
######设置PHP脚本允许访问的目录(需要根据实际情况配置)
open_basedir = /etc/nginx/html;
vim /usr/local/php7/etc/php-fpm.conf
[global]
pid = /usr/local/php7/var/run/php-fpm.pid
error_log = /usr/local/php7/var/log/php-fpm.log
log_level = notice
[www]
listen = /var/run/php-fpm/php-fpm.sock ### 或者 127.0.0.1:9000
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = nginx
listen.group = nginx
listen.mode = 0666
user = nginx
group = nginx
pm = dynamic
pm.max_children = 80
pm.start_servers = 40
pm.min_spare_servers = 40
pm.max_spare_servers = 80
request_terminate_timeout = 100
request_slowlog_timeout = 10s
slowlog = /var/log/php-fpm/$pool-slow.log
######设置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都是由 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
标签:lis date listen php错误日志 开启 mod ldap get deb
原文地址:http://blog.51cto.com/hequan/2058926