CENTOS7 lnmp+phpmyadmin Environment Construction (second, LNMP environment construction)

Source: Internet
Author: User
Tags mysql login phpmyadmin

Previous blog We installed the CENTOS7 on the virtual machine, and then we started to install the LNMP environment.

Same as before, after entering the command line, first use the SU command to switch to root permissions.

Configure the firewall first
CentOS 7.0 defaults to using firewall as the firewall
1. Close the firewall:

    Systemctl Stop Firewalld.service #停止firewall      systemctl Disable Firewalld.service #禁止firewall开机启动  

2. Turn off SELinux:

vi/etc/selinux/Config  
#SELINUX =enforcing #注释掉  selinux=disabled #增加  : wq! #保存退出  setenforce 0 #使配置立即生效

3. Installing priorities and wget

Yum Install yum-priorities-y install wget

1. Install MySQL

Download MySQL Source installation package

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

Install MySQL source

Yum Localinstall mysql57-community-release-el7-8

Check that the MySQL source is installed successfully , and note the order number in the command.

" mysql.-community. "

Install MySQL

Yum Install Mysql-community-server

Start the MySQL service and it may be slower to start the service because of different computer configurations.

to view the startup status of MySQL

Systemctl Status Mysqld

Boot up

systemctl enable mysqld systemctl daemon-reload

Check the root local login password (This command will find the default random password for MySQL settings, e.g., my random password is t3e4woyyi=:y)

' Temporary password ' /var/log/mysqld.log

Login to MySQL by random password (random password is difficult to identify, more than a few times, I was on the landing because of the wrong password to try two times before success)

Modify the MySQL login password (note Do not miss the semicolon, this is the MySQL statement, after the modification is completed using exit after the login again)

' Root '@'localhost'='Chen123456. ";
Exit

Note: mysql5.7 The password security check plug-in (Validate_password) is installed by default, and the default password check policy requires that the password must contain: uppercase and lowercase letters, numbers, and special symbols, and not less than 8 bits in length. Otherwise you will be prompted for error 1819 (HY000): Your password does not satisfy the current policy requirements error as follows:

ALTER USER ' root ' @ ' localhost ' identified by ' mynewpass4! ';
Set password for ' root ' @ ' localhost ' =password (' mynewpass4! ');
You can view information about the password policy through the MSYQL environment variable:
Mysql> Show variables like '%password% ';

if the above method cannot be modified, you can use the following Safe mode to modify root:
Close Service
systemctl Stop Mysqld.service
vi/etc/my.cnf
mysqld below add skip-grant-tables Save exit start service
systemctl start Mysqld.service
mysql-u root without a password to enter directly
Use MySQL
Update user Set Authentication_string=password (' Root-123 ') where user= ' Root ' and host= ' localhost ';
flush Privileges;
exit;
vi/etc/my.cnf skip-grant-tables A sentence delete save to quit restarting the MySQL service
systemctl Restart Mysqld.service
Log in again
mysql-u root-proot-123

If you do, the following prompt appears:
You must reset your password using ALTER USER statement before executing thisstatement.
I'll set the password again.
Set password = password (' Root-123 ');

Open 3306 port (allows you to connect to MySQL server from any host using the username root password Root-123456)

Mysql>grant all on root.* to [email protected]'%'[email protected]# 456VMROOT';
Mysql>flush privileges;
mysql>exit;

Turn on external access to the firewall MySQL 3306 port

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

Configure default encoding to UTF8

Vi/etc/my.cnf

Modify the /etc/my.cnf configuration file and add the encoding configuration under [Mysqld] as follows:
[Mysqld]
Character_set_server=utf8
init_connect= ' SET NAMES UTF8 '

Default configuration file path:
Configuration file:/etc/my.cnf
Log file:/var/log//var/log/mysqld.log
Service startup script:/usr/lib/systemd/system/mysqld.service
Socket file:/var/run/mysqld/mysqld.pid

If you want to use a firewall, it is recommended that you configure the following methods:

Close Firewall :

Systemctl Stop Firewalld.service #停止firewallsystemctl disable Firewalld.service #禁止firewall开机启动

installation iptables Firewall:

Yum install iptables-/etc/sysconfig/iptables #编辑防火墙配置文件

The configuration file changes as follows:

