前置条件
首先要有一台linux 服务器,阿里云、腾讯云等等都行
由于我之前买的是腾讯云的服务器,本文就以腾讯云服务器为例
LNMP(Linux+Nginx+Mysql+PHP)
php-7.3.4
Mysql 以及Nginx的安装请参考博主的另一篇文章
https://blog.csdn.net/gao36951/article/details/73321345
PHP 环境准备(php-7.3.4.tar.gz)
下载地址:https://www.php.net/downloads.php
cd /root/php/
tar -zxvf php-7.3.4.tar.gz
cd php-7.3.4
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-zlib-dir=/usr/local/zlib --with-libxml-dir=/usr/local/libxml2/ --with-iconv-dir=/usr/local/libiconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring=all --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --enable-ctype --enable-shared --with-gd
执行报错:
configure: error: in `/root/php/php-7.3.4':
configure: error: no acceptable C compiler found in $PATH
解决方案:
yum install gcc
执行报错:
checking whether to use system default cipher list instead of hardcoded value... no
checking for RAND_egd... no
checking for pkg-config... /usr/bin/pkg-config
configure: error: Cannot find OpenSSL's
解决方案:
yum install openssl openssl-devel
ln -s /usr/lib64/libssl.so /usr/lib/
执行报错:
checking pcre install prefix... no
checking libzip... yes
checking for the location of zlib... /usr
checking for pkg-config... (cached) /usr/bin/pkg-config
checking for libzip... configure: error: system libzip must be upgraded to version >= 0.11
解决方案:
yum remove libzip -y
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
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-zlib-dir=/usr/local/zlib --with-libxml-dir=/usr/local/libxml2/ --with-iconv-dir=/usr/local/libiconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring=all --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --enable-ctype --enable-shared --with-gd --with-fpm-user=nginx --with-fpm-group=nginx
make && make install
执行报错:
In file included from /root/php/php-7.3.4/ext/zip/php_zip.h:31:0,
from /root/php/php-7.3.4/ext/zip/php_zip.c:36:
/usr/local/include/zip.h:59:21: fatal error: zipconf.h: No such file or directory
#include
^
compilation terminated.
make: *** [ext/zip/php_zip.lo] Error 1
解决方案:
cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h
make && make install
cp php.ini-production /usr/local/php/etc/php.ini
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
vim /etc/profile.d/php.sh
export PATH=$PATH:/usr/local/php/bin/:/usr/local/php/sbin/
source /etc/profile.d/php.sh
service php-fpm start
ps -ef | grep php-fpm
netstat -lntup | grep 9000
vim /etc/nginx/nginx.conf
server {
listen 80;
server_name localhost;
include /etc/nginx/default.d/*.conf;
location / {
root /project/php;
}
location /favicon.ico {
root /project/php;
}
location ~ \.php$ {
root /project/php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
nginx -s reload
cd /project/php
touch test.php
echo "" > test.php
参考:
https://blog.csdn.net/mangojo/article/details/86475554
http://www.kwx.gd/PHPEnvironment/CetnOS-libzip.html
https://blog.csdn.net/alexdream/article/details/7408561
https://blog.csdn.net/duguduchong/article/details/8699774
https://blog.csdn.net/weixin_42579642/article/details/85290670
http://www.kuitao8.com/20180429/4689.shtml