一、在官网下载PHP-7.4.6版本压缩包
下载安装包到/root下 [root@server1 ~]# ll -d php-7.4.6.tar.bz2 -rw-r--r-- 1 root root 12726842 Aug 14 00:51 php-7.4.6.tar.bz2 [root@server1 ~]# tar xf php-7.4.6.tar.bz2 [root@server1 ~]# cd php-7.4.6/
二、执行configure
./configure --prefix=/usr/local/lnmp/php --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-curl --with-iconv --with-mhash --with-zlib --with-openssl --enable-mysqlnd --with-mysqli --with-pdo-mysql --disable-debug --enable-sockets --enable-soap --enable-inline-optimization --enable-xml --enable-ftp --enable-gd --enable-exif --enable-mbstring --enable-bcmath --with-fpm-systemd --------------------------------------------------------------------- [root@server1 php-7.4.6]# dnf install systemd-devel -y [root@server1 php-7.4.6]# dnf install libxml2-devel -y [root@server1 php-7.4.6]# dnf install libcurl-devel -y [root@server1 php-7.4.6]# dnf install sqlite-devel -y [root@server1 php-7.4.6]# dnf install libpng-devel -y --------------------------------------------------------------------- 还差oniguruma-6.8.2-1.el7.x86_64.rpm和oniguruma-devel-6.8.2-1.el7.x86_64.rpm 仓库里没有安装包,可以在阿里云下载到主机上 [root@server1 php-7.4.6]# dnf install -y oniguruma-* ---------------------------------------------------------------------- 重复第一条操作,无报错就success : Thank you for using PHP.
![]()
三、make和make install
make ##需要的时间有点长 make install ##这两步为了生成/usr/local/lnmp/php/ [root@server1 php-7.4.6]# ll -d /usr/local/lnmp/php/ drwxr-xr-x 9 root root 88 Aug 14 01:22 /usr/local/lnmp/php/
四、修改nginx的配置文件以及nginx的html
[root@server1 php-7.4.6]# vim /usr/local/lnmp/nginx/conf/nginx.conf location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_params; } [root@server1 php-7.4.6]# nginx -s reload --------------------------------------------------------------------- vim /usr/local/lnmp/nginx/html/index.php <?php phpinfo() ?> [root@server1 php-7.4.6]# nginx -s reload
五、修改php的文件
cd /root/php-7.4.6/ cp php.ini-production /usr/local/lnmp/php/lib/php.ini cd /root/php-7.4.6/sapi/fpm/ cp init.d.php-fpm /etc/init.d/php-fpm chmod +x /etc/etc/init.d/php-fpm cd /usr/local/lnmp/php/etc/ cp php-fpm.conf.default php-fpm.conf cd /usr/local/lnmp/php/etc/php-fpm.d cp www.conf.default www.conf /etc/init.d/php-fpm nginx -s reload
六、测试
七、实现高速缓存
在官网下载memcache 4.0.5.2 tgz yum install -y autoconf tar zxf memcache 4.0.5.2 tgz cd memcache 4.0.5.2 /usr/local/lnmp/php/bin/phpize ./congigure ##切记在path中 vim /root/.bash_profile 添加/usr/local/lnmp/php/bin: ##source .bash_profile make make install
vi /usr/local/lnmp/php/lib/php.ini 添加一行 extension=memcache.so /etc/init.d/php-fpm reload 加载php
测试:
cd /memcache-4.0.5.2 /usr/local/lnmp/php/bin/php -m | grep memcache ##过滤是否有memcache这个资源
八、做监控页面memecache.php
dnf install -y memcached systemctl start memcached cd memcache-4.0.5.2 cp memcache.php example.php /usr/local/lnmp/nginx/html/ cd /usr/local/lnmp/nginx/html/ vim memache.php $MEMCACHE_SERVERS[] = '127.0.0.1:11211'; // add more as an array #$MEMCACHE_SERVERS[] = 'mymemcache-server2:11211'; // add more as an array