MySQL installation and Configuration


1. Configure the yum source

# Update yum source

yum update         Copy the code

Download mysql source installation package

wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpmCopy the code

Install mysql source

yum localinstall mysql57-community-release-el7-8.noarch.rpmCopy the code

Check whether the mysql source is installed successfully

yum repolist enabled | grep "mysql.*-community.*"Copy the code

2. Installation of MySQL

yum install mysql-community-serverCopy the code

3. Start the MySQL


Start the MySQL service

systemctl start mysqldCopy the code

Check the MySQL startup status

systemctl status mysqldCopy the code

Set MySQL to boot

systemctl enable mysqld
systemctl daemon-reloadCopy the code

4. Change the default password of root

Find the default password for root

grep 'temporary password' /var/log/mysqld.logCopy the code

Go to the mysql console and enter the default password

mysql -uroot -pCopy the code

Set the password of the root administrator

set password for 'root'@'localhost'=password('PassWord123@'); Copy the code

By default, only the root account is allowed to log in locally. If you want to connect to mysql from other machines, you must change the root account to allow remote connection or add an account that allows remote connection

Add a remote account

GRANT ALL PRIVILEGES ON *.* TO 'yourname'@The '%' IDENTIFIED BY 'YourPassword@123' WITH GRANT OPTION;Copy the code

6. Configure the default encoding to UTf8. Modify the configuration file /etc/my. CNF, add the following two lines, utf8 encoding configuration

character_set_server=utf8 
init_connect='SET NAMES utf8'Copy the code

1. Install PHP and php-fpm

# Install ePEL first

yum -y install epel-releaseCopy the code

# install PHP php-fpm

yum -y install php php-fpmCopy the code

# Check the PHP version

php -vCopy the code

2. Install a PHP – mysql

yum install php-mysqlCopy the code

3. Set phP-FPM to automatically start upon startup

systemctl enable php-fpmCopy the code

4. Start the PHP – FPM

systemctl start php-fpmCopy the code


Nginx installation and configuration

Download the installation package

Wget HTTP: / / http://nginx.org/download/nginx-1.10.0.tar.gzCopy the code

Unzip the Nginx tar package and go to the unzip directory

The tar - ZXVF nginx - 1.10.0. Tar. GzcdNginx 1.10.0 /Copy the code

Install zlib and pcre libraries

yum -y install zlib zlib-devel
yum -y install pcre pcre-develCopy the code

Configure, compile, and install

./configure--with-http_ssl_module\
make
make installCopy the code

# start nginx

/usr/local/nginx/sbin/nginxCopy the code

The following figure shows that Nginx is running properly.

Nginx configures access to the project directory and supports PHP’s Pathinfo mode configuration

server {
        listen       80;
        server_name  xxx.xxxx.com; Your domain nameLocation / {root /var/ WWW/XXX project directory /; index index.php; } the location ~ ^ (. + \. PHP) (. *) ${root project directory/var/WWW/XXX /; Fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param PATH_INFO$fastcgi_path_info;
	    if (!-e $document_root$fastcgi_script_name) {
	        return 404;
	    }
	    fastcgi_param  SCRIPT_FILENAME$document_root$fastcgi_script_name; include fastcgi_params; }}Copy the code

Mysql -fpm systemctl start mysqld mysql -fpm systemctl start mysqld Nginx sudo fuser -k 80/ TCP # kill port 80 / usr/local/nginx/sbin/nginx # on/usr/local/nginx/sbin/nginx – # s stop stop/usr/local/nginx/sbin/nginx -s reopen # to restart / usr/local/nginx/sbin/nginx – # s reload reload the configuration file

Other problems

1. Close SELINUX(SELINUX is a security subsystem that controls applications to access only certain files. If not closed, you may have limited access to files):

vi /etc/selinux/config 
#SELINUX=enforcing #
#SELINUXTYPE=targeted
SELINUX=disabled          # increase
:wq!                      # save exit
shutdown -r now           Restart the systemCopy the code

Thinkphp error [./Runtime/] unwritable!

Chmod 777-r /var/www/ XXX Project directory /Application/RuntimeCopy the code


Benefits: This article has been synchronized to my personal technical website IT goods – Sufaith. This website includes Python, Linux, Nodejs, front-end development and other modules, focusing on the technology of program development, experience summary and sharing, welcome to visit.