CentOS Linux release 7.5.1804 (Core) 编译安装 PHP7.2 OR NGINX1.15.4

本文只介绍给编译的初学者


1.安装需要的依赖包

yum -y install wget tomcat psmisc net-tools curl openssl openssl-devel vim zlib pcre pcre-devel gcc gcc-c++ libxml2-devel autoconf apr apr-util

# (wget下载)
# (tomcat查看日志)
# (psmisc别名killall杀进程)
# (net-tools别名netstat看端口)
# (curl不解释) (SSL)  (vim编辑器)
# (gzip模块需要 zlib 库)
# (rewrite模块需要 pcre 库 pcre-devel)
# (gcc gcc-c++不解释)
# (libxml2-devel不解释)
# (libiconv 对文本进行编码间的转换,用它来处理中文各种编码之间的转换 PHP 手动下载)
# (libmcrypt 实现加密功能的库 PHP手动下载)
# (mhash 哈稀函数库 PHP手动下载)
# (mcrypt 加密PHP手动下载)
# (autoconf PHP动态编译)
# (make 编译安装)

 

2.下载

  1. http://hk1.php.net/get/php-7.2.10.tar.gz/from/this/mirror
  2. http://nginx.org/download/nginx-1.15.4.tar.gz
  3. 耐心
  4. tar -zxvf mirror
  5. tar -zxvf nginx-1.15.4.tar.gz

3.安装PHP

cd php-7.2.10
./configure --prefix=/usr/local/php7.2 --enable-fpm ./configure --with-mysqli=mysqlnd

 出现下图  编译配置成功

Generating files
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.
make && make install

 试验一下

[root@localhost ~]# /usr/local/php7.2/bin/php -v
PHP 7.2.10 (cli) (built: Sep 28 2018 13:31:01) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
[root@localhost ~]# 

 成功 !

编辑PHP-FPM

cd /usr/local/php7.2/etc
cp php-fpm.conf.default php-fpm.conf
cp php-fpm.d/www.conf.default  php-fpm.d/www.conf
vim php-fpm.d/www.conf

 找到下面的代码 改成 对应的

listen = 127.0.0.1:9000
;listen.owner = nobody
;listen.group = nobody
;listen.mode = 0660

listen = var/run/php-fpm.sock
listen.owner = nobody
listen.group = nobody
listen.mode = 0660

 4.安装nginx

cd nginx-1.15.4
./configure --prefix=/usr/local/nginx --with-pcre
make && make install

 修改 nginx/conf/nginx.conf

location ~ \.php$ {
            root           html;
        #    fastcgi_pass   127.0.0.1:9000;
            fastcgi_pass   unix:/usr/local/php7.2/var/run/php-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi_params;
        }

 运行

./usr/local/nginx/sbin/nginx

开启 80 端口与FTP

firewall-cmd --zone=public --add-service=ftp --permanent
firewall-cmd --zone=public --add-port=80/tcp --permanent
systemctl restart firewalld

 启动PHP 与 nginx

/usr/local/nginx/sbin/nginx
/usr/local/php7.2/sbin/php-fpm

 

你可能感兴趣的:(初学者的笔记)