LNMP架构超详细教程(二)PHP安装教程

1】进入官网下载源码包

在浏览器搜索php,进入php官网,然后选择download,因为高版本我在测试时bug比较多,因此这里我选择,安装php-5.6.36.tar.gz


选择镜像源,这里我择香港也就是下图标记处选择一个网址下载。

然后弹出下面的对话框,选择save File即可。

2】解压

[root@server1 ~]# tar zxf php-5.6.36.tar.gz

3】下载需要的依赖包

https://pkgs.org/网站搜索gd-devel然后根据自己系统选择rpm包版本并下载。

我下载的rpm包为:gd-devel-2.0.35-26.el7.x86_64.rpm,利用同样的方式下载下面三个软件安装包,并将yum源设置为你电脑系统的镜像。

libmcrypt-2.5.8-13.el7.x86_64.rpm
libmcrypt-devel-2.5.8-13.el7.x86_64.rpm
re2c-0.14.3-2.el7.x86_64.rpm

4】安装依赖软件

[root@server1 ~]# yum install -y gd-devel-2.0.35-26.el7.x86_64.rpm \
> libmcrypt-2.5.8-13.el7.x86_64.rpm \
> libmcrypt-devel-2.5.8-13.el7.x86_64.rpm \
> re2c-0.14.3-2.el7.x86_64.rpm \
> libxml2-devel \
> openssl-devel \
> curl-devel \
> gmp-devel \
> net-snmp-devel

5】预编译

[root@server1 php-5.6.36]# ./configure --prefix=/usr/local/lnmp/php \
> --with-config-file-path=/usr/local/lnmp/php/etc  --enable-mysqlnd \
> --with-mysqli=mysqlnd  --with-pdo-mysql=mysqlnd \
> --with-openssl  --with-snmp  --with-gd  --with-zlib  --with-curl \
> --with-libxml-dir  --with-png-dir  --with-jpeg-dir  --with-freetype-dir  --with-pear \
> --with-gettext  --with-gmp  --enable-inline-optimization  --enable-soap \
> --enable-ftp  --enable-sockets  --enable-mbstring  --enable-fpm \
> --with-fpm-user=nginx  --with-fpm-group=nginx   --with-mhash

6】编译并安装

[root@server1 php-5.6.36]#make && make install

7】配置

[root@server1 ~]# cd php-5.6.36
[root@server1 php-5.6.36]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@server1 php-5.6.36]# chmod +x /etc/init.d/php-fpm
[root@server1 php-5.6.36]# cp php.ini-production /usr/local/lnmp/php/etc/php.ini

php.ini文件里的timezone改成上海如下图:

[root@server1 etc]# pwd
/usr/local/lnmp/php/etc
[root@server1 etc]# cp php-fpm.conf.default php-fpm.conf

php-fpm.conf文件下图标记处的分号删除:

这样环境已经配置好了。

8】开启服务

[root@server1 etc]# /etc/init.d/php-fpm start
Starting php-fpm  done
[root@server1 etc]# netstat -antlupe | grep 9000
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      0          150407     20611/php-fpm: mast

这样lnmp架构的php环境已经配置好了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值