centos7环境php7安装

下载
链接:https://pan.baidu.com/s/1kVENjV7Z7SJOYm0-OhodUA
提取码:e167

安装操作指令

## 文件目录,个人喜好选择
[root@iZm5eealoheq9oyr6fvfk6Z src] cd /usr/local/src/
## 解压
[root@iZm5eealoheq9oyr6fvfk6Z src] tar -zxvf mirror
## 进入
[root@iZm5eealoheq9oyr6fvfk6Z src] cd php-7.2.10/
## 配置
[root@iZm5eealoheq9oyr6fvfk6Z php-7.2.10] ./configure --prefix=/usr/local/php  --with-curl  --with-freetype-dir  --with-gd  --with-gettext  --with-iconv-dir  --with-kerberos  --with-libdir=lib64  --with-libxml-dir  --with-mysqli  --with-openssl  --with-pcre-regex  --with-pdo-mysql  --with-pdo-sqlite  --with-pear  --with-png-dir  --with-xmlrpc  --with-xsl  --with-zlib  --enable-fpm  --enable-bcmath  --enable-libxml  --enable-inline-optimization  --enable-gd-native-ttf  --enable-mbregex  --enable-mbstring  --enable-opcache  --enable-pcntl  --enable-shmop  --enable-soap  --enable-sockets  --enable-sysvsem  --enable-xml  --enable-zip
## 遇到错误如下:
configure: error: libxml2 not found. Please check your libxml2 installation.
## 缺少libxml2,所以安装libxml2, 由于libxml2安装需要一些依赖库,所以如下一并安装
[root@iZm5eealoheq9oyr6fvfk6Z php-7.2.10] yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql pcre-devel
...
Complete! // 
## 然后继续执行之前的配置命令
[root@iZm5eealoheq9oyr6fvfk6Z php-7.2.10] ./configure --prefix=/usr/local/php  --with-curl  --with-freetype-dir  --with-gd  --with-gettext  --with-iconv-dir  --with-kerberos  --with-libdir=lib64  --with-libxml-dir  --with-mysqli  --with-openssl  --with-pcre-regex  --with-pdo-mysql  --with-pdo-sqlite  --with-pear  --with-png-dir  --with-xmlrpc  --with-xsl  --with-zlib  --enable-fpm  --enable-bcmath  --enable-libxml  --enable-inline-optimization  --enable-gd-native-ttf  --enable-mbregex  --enable-mbstring  --enable-opcache  --enable-pcntl  --enable-shmop  --enable-soap  --enable-sockets  --enable-sysvsem  --enable-xml  --enable-zip
## 然后又遇到错误如下:
configure: error: Cannot find OpenSSL's <evp.h>
### 缺少OpenSSL,所以安装OpenSSL
[root@iZm5eealoheq9oyr6fvfk6Z php-7.2.10] yum install openssl openssl-devel
...
Complete! // 
## 然后继续
[root@iZm5eealoheq9oyr6fvfk6Z php-7.2.10] ./configure --prefix=/usr/local/php  --with-curl  --with-freetype-dir  --with-gd  --with-gettext  --with-iconv-dir  --with-kerberos  --with-libdir=lib64  --with-libxml-dir  --with-mysqli  --with-openssl  --with-pcre-regex  --with-pdo-mysql  --with-pdo-sqlite  --with-pear  --with-png-dir  --with-xmlrpc  --with-xsl  --with-zlib  --enable-fpm  --enable-bcmath  --enable-libxml  --enable-inline-optimization  --enable-gd-native-ttf  --enable-mbregex  --enable-mbstring  --enable-opcache  --enable-pcntl  --enable-shmop  --enable-soap  --enable-sockets  --enable-sysvsem  --enable-xml  --enable-zip
## 然后又遇到错误如下:
checking for cURL 7.10.5 or greater... configure: error: cURL version 7.10.5 or later is required to compile php with cURL support
## 安装curl-devel
[root@iZm5eealoheq9oyr6fvfk6Z php-7.2.10] yum -y install curl-devel
...
Complete!
## 然后继续
[root@iZm5eealoheq9oyr6fvfk6Z php-7.2.10] ./configure --prefix=/usr/local/php  --with-curl  --with-freetype-dir  --with-gd  --with-gettext  --with-iconv-dir  --with-kerberos  --with-libdir=lib64  --with-libxml-dir  --with-mysqli  --with-openssl  --with-pcre-regex  --with-pdo-mysql  --with-pdo-sqlite  --with-pear  --with-png-dir  --with-xmlrpc  --with-xsl  --with-zlib  --enable-fpm  --enable-bcmath  --enable-libxml  --enable-inline-optimization  --enable-gd-native-ttf  --enable-mbregex  --enable-mbstring  --enable-opcache  --enable-pcntl  --enable-shmop  --enable-soap  --enable-sockets  --enable-sysvsem  --enable-xml  --enable-zip
## 然后又遇到错误如下:
configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
## 安装libxslt-devel
[root@iZm5eealoheq9oyr6fvfk6Z php-7.2.10] yum -y install libxslt libxslt-devel
...
Complete!
## 然后继续
[root@iZm5eealoheq9oyr6fvfk6Z php-7.2.10] ./configure --prefix=/usr/local/php  --with-curl  --with-freetype-dir  --with-gd  --with-gettext  --with-iconv-dir  --with-kerberos  --with-libdir=lib64  --with-libxml-dir  --with-mysqli  --with-openssl  --with-pcre-regex  --with-pdo-mysql  --with-pdo-sqlite  --with-pear  --with-png-dir  --with-xmlrpc  --with-xsl  --with-zlib  --enable-fpm  --enable-bcmath  --enable-libxml  --enable-inline-optimization  --enable-gd-native-ttf  --enable-mbregex  --enable-mbstring  --enable-opcache  --enable-pcntl  --enable-shmop  --enable-soap  --enable-sockets  --enable-sysvsem  --enable-xml  --enable-zip
## 编译配置完成(终于好了),接着开始编译安装
[root@iZm5eealoheq9oyr6fvfk6Z php-7.2.10] make && make install
## 配置PHP
[root@iZm5eealoheq9oyr6fvfk6Z php-7.2.10] cp php.ini-development /usr/local/php/lib/php.ini
[root@iZm5eealoheq9oyr6fvfk6Z php-7.2.10] cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@iZm5eealoheq9oyr6fvfk6Z php-7.2.10] cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
[root@iZm5eealoheq9oyr6fvfk6Z php-7.2.10] cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm
## 启动
[root@iZm5eealoheq9oyr6fvfk6Z php-7.2.10] /etc/init.d/php-fpm
## 确认一下是否进程启动
[root@iZm5eealoheq9oyr6fvfk6Z php-7.2.10] ps -ef|grep php
root     19116     1  0 19:29 ?        00:00:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
nobody   19117 19116  0 19:29 ?        00:00:00 php-fpm: pool www
nobody   19118 19116  0 19:29 ?        00:00:00 php-fpm: pool www
root     19120 30461  0 19:29 pts/1    00:00:00 grep --color=auto php
## PHP安装完成

Nginx配置

## 修改nginx配置
[root@iZm5eealoheq9oyr6fvfk6Z php-7.2.10] vim /usr/local/nginxconf/nginx.conf
## 找到server项, 新增如下配置
location ~ \.php?.*$ {
   root           html;
   fastcgi_pass   127.0.0.1:9000;
   fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
   include        fastcgi_params;
}
## 测试配置
[root@iZm5eealoheq9oyr6fvfk6Z sbin] ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
## 重启Nginx
[root@iZm5eealoheq9oyr6fvfk6Z sbin] ./nginx -s reload

猜你喜欢

转载自blog.csdn.net/weixin_39416711/article/details/83420665