阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

CentOS 7.3环境下PHP7.0安装

136次阅读
没有评论

共计 3006 个字符,预计需要花费 8 分钟才能阅读完成。

CentOS 7.3 环境下 PHP7.0 安装

一、安装相关的依赖:
# yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel MySQL pcre-devel
# yum -y install curl-devel
# yum -y install libxslt-devel
#yum install openssl openssl-devel
下载
#wget http://at1.php.net/distributions/php-7.0.2.tar.gz

二,解压安装
# tar -zxvf php-7.0.2.tar.gz
# cd php-7.0.2
# ./configure –prefix=/usr/local/php  –with-curl  –with-freetype-dir  –with-gd  –with-gettext  –with-iconv-dir  –with-kerberos  –with-libdir=lib64  –with-libxml-dir  –with-mysqli  –with-openssl  –with-pcre-regex  –with-pdo-mysql  –with-pdo-sqlite  –with-pear  –with-png-dir  –with-xmlrpc  –with-xsl  –with-zlib  –enable-fpm  –enable-bcmath  –enable-libxml  –enable-inline-optimization  –enable-gd-native-ttf  –enable-mbregex  –enable-mbstring  –enable-opcache  –enable-pcntl  –enable-shmop  –enable-soap  –enable-sockets  –enable-sysvsem  –enable-xml  –enable-zip
# make &&  make install

三,配置文件
# cp php.ini-development /usr/local/php/lib/php.ini
# 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
# cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm
需要注意的是 php7 中 www.conf 这个配置文件配置 phpfpm 的端口号等信息,如果你修改默认的 9000 端口号需在这里改,再改 nginx 的配置
启动
#  /etc/init.d/php-fpm

四,安装 Nginx
#yun install nginx
查看 Nginx 安装路径
#rpm -ql nginx

五,查看 PHP 安装版本
进入 Nginx 存放页面目录

#cd /usr/share/nginx/html
#vim index.php
      <?php phpinfo(); ?>

六,配置 Nginx
#vim /etc/nginx/nginx.conf
在配置文件的 server 中加入以下配置
        location ~ \.php$ {
          root /usr/share/nginx/html; #指定 php 的根目录
          fastcgi_pass 127.0.0.1:9000;#php-fpm 的默认端口是 9000
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          include fastcgi_params;
        }
重新加载 Nginx
#/usr/sbin/nginx  -s reload
通过浏览器就可以查看 PHP 版本

CentOS 7.3 环境下 PHP7.0 安装

PHP 支持开机启动

CentOS 7 的服务 systemctl 脚本存放在:/usr/lib/systemd/,有系统(system)和用户(user)之分,像需要开机不登陆就能运行的程序,最好还是存在系统服务里面,即:/usr/lib/systemd/system 目录下,每一个服务以.service 结尾,一般会分为 3 部分:[Unit]、[Service]和 [Install]
我们可以使用 systemctl - a 来查看所有服务,如果列表里面没有 PHP,又想借助于 systemctl 来进行统一管理的话,就到上述所说的 /usr/lib/systemd/system 目录下面创建以下文件吧
PHP 之 php-fpm.service 文件
vim /usr/lib/systemd/system/php-fpm.service

[Unit]

Description=php

After=network.target

[Service]

Type=forking

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

ExecStop=/bin/pkill -9 php-fpm

PrivateTmp=true

[Install]

WantedBy=multi-user.target

#  systemctl restart php-fpm.service
#  systemctl enable php-fpm.service

Red Hat Enterprise Linux 7.3 下 PHP 安装  http://www.linuxidc.com/Linux/2017-05/143942.htm

Ubuntu 16.04 环境中安装 PHP7.0 Redis 扩展 http://www.linuxidc.com/Linux/2016-09/135631.htm

在 CentOS 7.x / Fedora 21 上面体验 PHP 7.0  http://www.linuxidc.com/Linux/2015-05/117960.htm 

CentOS 7 下 PHP 5.6.19 编译安装详解  http://www.linuxidc.com/Linux/2017-03/142002.htm

PHP 源码安装、简单配置、测试及连接数据库 http://www.linuxidc.com/Linux/2016-10/135977.htm

《细说 PHP》高清扫描 PDF+ 光盘源码 + 全套教学视频 http://www.linuxidc.com/Linux/2014-03/97536.htm 

CentOS 7 编译安装 PHP 5.6  http://www.linuxidc.com/Linux/2017-08/146095.htm

CentOS 7.2 下编译安装 PHP7.0.10+MySQL5.7.14+Nginx1.10.1  http://www.linuxidc.com/Linux/2016-09/134804.htm

PHP 的详细介绍:请点这里
PHP 的下载地址:请点这里

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-08/146433.htm

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-21发表,共计3006字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中