准备
1、下载所需安装包
wget https://www.php.net/distributions/php-7.4.0.tar.gz
wget http://nginx.org/download/nginx-1.17.6.tar.gz
2、安装所需扩展
yum install -y gcc gcc-c++ make cmake bison autoconf wget lrzsz libtool libtool-ltdl-devel freetype-devel libjpeg.x86_64 libjpeg-devel libpng-devel gd-devel python-devel patch sudo openssl* openssl openssl-devel ncurses-devel bzip* bzip2 unzip zlib-devel libevent* libxml* libxml2-devel libcurl* curl-devel readline-devel sqlite-devel libsodium-devel https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/o/oniguruma-5.9.5-3.el7.x86_64.rpm https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/o/oniguruma-devel-5.9.5-3.el7.x86_64.rpm
安装PHP
1、解压-进入目录-生成编译文件
tar -zxvf php-7.4.0.tar.gzcd php-7.4.0./configure --prefix=/usr/local/php / --with-config-file-scan-dir=/usr/local/php/etc/ / --with-mhash --with-pdo-mysql / --with-openssl --with-mysqli / --with-iconv --with-zlib / --enable-inline-optimization / --disable-debug --disable-rpath / --enable-shared --enable-xml / --enable-bcmath --enable-shmop / --enable-sysvsem --enable-sysvshm --enable-mbregex / --enable-mbstring --enable-ftp / --enable-pcntl --enable-sockets / --with-xmlrpc --enable-soap / --without-pear --with-gettext / --enable-session --with-curl / --enable-opcache --enable-fpm / --without-gdbm --enable-fast-install / --disable-fileinfo --with-sodium
2、编译 并 安装
make && make install
3、配置文件
1.复制配置文件到安装目录
cp ~/php-7.4.0/php.ini-production /usr/local/php/etc/php.inicp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.confcp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
2.修改PHP 配置文件 php.ini
vim /usr/local/php/etc/php.ini
内容修改如下:
;不显示错误,默认display_errors = Off;在关闭display_errors后开启PHP错误日志(路径在php-fpm.conf中配置),默认log_errors = On;字符集,默认default_charset = "UTF-8";文件上传大小,默认值太小,建议修改10Mupload_max_filesize = 2M;Maximum size of POST data that PHP will accept. 表单最大值,默认是8M,如果表单含有多图上传,大小可能不够。超过该大小后台收不到 表单数据post_max_size = 8M;设置PHP的扩展库路径,默认被注释了,之后一个文件夹 于 你/usr/local/php/lib/php/extensions/ 下的文件夹同名。extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/";设置PHP的时区date.timezone = PRC;开启opcache,默认是0[opcache]; Determines if Zend OPCache is enabledopcache.enable=1
3.修改php-fpm 的配置文件 php-fpm.conf
vim /usr/local/php/etc/php-fpm.conf
内容修改如下
; 去掉里分号,方便以后重启。建议修改;Default Value: none; 下面的值最终目录是/usr/local/php/var/run/php-fpm.pid; 开启后可以平滑重启php-fpmpid = run/php-fpm.pid; 设置错误日志的路径,可以默认值; Note: the default prefix is /usr/local/php/var; Default Value: log/php-fpm.log, 即/usr/local/php/var/log/php-fpm.logerror_log = /var/log/php-fpm/error.log; Log等级,可以默认值; Possible Values: alert, error, warning, notice, debug; Default Value: noticelog_level = notice; 后台运行,默认yes,可以默认值; Default Value: yes;daemonize = yes; 引入www.conf文件中的配置,可以默认值include=/usr/local/php/etc/php-fpm.d/*.conf
新闻热点
疑难解答