centos7下编译安装php-7.0.15(PHP-FPM)
一、下载php7源码包
1 | http: //php.net/downloads.php |
如:php-7.0.15.tar.gz
二、安装所需依赖
1 | > yum -y install gd-devel zlib-devel libjpeg-devel libpng-devel libiconv-devel freetype-devel libxml2 libxml2-devel openssl openssl-devel curl-devel libxslt-devel libmcrypt-devel mhash mcrypt |
如果无法安装libiconv,请手动下载安装
1 | http: //ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz |
1 2 3 4 | > tar xf libiconv-1.14.tar.gz > cd libiconv-1.14 > ./configure --prefix=/usr/local/libiconv > make && make install |
如果出现如下问题,说明你系统版本较高。
./stdio.h:1010:1: 错误:‘gets’未声明(不在函数内)
1 2 3 4 | > cd srclib/ > sed -i -e '/gets is a security/d' ./stdio.in.h > cd ../ > make && make install |
如果安装libmcrypt-devel、mhash、mcrypt出错,则重新配置yum源。
1 2 | http: //mirrors.163.com/.help/centos.html http: //mirrors.aliyun.com/help/centos |
三、编译PHP
创建账号
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | > useradd -s /sbin/nologin -M nginx > tar xf php-7.0.15.tar.gz > cd /data/php-7.0.15 > ./configure --prefix=/data/php7 \ --with-openssl \ --with-pcre-regex \ --with-kerberos \ --with-libdir=lib \ --with-libxml-dir \ --with-mysqli=shared,mysqlnd \ --with-pdo-mysql=shared,mysqlnd \ --with-pdo-sqlite \ --with-gd \ --with-iconv \ --with-zlib \ --with-xmlrpc \ --with-xsl \ --with-pear \ --with- gettext \ --with-curl \ --with-png-dir \ --with-jpeg-dir \ --with-freetype-dir \ --with-fpm-user=nginx \ --with-fpm-group=nginx \ --enable-mysqlnd \ --enable-zip \ --enable-inline-optimization \ --enable-shared \ --enable-libxml \ --enable-xml \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-mbregex \ --enable-mbstring \ --enable-ftp \ --enable-gd-native-ttf \ --enable-pcntl \ --enable-sockets \ --enable-soap \ --enable-session \ --enable-opcache \ --enable-fpm \ --enable-maintainer-zts \ --enable-fileinfo \ |
四、make && make install
1 | > make && make install |
五、配置文件
1 2 3 4 | > cp /data/php-7.0.15/php.ini-development /data/php7/lib/php.ini > cp -R /data/php-7.0.15/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm > cp /data/php7/etc/php-fpm.conf. default /data/php7/etc/php-fpm.conf > cp /data/php7/etc/php-fpm.d/www.conf. default /data/php7/etc/php-fpm.d/www.conf |
六、修改php.ini
1 2 | > mkdir /data/php7/tmp > chmod 766 /data/php7/tmp |
1 2 3 | extension_dir = "/data/php7/lib/php/extensions/no-debug-zts-20151012/" session.save_path = "/data/php7/tmp" date .timezone = PRC |
七、添加环境变量
1 2 | > echo 'export PATH=/data/php7/bin:/data/php7/sbin:$PATH' >> /etc/profile > source /etc/profile |
八、添加自启动
1 2 3 | > chkconfig --add php-fpm > chkconfig php-fpm on > chkconfig --list php-fpm |
九、启动服务
1 2 3 | > chmod 755 /etc/init.d/php-fpm > service php-fpm start > ps -ef|grep php-fpm |
十、php-fpm重启
php-fpm的pid文件默认在你php安装目录下var/run/php-fpm.pid
当然这是可以更改的,在/data/php7/etc/php-fpm.conf文件中
关闭
1 | > kill -INT `cat /data/php7/ var /run/php-fpm.pid` |
重启
1 | > kill -USR2 `cat /data/php7/ var /run/php-fpm.pid` |
版权声明:博主文章,可以不经博主允许随意转载,随意修改,知识是用来传播的。
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步