#centos7系列,编译安装php7.3.5
#php源码解压到 /home/root/soft/php-7.3.5
#php安装到 /data/server/php
#以root用户权限执行
yum install freetype freetype-devel libpng libpng-devel libzip unzip libxml2 libxml2-devel openssl openssl-devel libmcrypt libzip-devel curl curl-devel libjpeg libjpeg-devel libXpm libXpm-devel libicu libicu-devel autoconf
'./configure' '--prefix=/data/server/php/' '--with-config-file-path=/data/server/php/etc' '--enable-fpm' '--with-fpm-user=java' '--with-fpm-group=java' '--enable-mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-iconv-dir' '--with-freetype-dir' '--with-jpeg-dir' '--with-png-dir' '--with-zlib' '--with-libxml-dir' '--enable-xml' '--disable-rpath' '--enable-bcmath' '--enable-shmop' '--enable-sysvsem' '--enable-inline-optimization' '--with-curl' '--enable-mbregex' '--enable-mbstring' '--enable-intl' '--enable-ftp' '--with-gd' '--with-openssl' '--with-mhash' '--enable-pcntl' '--enable-sockets' '--with-xmlrpc' '--enable-soap' '--with-gettext' '--disable-fileinfo' '--enable-opcache'
#之后编译安装
make && make install
#最后显示
Installing shared extensions: /data/server/php/lib/php/extensions/no-debug-non-zts-20180731/
Installing PHP CLI binary: /data/server/php/bin/
Installing PHP CLI man page: /data/server/php/php/man/man1/
Installing PHP FPM binary: /data/server/php/sbin/
Installing PHP FPM defconfig: /data/server/php/etc/
Installing PHP FPM man page: /data/server/php/php/man/man8/
Installing PHP FPM status page: /data/server/php/php/php/fpm/
Installing phpdbg binary: /data/server/php/bin/
Installing phpdbg man page: /data/server/php/php/man/man1/
Installing PHP CGI binary: /data/server/php/bin/
Installing PHP CGI man page: /data/server/php/php/man/man1/
Installing build environment: /data/server/php/lib/php/build/
Installing header files: /data/server/php/include/php/
Installing helper programs: /data/server/php/bin/
program: phpize
program: php-config
Installing man pages: /data/server/php/php/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /data/server/php/lib/php/
[PEAR] Archive_Tar - installed: 1.4.7
[PEAR] Console_Getopt - installed: 1.4.2
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util - installed: 1.4.3
[PEAR] PEAR - installed: 1.10.9
Wrote PEAR system config file at: /data/server/php/etc/pear.conf
You may want to add: /data/server/php/lib/php to your php.ini include_path
/home/root/soft/php-7.3.5/build/shtool install -c ext/phar/phar.phar /data/server/php/bin
ln -s -f phar.phar /data/server/php/bin/phar
Installing PDO headers: /data/server/php/include/php/ext/pdo/
#之后
cd /data/server/php/etc/
cp php-fpm.conf.default php-fpm.conf
cp ~/soft/php-7.3.5/php.ini-production /data/server/php/lib/php.ini
#修改PHP的基本参数
vi /data/server/php/lib/php.ini
#增加fpm的配置参数
cp /data/server/php/etc/php-fpm.d/www.conf.default /data/server/php/etc/php-fpm.d/www.conf
#增加php以及php-fpm的系统软连接
ln -s /data/server/php/sbin/php-fpm /usr/local/bin
ln -s /data/server/php/bin/php /usr/local/bin/
#设置启动项
cp ~/soft/php-7.3.5/sapi/fpm/php-fpm.service /usr/lib/systemd/system/
systemctl enabled php-fpm
systemctl start php-fpm
systemctl status php-fpm -l
#默认9000端口监听,记得修改阿里云、腾讯云的开放端口,并检查是否开启了linux防火墙,检查端口
#nginx 配置示例,nginx与PHP不在一个服务器上
server
{
listen 80;
#server_name 填写域名
server_name aaa.com;
index index.php index.html index.htm default.php default.htm default.html;
#root /www/wwwroot/APP;
#SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
#error_page 404/404.html;
#SSL-END
#ERROR-PAGE-START 错误页配置,可以注释、删除或修改
error_page 404 /404.html;
error_page 502 /502.html;
#ERROR-PAGE-END
#PHP-INFO-START PHP引用配置,可以注释或修改
location ~* \.php$ {
#root 填写目标PHP服务器的项目文件路径
root /opt/html;
fastcgi_pass 172.16.0.2:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
#PHP-INFO-END
#REWRITE-START URL重写规则引用
#include /www/server/panel/vhost/rewrite/aaa.com.conf;
#REWRITE-END
#禁止访问的文件或目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
error_log off;
access_log /dev/null;
}
location ~ .*\.(js|css)?$
{
expires 12h;
error_log off;
access_log /dev/null;
}
#日志存储路径
access_log /www/wwwlogs/aaa.com.log;
error_log /www/wwwlogs/aaa.com.error.log;
}