Home > Article > Backend Development > How to install and configure PHP7 with yum
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.
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:
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
After connecting to the server, execute yum install nginx
You need to enter y
here and then return Car, start installing nginx
In the above picture, nginx has been installed!
First we Configure the source of PHP7
yum install epel-release
Enter y
here to confirm the installation and press Enter
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
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
y
Continue
y
Continue
The PHP7-FPM installation is completed!
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
Add successfully!
Install MySQL
yum install mysql-server mysql-devel mysql
y
It will take some time to continue the MySQL installation and wait patiently
y
Continue
The picture above indicates that the MySQL installation is complete
The configuration will be updated after time!!
Enter the configuration directory of nginx/etc/nginx
Edit nginx.conf
This file
change nginx.conf
Delete the contents of lines 38-57
in the file
删除完成后保存即可!
下面我们在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
这个目录中(这个目录没有 需要我们自己创建)
上图是创建目录
下面编辑站点文件
在站点目录下面创建index.php
内容如下
<?php phpinfo();
下面配置php-fpm 位置在/etc/php-fpm.d/www.conf
将原来的apache改成nginx
下面我们How to install and configure PHP7 with yum为nginx
下面启动nginx
启动: service nginx start
停止: service nginx stop
检查配置文件是否正确: nginx -t
启动php-fpm
启动: service php-fpm start
停止: service php-fpm stop
检查配置文件是否正确: php-fpm -t
两个服务都启动后就可以在浏览器中访问站点了!
下面启动mysql
启动: service mysqld start
停止: service mysqld stop
需要先启动mysql
再查看一下mysql的默认密码
grep 'temporary password' /var/log/mysqld.log
密码是随机的
下面连接mysql
使用默认密码链接成功
现在还不能进行任何操作 必须先修改密码 当前版本的mysql对密码强度要求就高
ALTER USER 'root'@'localhost' IDENTIFIED BY 'GuYuePass666!';
下面How to install and configure PHP7 with yum
FLUSH PRIVILEGES;
然后我们退出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!