Installation configuration code for apache php7 and mysql5.7 on CentOS7 servers

  • 2020-06-19 12:29:56
  • OfStack

The configuration codes for apache, php7, and mysql5.7 in CentOS7 servers are as follows:


yum upgrade
yum install net-tools

Install apache


 Shut down SELinux
 Editor open  etc/selinux/config  File, find  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
 Powered up 
systemctl start httpd
systemctl enable httpd
 Terminal input the following instructions check httpd Running state 
sudo systemctl status httpd

Install PHP7


 Add the 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
 The installation 
yum install php70w

Install mysql5. 7


1. The installation wget
  yum -y install wget
2. The installation source 
  wget https://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
  rpm -ivh mysql57-community-release-el7-8.noarch.rpm
3. The installation mysql
  yum install mysql-server
4. Start the mysql service 
  systemctl start mysqld
5. To view MySQL Startup state 
  systemctl status mysqld
6. Powered up 
  systemctl enable mysqld
  systemctl daemon-reload
7. Modify the root Local login password 
   To find the mysql Generated random password 
  grep 'temporary password' /var/log/mysqld.log
  mysql -uroot -p
   To change the password, note: mysql5.7 The password security check plug-in ( validate_password ), the default password checking policy requires passwords to contain: upper and lower case letters, Numbers, and special symbols, and to be no less than length 8 position Otherwise it will prompt ERROR 1819 (HY000): Your password does not satisfy the current policy requirements error 
  ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!'; 
8. The default encoding of the configuration is utf8
   Modify the /etc/my.cnf Configuration file in [mysqld] Next add the encoding configuration 
  [mysqld]
  character_set_server=utf8
  init_connect='SET NAMES utf8'
9. configuration mysql The remote connection 
  mysql -uroot -p
  use mysql;
  Grant all on *.* to 'root'@'%' identified by 'root User's password ' with grant option;
flush privileges;
 Then use the following command to see which users and host You can access, % On behalf of any ip address 
select user,host from user;
 Firewall addition 3306 port 
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 ) , in [mysqld] add 1 line skip-grant-tables
2.service mysqld restart After, can be used directly mysql Enter the 
3.mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';
  mysql> flush privileges;
  mysql> quit;
  will /etc/my.cnf File restore, restart mysql:service mysql restart, It can be used at this point mysql -u root -p'123qwe' Into the 
 mysql>SET PASSWORD = PASSWORD('newpasswd');  Set a new password 

conclusion


Related articles: