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

黄舟
Release: 2023-03-16 15:00:01
Original
1641 people have browsed it

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
Copy after login

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
Copy after login

Configure the firewall

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

Start up after booting up

systemctl start httpd
systemctl enable httpd
Copy after login

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

sudo systemctl status httpd
Copy after login

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
Copy after login

Install

yum install php70w
Copy after login

Install mysql5. 7

1. Install wget

  yum -y install wget
Copy after login

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
Copy after login

3. Install mysql

  yum install mysql-server
Copy after login

4. Start the mysql service

 systemctl start mysqld
Copy after login

5. Check the startup status of MySQL

 systemctl status mysqld
Copy after login

6. Start up

 systemctl enable mysqld
  systemctl daemon-reload
Copy after login

7. Modify the root local login password

Find the random password generated by mysql

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

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!';
Copy after login

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'
Copy after login

9. Configure mysql remote connection

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

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

select user,host from user;
Copy after login

Add 3306 port to firewall

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

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;
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!