你好,游客 登录 注册 搜索
背景:
阅读新闻

CentOS 7.3环境下PHP7.0安装

[日期:2017-08-22] 来源:Linux社区  作者:sqtce [字体: ]

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版本

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

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款