CentOS7源码安装PHP

一、更新库并安装依赖

yum -y install epel-release

yum -y install gcc gcc-c++ make pcre pcre-devel zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel openldap openldap-devel libmcrypt libmcrypt-devel

中间出现问题 执行以下命令:

yum remove epel-release

yum update -y

yum install epel-release

二、下载包并解压

cd /usr/local/src

wget 'https://hk1.php.net/distributions/php-5.6.40.tar.gz'

tar -zxf php-5.6.40.tar.gz

三、编译检查并安装

cd php-5.6.40

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-ctype --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --with-gettext --enable-fpm

检查没有问题就开始安装:

make && make install

cp php.ini-production /usr/local/php/etc/php.ini

四、配置PHP环境变量

vim /etc/profile

添加 export PATH=$PATH:/usr/local/php/sbin/:/usr/local/php/bin/

可重启或者source /etc/profile 生效

查看FPM 的配置情况

php-fpm -t 

 

复制配置文件

cd /usr/local/php/etc/

cp php-fpm.conf.default php-fpm.conf

 

使用systemctl 管理php

vim /usr/lib/systemd/system/php-fpm.service

添加:

[Unit]

Description=php-fpm

After=network.target

[Service]

Type=forking

ExecStart=/usr/local/php/sbin/php-fpm

[Install]

WantedBy=multi-user.target

 

注意:如果是Nginx服务器

修改 /usr/local/nginx/conf/nginx.conf 以下两处位置代码

  location / {

            root   html;

            index  index.html index.htm index.php;

        }

 

 

location ~ \.php$ {

            root           html;

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

           #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

            include        fastcgi_params;

        }

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

一勺米饭

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

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

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

打赏作者

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

抵扣说明:

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

余额充值