CentOS 7 configuration LNMP development environment and configuration file management details
- 2020-05-17 07:23:57
- OfStack
Install and configure MySQL 5.6
MariaDB is used by default from CentOS starting from 7.x. MariaDB is fully compatible with MySQL, including API and the command line. But a lot of times we still want to install MySQL, so we can't install it directly through the yum command.
Download the source installation file
wget http://repo.mysql.com//mysql57-community-release-el7-8.noarch.rpm
Install the rpm package locally (configure the MySQL installation source)
yum -y localinstall mysql57-community-release-el7-8.noarch.rpm
View all MySQL installation sources (default MySQL installation version 5.7)
yum repolist all | grep mysql
Shut down the MySQL 5.7 installation source
sudo yum-config-manager --disable mysql57-community
Open the MySQL 5.6 installation source
sudo yum-config-manager --enable mysql56-community
No yum config - manager command can install yum install yum - utils. noarch tool or edit/etc/yum repos. d/mysql - community. enable repo file for 1 is open, closed to 0 said
Install MySQL
yum -y install mysql-devel mysql-community-server
Start the MySQL
systemctl start mysqld.service
Security configuration MySQL
mysql_secure_installation
Install and configure PHP 5.6
In version 7.1 of CentOS, PHP is installed as PHP5.4 by default, where php-mysqlnd is the MYSQL driver database provided by PHP source code.
Many times a new version is required for the PHP environment, such as the PHP5.6 environment, to record a way to install the latest version of PHP through the yum tool. First, you need to install an extended yum source, the epel source, on your system. From http: / / fedoraproject org/wiki/EPEL website to download and install. (note: if the article is too long, you may need to find a new download link.)
Download the source installation file
wget https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
Local installation (similar to the MySQL installation source command above)
rpm -ivh epel-release-7-8.noarch.rpm
Then, also need a REMI source, this yum source provides the latest PHP version to download and install, its website http: / / rpms famillecollet. com /. The procedure for installing the REMI source is as follows.
Import the gpg validation file
yum -y localinstall mysql57-community-release-el7-8.noarch.rpm
0
Download the source installation file
yum -y localinstall mysql57-community-release-el7-8.noarch.rpm
1
The local installation
yum -y localinstall mysql57-community-release-el7-8.noarch.rpm
2
By default, REMI is disabled to prevent conflicts between multiple yum sources. You can check if the REMI source was installed successfully with the command
yum repolist disabled | grep remi
Install the required version of PHP from the REMI source and install PHP5.6.
yum -y localinstall mysql57-community-release-el7-8.noarch.rpm
4
Install php - fpm
yum -y localinstall mysql57-community-release-el7-8.noarch.rpm
5
Open php - fpm
yum -y localinstall mysql57-community-release-el7-8.noarch.rpm
6
Install and configure Nginx
Import the gpg validation file
yum -y localinstall mysql57-community-release-el7-8.noarch.rpm
7
Download the source installation file (configure the Nginx installation source). From http: / / nginx org/packages/centos/web site to download the installation source. (note: if the article is too long, you may need to find a new download link.)
wget http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.10.0-1.el7.ngx.x86_64.rpm
The local installation
yum -y localinstall mysql57-community-release-el7-8.noarch.rpm
9
Install Nginx
yum install nginx
Open Nginx
systemctl start nginx
Nginx host configuration (php-fpm)
Edit/etc/nginx/conf d/default conf configuration files, and restart.
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
root /usr/share/nginx/html;
index index.html index.htm index.php;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}