# Firewall configuration written by system-config-firewall# Manual Customization of ThisFile isNot recommended.*filter:input ACCEPT [0:0]:forward ACCEPT [0:0]:output ACCEPT [0:0]-A input-m state--state established,related-J ACCEPT-A input-p ICMP-J ACCEPT-A input-i lo-J ACCEPT-A input-m state--state new-m tcp-p TCP--dport A-J ACCEPT//here is the section that the editor adds-A input-m state--state new-m tcp-p TCP--dport the-J ACCEPT-A input-m state--state new-m tcp-p TCP--dport3306-J ACCEPT//The above is the part that the editor adds-A input-j REJECT--reject-with icmp-host-prohibited-A forward-j REJECT--reject-with icmp-host-Prohibitedcommit then enter: Wq Save to exit, enter the following command in the Command window to make it effective: Systemctl restart Iptables.service #最后重启防火墙使配置生效systemctl enable Iptables.service #设置防火墙开机启动

2. Turn off SELinux

command line, enter the following to open the SELinux configuration file:

sudo vi/etc/selinux/config

Modify the content as follows

#SELINUX =enforcing #注释掉 #SELINUXTYPE=targeted #注释掉 SELINUX=disabled #增加

input : wq! # Save Exit , The command line then enters the following to make it effective

0 #使配置立即生效

2. Install PHP

Yum has a lower version of PHP installed by default, this time we are ready to install the php5.6 version, so we need to install the Epel library first and then install PHP.

Yum Install Epel-release
RPM-IVH http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

Yum install--enablerepo=remi--enablerepo=remi-php56 php php-opcache php-fpm php-devel php-mbstring php-mcrypt Php-mysqlnd Php-phpunit-phpunit Php-pecl-xdebug php-pecl-xhprof

After the installation is complete, typing php-v will show the PHP version, which means that we have completed the installation of PHP.

Php-v

3. Installing Nginx

wget http://nginx.org/packages/centos/7/noarch/rpms/nginx-release-centos-7-0.el7.ngx.noarch.rpm
RPM-IVH nginx-release-centos-7-0.el7.ngx.noarch.rpm

and start the Nginx.

Systemctl start Nginx.service #启动nginx  systemctl stop nginx.service #停止  systemctl restart Nginx.service #重启  Systemctl Enable Nginx.service #设置开机启动

. Change the Nginx port number (depending on your needs)

cd /etc/nginx/conf. D
vim default. conf
改成  81
然后重启

systemctl restart nginx. Service #重启nginx

At this point we open the browser, access to localhost if Welcome to nginx! appears, then the installation of Nginx is successful

Nginx installation is complete, then the configuration is PHP-FPM. Let Nginx and PHP linkage together.

Open PHP-FPM configuration file

sudo vi/etc/php-fpm.d/www.conf

Modify the following (find the configuration item here, you can use the slash plus the keyword to find the return lookup, as shown in)

Listen.owner ==0666

Finally, after modifying the three parameters: Wq exit and restart the PHP-FPM service

sudo systemctl start php-fpm    #启动php-fpmsudo systemctl enable PHP-fpm   #开机启动fpm

We then modify the Nginx configuration by using the Find command to locate the configuration file location, where my profile location is

Find/-name nginx.conf

Then, using the VI command to enter the view, the last line found this configuration file and introduced another configuration file.

Vi/etc/nginx/nginx.conf

Enter this directory again to discover configuration files such as

Modify it with the VI command

default. conf

Add a sibling under LocalHost, as shown in

Location ~/var/www/127.0. 0.1:9000;the default port for #php-FPM is 9000fastcgi_index index.php;fastcgi_param script_filename $document _ Root$fastcgi_script_name;include Fastcgi_params;}

After the modification is saved, use the NGINX-T command to confirm that the format is error-free and then restart Nginx. As shown

Nginx-s Reload

Then, in the PHP directory you just set up, create a new PHP file for testing.

Establish index.php in/var/www/html

<?php

Phpinfo ();

Then we visit localhsot/index.php if we see the following screen, our nginx PHP is already connected.

At this point, LNMP has been installed to complete, this blog has been long enough, the next blog, we will install phpMyAdmin.

CENTOS7 lnmp+phpmyadmin Environment Construction (second, LNMP environment construction)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.