groupadd -r www && useradd -r -g www -s /bin/false -d /usr/local/php7 -M php
yum -y install gcc libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel libzip-devel wget cmake libtool
yum remove libzip -y
#1.5.1版本
wget https://nih.at/libzip/libzip-1.5.1.tar.gz
tar -zxvf libzip-1.5.1.tar.gz
cd libzip-1.5.1
mkdir build && cd build && cmake … && make && make install
#1.2.0版本(不要使用)
wget https://nih.at/libzip/libzip-1.2.0.tar.gz
tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure
make && make install
#cmake版本低的时候
yum remove cmake
cd /opt
wget https://cmake.org/files/v3.10/cmake-3.10.2-Linux-x86_64.tar.gz
tar -zxvf cmake-3.10.2-Linux-x86_64.tar.gz
export CMAKE_HOME=/opt/cmake-3.10.2-Linux-x86_64
export PATH= P A T H : PATH: PATH:CMAKE_HOME/bin
source /etc/profile
cmake -version
##configure: error: off_t undefined; check your library configuration
echo ‘/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64’>>/etc/ld.so.conf
ldconfig -v
tar -xzvf php-7.3.2.tar.gz
cd php-7.3.2
./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/lib/mysql/mysql.sock
–with-mhash
–with-openssl
–with-mysqli=shared,mysqlnd
–with-pdo-mysql=shared,mysqlnd
–with-gd
–with-iconv
–with-zlib
–enable-zip
–enable-inline-optimization
–disable-debug
–disable-rpath
–enable-shared
–enable-xml
–enable-bcmath
–enable-shmop
–enable-sysvsem
–enable-mbregex
–enable-mbstring
–enable-ftp
–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=www
–with-fpm-group=www
–without-gdbm
–disable-fileinfo
make
make test
make install
#问题:zipconf.h: No such file or directory
cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h
#当配置PHP时出现 make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1 时,是因为服务器内存不足1G。只需要在配置命令中添加 --disable-fileinfo即可
1 配置php.ini
php.ini是php运行核心配置文件:
######避免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-20141001/”
######设置PHP的opcache和mysql动态库
zend_extension=opcache.so
extension=mysqli.so
extension=pdo_mysql.so
######设置PHP的时区
date.timezone = PRC
######开启opcache
[opcache]
; Determines if Zend OPCache is enabled
opcache.enable=1
######设置PHP脚本允许访问的目录(需要根据实际情况配置)
;open_basedir = /usr/share/nginx/html;
2 配置php-fpm.conf
php-fpm.conf是 php-fpm 进程服务的配置文件:
######设置错误日志的路径
error_log = /var/log/php-fpm/error.log
######引入www.conf文件中的配置
include=/usr/local/php7/etc/php-fpm.d/*.conf
3 配置www.conf(在php-fpm.d目录下)
www.conf这是 php-fpm 进程服务的扩展配置文件:
######设置用户和用户组
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/sessio