PHP编译安装并通过NGINX发布

一、下载安装包

wget https://mirrors.sohu.com/php/php-7.4.9.tar.gz

二、解压并进入 解压目录 

tar zxvf php-7.4.9.tar.gz &&  cd php-7.4.9

三、预编译、编译、安装

./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --with-mhash --with-openssl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib --enable-bcmath  --enable-gd --with-jpeg --with-freetype  --enable-mbstring --enable-ftp --enable-sockets   --with-gettext --enable-session --with-curl   --enable-fpm --with-fpm-user=php --with-fpm-group=php   --enable-pdo -enable-tokenizer --with-zip
make && make install
注意:在第三步预编译过程中通常会有很多报错,其中比较难处理的是

configure: error: Package requirements (oniguruma) were not met

oniguruma是一个处理正则表达式的库,在编译安装php时,如果使用–enable-mbstring 参数, 开启mbstring扩展,则会出现这个错误。

原因:mbstring的正则功能需要oniguruma的支持,系统中却没有oniguruma库。

解决办法:

1、在’–enable-mbstring’参数后添加’–disable-mbregex’参数,意为不使用mbstring的正则功能,不再需要oniguruma库,或者去掉该参数也可以。

2、安装oniguruma库

wget https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz -O oniguruma-6.9.4.tar.gz
tar -zxf oniguruma-6.9.4.tar.gz
cd oniguruma-6.9.4 
./autogen.sh && ./configure --prefix=/usr  --libdir=/lib64
make && make install 
在使用./configure时添加‘–libdir=/lib64’参数,重新编译PHP,如果不使用该参数则仍会报错。

其它报错,如缺XXX包,基本上通过yum install  -y XXX-devel安装成功,然后重新预编译即可解决

四、给配置文件改名,否则启动时会报错
cd /usr/local/php7/etc/
cp php-fpm.conf.default php-fpm.conf
cp php-fpm.d/www.conf.default php-fpm.d/www.conf

五、给php命令设置软链接
ln -s /usr/local/php7/bin/* /usr/local/bin
ln -s /usr/local/php7/sbin/* /usr/local/sbin

六、查看php的版本和支持的模块 
php -v

php -m 

七、配置nginx的php网页
vim /usr/local/nginx/conf/nginx.conf

        location / {
            root   html;
            index  index.php index.html index.htm;
        }
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zcfeng530

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值