继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

PHP-7.1.11 YUM安装 与编译安装

叮当猫咪
关注TA
已关注
手记 199
粉丝 6
获赞 27

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   openldap   openldap-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.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-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-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 \

--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

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

######设置错误日志的路径

error_log = /var/log/php-fpm/error.log

######引入www.conf文件中的配置

include=/usr/local/php7/etc/php-fpm.d/*.conf

[root@zabbix ~]# cat  /usr/local/php/etc/php-fpm.conf

[global]

pid = /usr/local/php/var/run/php-fpm.pid

error_log = /usr/local/php/var/log/php-fpm.log

log_level = notice

[www]

listen = /tmp/php-cgi.sock

listen.backlog = -1

listen.allowed_clients = 127.0.0.1

listen.owner = www

listen.group = www

listen.mode = 0666

user = www

group = www

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 = 0

slowlog = var/log/slow.log

 

 

 

 

 

 

 

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



打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP