PHP 7.2已经在中止支持,旧代码需要在下面链接下载:
https://php.watch/versions/7.2/releases/7.2.34
在安装PHP前,如果不是旧系统,自带的OpenSSL库会是3,需要先安装旧版OpenSSL库:
$ wget https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz
$ tar zxvf openssl-1.1.1w.tar.gz
$ cd openssl*
$ ./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib
$ make
$ make test
$ make install
然后再安装PHP:
$ cd php-src-php-7.2.34/
$ apt install autoconf build-essential curl libtool libssl-dev libcurl4-openssl-dev libxml2-dev libreadline-dev libzip-dev openssl pkg-config zlib1g-dev libsqlite3-dev libonig-dev libpng-dev libfreetype6-dev freetype2-demos libjpeg-dev bison
$ ./configure --prefix=/opt/php-7.2.34 --enable-mysqlnd --with-pdo-mysql --with-pdo-mysql=mysqlnd --enable-bcmath --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --enable-mbstring --enable-phpdbg --enable-shmop --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-zip --with-zlib --with-curl --with-pear --with-openssl --enable-pcntl --with-readline --enable-calendar --with-mysqli --with-openssl=/usr/local/ssl --without-pear --with-gd
$ make
$ make test
$ make install
$ cp php.ini-production /opt/php-7.2.34/lib/php.ini
$ cd /opt/php-7.2.34/etc;
$ cp php-fpm.conf.default php-fpm.conf
$ cp php-fpm.d/www.conf.default php-fpm.d/www.conf
修改www.conf里的IP和端口,以适应实际情况。默认端口是9000。默认IP是127.0.0.1。
access.log = var/log/$pool.access.log
修改php.ini:
post_max_size = 128M
upload_max_filesize = 128M
memory_limit = 2G
max_input_vars = 2000
max_execution_time = 300
max_input_time = 600
error_log = /opt/php-7.2.34/var/log/error.log
再安装stats扩展:
$ wget https://pecl.php.net/get/stats-2.0.3.tgz
$ tar zxvf stats-2.0.3.tgz
$ cd stats-2.0.3
$ /opt/php-7.2.34/bin/phpize
$ ./configure --with-php-config=/opt/php-7.2.34/bin/php-config
$ make
$ make test
$ make install
启动php-fpm:
$ /opt/php-7.2.34/sbin/php-fpm
在nginx里配置:
location ~ /demo/ {
access_log /var/log/nginx/d7_php_access.log;
error_log /var/log/nginx/d7_php_error.log;
include snippets/fastcgi-php.conf;
fastcgi_pass 172.16.5.51:9000;
}
评论