Home  >  Article  >  Backend Development  >  How to install and configure PHP7 with yum

How to install and configure PHP7 with yum

藏色散人
藏色散人Original
2021-11-17 10:00:234146browse

Yum installation and configuration method for PHP7: 1. Install nginx; 2. Configure the source of PHP7 through "yum install epel-release"; 3. Officially install php7-fpm through yum; 4. Install MySQL; 5. Configure nginx; 6. Start php-fpm.

How to install and configure PHP7 with yum

The operating environment of this article: centos7 system, PHP7 version, DELL G3 computer

How to install and configure PHP7 with yum?

Centos 7 teaches you step by step how to install and configure Nginx php7-fpm MySQL using YUM method:

What you need to prepare

  • A pure system server

  • Tools for remote connection to the server (I Xshell is used here)

  • Students who need Xshell can visit my article to get it ->Click to visit

Install nginx

After connecting to the server, execute yum install nginx
How to install and configure PHP7 with yum

How to install and configure PHP7 with yum

You need to enter y here and then return Car, start installing nginx

How to install and configure PHP7 with yum

In the above picture, nginx has been installed!


Now install php7-fpm

First we Configure the source of PHP7

yum install epel-release

How to install and configure PHP7 with yum
How to install and configure PHP7 with yum

Enter y here to confirm the installation and press Enter

How to install and configure PHP7 with yum

The picture above indicates that the installation is complete!

Add the source of PHP7 below

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

How to install and configure PHP7 with yum
The picture above indicates that the addition is complete!

The following is the formal installation php7-fpm

yum install php70w-fpm php70w-cli php70w-gd php70w-mcrypt php70w-mysql php70w-pear php70w-xml php70w-mbstring php70w-pdo php70w-json php70w-pecl-apcu php70w-pecl-apcu-devel

Copy the above code and execute
How to install and configure PHP7 with yum

How to install and configure PHP7 with yum
yContinue
How to install and configure PHP7 with yum
yContinue
How to install and configure PHP7 with yum

The PHP7-FPM installation is completed!


Now install MySQL

First add the source of MySQL7

rpm -Uvh http://repo.mysql.com/mysql57-community-release-el7-7.noarch.rpm

Copy the above code and execute
How to install and configure PHP7 with yum

Add successfully!

Install MySQL

yum install mysql-server mysql-devel mysql

How to install and configure PHP7 with yum

How to install and configure PHP7 with yum
yIt will take some time to continue the MySQL installation and wait patiently

How to install and configure PHP7 with yum
yContinue
How to install and configure PHP7 with yum

The picture above indicates that the MySQL installation is complete

The configuration will be updated after time!!

The following is the configuration after installation

Configure nginx first

Enter the configuration directory of nginx/etc/nginxEdit nginx.confThis file
How to install and configure PHP7 with yum

change nginx.confDelete the contents of lines 38-57 in the file
How to install and configure PHP7 with yum

删除完成后保存即可!
下面我们在conf.d这个目录中创建站点的配置文件,例如first.conf 文件中的内容如下

server {    listen 80;
    server_name (站点域名 没有就用IP代替);
    root  /www/first(网站根目录);    index index.php index.html;
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

}

假设我们的站点配置在/www/first这个目录中(这个目录没有 需要我们自己创建)

How to install and configure PHP7 with yum
上图是创建目录

下面编辑站点文件
在站点目录下面创建index.php内容如下

<?php
    phpinfo();

下面配置php-fpm 位置在/etc/php-fpm.d/www.conf
将原来的apache改成nginx
How to install and configure PHP7 with yum

下面我们How to install and configure PHP7 with yum为nginx
How to install and configure PHP7 with yum

下面启动nginx
启动: service nginx start
停止: service nginx stop
检查配置文件是否正确: nginx -t

启动php-fpm
启动: service php-fpm start
停止: service php-fpm stop
检查配置文件是否正确: php-fpm -t
How to install and configure PHP7 with yum
两个服务都启动后就可以在浏览器中访问站点了!

下面配置MySQL

下面启动mysql
启动: service mysqld start
停止: service mysqld stop

需要先启动mysql

再查看一下mysql的默认密码

grep &#39;temporary password&#39; /var/log/mysqld.log

密码是随机的
How to install and configure PHP7 with yum

下面连接mysql
How to install and configure PHP7 with yum
使用默认密码链接成功
现在还不能进行任何操作 必须先修改密码 当前版本的mysql对密码强度要求就高

ALTER USER &#39;root&#39;@&#39;localhost&#39; IDENTIFIED BY &#39;GuYuePass666!&#39;;

下面How to install and configure PHP7 with yum

FLUSH PRIVILEGES;

How to install and configure PHP7 with yum

然后我们退出mysql重新连接就是我们设置的密码了!

到这里我们大功告成!

推荐学习:《PHP视频教程

The above is the detailed content of How to install and configure PHP7 with yum. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn