Install nginx
Install nginx
yum install nginx
Copy the code
Start the nginx service
systemctl start nginx # start
systemctl restart nginx # to restart
systemctl stop nginx # stop
Copy the code
Install MySQL
rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
yum -y install mysql-community-server
Copy the code
After installation, start MySQL
service mysqld start
Redirecting to /bin/systemctl start mysqld.service
Copy the code
Check the MySQL status
service mysqld status
Copy the code
Setting boot
systemctl enable mysqld
systemctl daemon-reload
Copy the code
After MySQL is installed, a default password is generated. You can perform the following operations to view the default password
grep 'temporary password' /var/log/mysqld.log
Copy the code
Changing the Root Password
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassWord! ';
Copy the code
If an error message is displayed, the password does not comply with the MySQL password policy
1819 (HY000): Your password does not satisfy the current policy requirements
Copy the code
The default password policy of MySQL requires that the password must contain uppercase and lowercase letters, digits, and special characters, and be at least eight characters in length. You can use the MSYQL environment variable to view information about password policies
mysql> show variables like '%password%'; +---------------------------------------+--------+ | Variable_name | Value | +---------------------------------------+--------+ | default_password_lifetime | 0 | | disconnect_on_expired_password | ON | | log_builtin_as_identified_by_password | OFF | | mysql_native_password_proxy_users | OFF | | old_passwords | 0 | | report_password | | | sha256_password_proxy_users | OFF | | validate_password_check_user_name | OFF | | validate_password_dictionary_file | | | validate_password_length | 8 | | validate_password_mixed_case_count | 1 | | validate_password_number_count | 1 | | validate_password_policy | MEDIUM | | validate_password_special_char_count | 1 | +---------------------------------------+--------+ 14 rowsin set (0.00 sec)
Copy the code
To change the password policy, add the validate_password_policy configuration to the /etc/my.cnf file:
# select one of 0 (LOW), 1 (MEDIUM), 2 (STRONG), select 2 requires a password dictionary file
validate_password_policy=0
Copy the code
Set the default encoding to UTf8 and add the following configuration in /etc/my.cnf
character_set_server=utf8
init_connect='SET NAMES utf8'
Copy the code
Restart the MySQL
systemctl restart mysqld
Copy the code
MySQL by default only allows user root to log in locally. If you want to connect to MySQL from another machine, you must change the root permission or add a remote user. For security purposes, add a new user
mysql> GRANT ALL PRIVILEGES ON *.* TO 'jack'@The '%' IDENTIFIED BY '@jack2018' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
Copy the code
Mysql > select host, user from mysql.user where username = jack and password = @jack2018
mysql> select host,user from mysql.user; +-----------+---------------+ | host | user | +-----------+---------------+ | % | jack | | localhost | mysql.session | | localhost | mysql.sys | | localhost | root | +-----------+---------------+ 4 rowsin set (0.00 sec)
Copy the code
3. Install PHP
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 the code
Execute the command to install PHP
yum install php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_64
Copy the code
Installing PHP – FPM
yum install php70w-fpm php70w-opcache
Copy the code
Start the PHP – FPM
systemctl start php-fpm
Copy the code
To configure the nginx configuration file to support PHP, go to the nginx.conf file in the nginx installation directory and add the following configuration
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000Location ~ \.php${fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME$document_root$fastcgi_script_name;
include fastcgi_params;
}
Copy the code
Create a file under /usr/share/nginx/html
vi /usr/share/nginx/html/info.php <? php phpinfo(); ? >Copy the code
Open the browser and access http://public IP address. If the following page is displayed, the configuration is successful