Home >Backend Development >PHP Tutorial >Detailed configuration tutorial for php7, apache, CentOS7 and mysql5.7

Detailed configuration tutorial for php7, apache, CentOS7 and mysql5.7

黄舟
黄舟Original
2017-10-10 09:14:471819browse

This article mainly introduces the detailed configuration tutorial of CentOS7+apache+php7+mysql5.7. Friends in need can refer to it

 yum upgrade
yum install net-tools

Install apache

Close SELinux

Open the etc/selinux/config file in the editor, find the SELINUX=enforcing field, change it to SELINUX=disabled, and restart the device.

yum -y install httpd mod_ssl

Configure the firewall

firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --add-port=443/tcp
firewall-cmd --reload

Start up after booting up

systemctl start httpd
systemctl enable httpd

Enter the following command in the terminal to check the running status of httpd

sudo systemctl status httpd

Install PHP7

Add source

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

Install

yum install php70w

Install mysql5. 7

1. Install wget

  yum -y install wget

2. Install source

 wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
  rpm -ivh mysql57-community-release-el7-8.noarch.rpm

3. Install mysql

  yum install mysql-server

4. Start the mysql service

 systemctl start mysqld

5. Check the startup status of MySQL

 systemctl status mysqld

6. Start up

 systemctl enable mysqld
  systemctl daemon-reload

7. Modify the root local login password

Find the random password generated by mysql

 grep 'temporary password' /var/log/mysqld.log
  mysql -uroot -p

Modify the password, note: mysql5.7 is installed by default With the password security check plug-in (validate_password), the default password check policy requires that the password must contain: uppercase and lowercase letters, numbers and special symbols, and the length must not be less than 8 characters. Otherwise, ERROR 1819 (HY000): Your password does not satisfy the current policy requirements error

  ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

8 will be prompted. The default encoding of the configuration is utf8

Modify the /etc/my.cnf configuration file and add encoding configuration under [mysqld]

 [mysqld]
  character_set_server=utf8
  init_connect='SET NAMES utf8'

9. Configure mysql remote connection

  mysql -uroot -p
  use mysql;
  Grant all on *.* to 'root'@'%' identified by 'root用户的密码' with grant option;
flush privileges;

Then use the following command to check which users and hosts can access, % represents any ip address

select user,host from user;

Add 3306 port to firewall

firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload

10.mysql forgot password

1. Modify the MySQL configuration file (default is /etc/my .cnf), add a line skip-grant-tables

2.service mysqld restart under [mysqld], you can directly use mysql to enter

3.

mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';
  mysql> flush privileges;
  mysql> quit;

Restore the /etc/my.cnf file and restart mysql:service mysql restart. At this time, you can use mysql -u root -p'123qwe' to enter

mysql>SET PASSWORD = PASSWORD('newpasswd'); Set a new password

Summary

The above is the detailed content of Detailed configuration tutorial for php7, apache, CentOS7 and mysql5.7. 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