centos6 安装php7语言

一、环境

Linux操作系统:centos6.9

 

二、安装步骤

1、 添加php的yum软件仓库

[root@VM_0_11_centos ~]# rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

2、 安装php相关软件

[root@VM_0_11_centos ~]# yum install php71w.x86_64 php71w-cli.x86_64 php71w-common.x86_64 php71w-gd.x86_64 php71w-ldap.x86_64 php71w-mbstring.x86_64 php71w-mcrypt.x86_64 php71w-mysql.x86_64 php71w-pdo.x86_64

如果出现以下错误 :

Transaction Check Error:
  file /usr/share/mysql/charsets/Index.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/armscii8.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/ascii.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/cp1250.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/cp1256.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/cp1257.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/cp850.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/cp852.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/cp866.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/dec8.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/geostd8.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/greek.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/hebrew.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/hp8.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/keybcs2.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/koi8r.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/koi8u.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/latin1.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/latin2.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/latin5.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/latin7.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/macce.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/macroman.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/charsets/swe7.xml from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/czech/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/danish/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/dutch/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/english/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/estonian/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/french/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/german/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/greek/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/hungarian/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/italian/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/japanese/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/korean/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/norwegian-ny/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/norwegian/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/polish/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/portuguese/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/romanian/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/russian/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/serbian/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/slovak/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/spanish/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/swedish/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64
  file /usr/share/mysql/ukrainian/errmsg.sys from install of mysql-libs-5.1.73-8.el6_8.x86_64 conflicts with file from package MySQL-server-5.6.40-1.el6.x86_64

Error Summary
-------------

表示已存在MySQL的库所以需要先删除以前的库才能安装!

查看MySQL的库

[root@VM_0_11_centos ~]# rpm -qa|grep MySQL
MySQL-server-5.6.40-1.el6.x86_64
MySQL-client-5.6.40-1.el6.x86_64

删除以上已安装的库

[root@VM_0_11_centos ~]# rpm -e MySQL-client-5.6.40-1.el6.x86_64
[root@VM_0_11_centos ~]# rpm -e MySQL-server-5.6.40-1.el6.x86_64

然后重新执行yum install 那里

3、 安装php71-fpm

[root@VM_0_11_centos ~]# yum install php71w-fpm.x86_64

4、 查看php是否安装成功

[root@VM_0_11_centos ~]# php -v
PHP 7.1.18 (cli) (built: Jun  2 2018 07:10:30) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

三、搭建php+nginx

1、 安装nginx

教程: https://blog.csdn.net/wawawawawawaa/article/details/81152654

2、 配置nginx与php的关联

     打开nginx配置文件,修改或添加下列语句

                            centos6 安装php7语言_第1张图片

location ~ \.php$ {
        root           /var/nginx;
        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;
    }

3、 重启nginx

[root@VM_0_11_centos ~]# service nginx restart
Stopping nginx:                                            [  OK  ]
Starting nginx:                                            [  OK  ]

4、 查看php-fpm是否正常运行

[root@VM_0_11_centos nginx]# ps aux |grep php                  
root     15668  0.0  0.3 280332  5792 ?        Ss   16:23   0:00 php-fpm: master process (/etc/php-fpm.conf)
apache   15670  0.0  0.3 280396  6236 ?        S    16:23   0:00 php-fpm: pool www            
apache   15671  0.0  0.3 280396  6236 ?        S    16:23   0:00 php-fpm: pool www            
apache   15672  0.0  0.3 280396  6236 ?        S    16:23   0:00 php-fpm: pool www            
apache   15673  0.0  0.3 280396  6244 ?        S    16:23   0:00 php-fpm: pool www            
apache   15674  0.0  0.3 280396  6244 ?        S    16:23   0:00 php-fpm: pool www            
root     15725  0.0  0.0 103336   848 pts/2    S+   16:23   0:00 grep php

以上为正常运行,如果没有,则重新启动服务

[root@VM_0_11_centos nginx]# service php-fpm restart 

将php-fpm服务设置开机自动启动

[root@VM_0_11_centos ~]# chkconfig --add php-fpm

5、 访问php

在/var/nginx 目录下创建index.php文件

[root@VM_0_11_centos ~]# vi /var/nginx/index.php

添加以下内容:

打开浏览器, 输入服务器ip地址+端口/index.php

centos6 安装php7语言_第2张图片

你可能感兴趣的:(服务器配置)