下载PHP
这里下载7.3.5
cd /download
wgettar -zvxf php-7.3.5.tar.gz
cd ./php-7.3.5[root@localhost download]# cd php-7.3.5
[root@localhost php-7.3.5]# ls
acinclude.m4 genfiles php.ini-development run-tests.php
aclocal.m4 header php.ini-production sapi
appveyor INSTALL README.EXT_SKEL scripts
build install-sh README.GIT-RULES server-tests-config.php
buildconf LICENSE README.input_filter server-tests.php
buildconf.bat ltmain.sh README.MAILINGLIST_RULES snapshot
CODING_STANDARDS main README.md stamp-h.in
config.guess makedist README.NEW-OUTPUT-API tests
config.sub Makefile.frag README.PARAMETER_PARSING_API travis
configure Makefile.gcov README.REDIST.BINS TSRM
configure.ac Makefile.global README.RELEASE_PROCESS UPGRADING
CONTRIBUTING.md missing README.SELF-CONTAINED-EXTENSIONS UPGRADING.INTERNALS
CREDITS mkinstalldirs README.STREAMS vcsclean
ext NEWS README.SUBMITTING_PATCH win32
EXTENSIONS pear README.TESTING Zend
footer php7.spec.in README.UNIX-BUILD-SYSTEM
generated_lists php.gif README.WIN32-BUILD-SYSTEM
安装开发工具um install -y libxml2-devel openssl-devel
yum install curl-devel
yum install -y libjpeg-devel
yum install -y libpng-devel
yum install freetype-devel
yum -y install libzip-devel
执行./configure./configure --prefix=/usr/local/php --enable-mbstring --enable-ftp --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pear --enable-sockets --with-freetype-dir=/usr --with-zlib --with-libxml-dir=/usr --with-xmlrpc --enable-zip --enable-fpm --enable-xml --enable-sockets --with-gd --with-zlib --with-iconv --enable-zip --with-freetype-dir=/usr/lib/ --enable-soap --enable-pcntl --enable-cli --with-curl --enable-opensslchecking for libzip... configure: error: system libzip must be upgraded to version >= 0.11
更新libzip库yum remove libzip -y
cd /download
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 installGenerating 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,需要一点时间make && make install/usr/local/include/zip.h:59:21: 致命错误:zipconf.h:没有那个文件或目录
查找zipconf.h文件find / -name "zipconf.h"
/usr/local/lib/libzip/include/zipconf.h
复制到/usr/local/lib/libzip/include目录/usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h
再次执行make && make install
看到如下代码则证明安装成功Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
/download/php-7.3.5/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers: /usr/local/php/include/php/ext/pdo/
软连接到/usr/local/binln -s /usr/local/php/bin/php /usr/local/bin/php
ln -s /usr/local/php/sbin/php-fpm /usr/local/sbin/php-fpm
查看PHP版本信息[root@localhost php-7.3.5]# php -v
PHP 7.3.5 (cli) (built: May 10 2019 12:04:53) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.5, Copyright (c) 1998-2018 Zend Technologies
复制php.ini文件cp php.ini-development /usr/local/php/php.ini
运行php-fpmphp-fpm
[10-May-2019 12:09:06] ERROR: failed to open configuration file '/usr/local/php/etc/php-fpm.conf': No such file or directory (2)
[10-May-2019 12:09:06] ERROR: failed to load configuration file '/usr/local/php/etc/php-fpm.conf'
[10-May-2019 12:09:06] ERROR: FPM initialization failed
复制php-fpm.conf文件cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
再次执行php-fpm[root@localhost php-7.3.5]# php-fpm
[10-May-2019 12:10:50] WARNING: Nothing matches the include pattern '/usr/local/php/etc/php-fpm.d/*.conf' from /usr/local/php/etc/php-fpm.conf at line 143.
[10-May-2019 12:10:50] ERROR: No pool defined. at least one pool section must be specified in config file
[10-May-2019 12:10:50] ERROR: failed to post process the configuration
[10-May-2019 12:10:50] ERROR: FPM initialization failedcp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
再次执行php-fpmphp-fpm
查看php-fpm进程ps -ef|grep php[root@localhost php-7.3.5]# ps -ef|grep php
root 35429 1 0 12:12 ? 00:00:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
nobody 35430 35429 0 12:12 ? 00:00:00 php-fpm: pool www
nobody 35431 35429 0 12:12 ? 00:00:00 php-fpm: pool www
root 35455 20525 0 12:12 pts/0 00:00:00 grep --color=auto php
php-fpm运行成功
到网页查看phpinfo()
浏览器打开网页,我这边虚拟机地址为192.168.1.110
查看虚拟机开启端口firewall-cmd --zone=public --list-ports
发现返回是空的
把80端口开放firewall-cmd --zone=public --add-port=80/tcp --permanent
success
重启防火墙firewall-cmd --reload
再次打开浏览器
nginx网页目录写入一个index.php文件vi /usr/local/nginx/html/index.php
文件内容为<?php
phpinfo();
修改nginx.conf配置文件让nginx支持PHP文件vi /usr/local/nginx/conf/nginx.conf#把这几行前面的井号去掉并保存
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
重启nginx[root@localhost php-7.3.5]# pkill -9 nginx # 杀掉nginx进程
[root@localhost php-7.3.5]# nginx # 启动nginx