CentOs7 builds PHP environment

Tip: The wget download URL prompts that the SSL connection cannot be established. Perform the following tutorial operations

https://blog.csdn.net/xinghun_4/article/details/50500331

reboot 重启虚拟机
  1. One-click installation of all compilation tools gcc
yum groupinstall "Development Tools" "Server Platform Development" -y 
  1. Yum add Epel source
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm
yum repolist      ##检查是否已添加至源列表
  1. Install Nginx
yum -y install nginx   使用yum安装nginx
systemctl start nginx  启动nginx,浏览器输入ip就可以看到nginx的欢迎页

3.1 Modify the Nginx configuration file to support PHP parsing

nginx配置文件默认放在/etc/nginx/nginx.conf
vi /etc/nginx/nginx.conf
在server区间里加入以下内容
注释掉本来的这两行 
        # location / { 
        #  } 
 location / { 
        root   /usr/share/nginx/html; 
        index  index.php index.html index.htm; 
    } 
  location ~ \.php$ { 
         root           html; 
         fastcgi_pass   127.0.0.1:9000; 
         fastcgi_index  index.php; 
         fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name; 
         include        fastcgi_params; 
     } 
systemctl restart nginx 重启nginx
  1. Install PHP
检查当前安装的PHP包
    yum list installed | grep php
如果有安装的PHP包,先删除他们
(这条命令看情况执行看清楚你安装的包用yum remove删除)
 yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_643

4.1 Add PHP's yum source

Centos 5.X
rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm

CentOs 6.x
  rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm

  CentOs 7.X
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
或者使用wget
wget https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -ivh epel-release.rpm

If you want to delete the Yum source package installed above, reinstall it

rpm -qa | grep webstatic
rpm -e  上面搜索到的包即可

4.2 Choose what version of PHP you want to install

php5.6
yum install php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64

php5.5
yum install php55w.x86_64 php55w-cli.x86_64 php55w-common.x86_64 php55w-gd.x86_64 php55w-ldap.x86_64 php55w-mbstring.x86_64 php55w-mcrypt.x86_64 php55w-mysql.x86_64 php55w-pdo.x86_64

php7
    yum install php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_64

4.2 Install PHP-FPM

5.5
yum install php55w-fpm 
5.6
yum install php56w-fpm 
7.0
yum install php70w-fpm

start php-fpm

systemctl start php-fpm 

configure php.ini

vi /etc/php.ini 
按下esc进入命令模式,输入:/cgi.fix_pathinfo,按n
进行下一个查找,找到指定cgi.fix_pathinfo, 修改为=0
  1. Install Mysql I don't put mariadb directly mysql
yum –y install mysql
yum –y install mysql-devel

添加官方mysql-server的yum源
 wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm 

installation source

 rpm -ivh mysql-community-release-el7-5.noarch.rpm 
安装mysql-server
 yum install mysql-community-server 

start mysql

systemctl restart mysqld

If there is a firewall, open ports 80 and 3306

centos7用的是firewall
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=3306/tcp --permanent

reload firewall

firewall-cmd --reload

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324428049&siteId=291194637