1. 下载nginx:http://nginx.org/en/download.html
2. Create a new lnmp folder in the usr/local folder, download the nginx compressed package and unzip it
[root@VM_48_141_centos ~]# cd usr/local
[root@VM_48_141_centos local]# mkdir lnmp
[root@VM_48_141_centos local]# cd lnmp
[root@VM_48_141_centos lnmp]# wget http://nginx.org/download/nginx-1.12.2.tar.gz
[root@VM_48_141_centos nginx-1.12.2]# ./configure --prefix=/usr/local/lnmp/nginx
error
Reason: There is no compiled library for gcc
Solution: [root@VM_48_141_centos nginx-1.12.2]# yum install gcc gcc-c++ kernel-devel
continue, error again
Reason: no regular library
Solution: [root@VM_48_141_centos nginx-1.12.2]# yum install pcre-devel
continue, error again
Reason: no zlib library
Solution: [root@VM_48_141_centos nginx-1.12.2]# yum install -y zlib-devel
continue, OK
3. Compile and install [root@VM_48_141_centos nginx-1.12.2]# make && make install
4 Start nginx
[root@VM_48_141_centos lnmp]# cd Nginx
Enter the installation directory you just customized. Nginx has 4 folders.
conf: configuration file html: web page file logs: log file sbin: main process file
[root@VM_48_141_centos Nginx]# ./sbin/nginx
Access in your browser:
Shut down Nginx : [root@VM_48_141_centos Nginx]# kill -INT 28024
View the nginx main process number: [root@VM_48_141_centos Nginx]# ps aux|grep nginx
Intermediate commands
grep 'nginx' /etc/group
awk -F":" '{print $1"\t\t"$4}' /etc/passwd | grep '1000'
Nginx.Conf
#user nobody;
// global area
work_processes 1 ; // There is a working child process, which can be modified by yourself, but it is too big and useless, because it is necessary to compete for CPU, generally set to the number of CPUs * the number of cores
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
// Generally configure the characteristics of nginx connection
/ / How many connections can a word allow at the same time
worker_connections 1024; // This refers to a child process that allows a maximum of 1024 connections
}
http { // This is the main section for configuring the http server
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index ab.html index.html index.htm;
}
#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 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 /scripts$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;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
2. Install mysql
[root@VM_48_141_centos logs]# yum -y install mysql-server mysql mysql-devel
Then I spent an afternoon changing mysql, not mysql , but mariadb
1. Uninstall: yum autoremove mysql -y
2.wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
3.yum localinstall mysql57-community-release-el7-11.noarch.rpm
4.yum repolist enabled | grep "mysql.*-community.*"
5.yum install mysql-community-server -y
6. Start mysql and view its status
Command: systemctl start mysqld
Command: systemctl status mysqld
7. Set mysql as a system service and start with the system startup
命令:systemctl enable mysqld
命令:systemctl daemon-reload
8. View the default password of the root account under mysql
After mysql5.7 is installed, a default password is generated for root in the /var/log/mysqld.log file . Find the root default password in the following way, and then log in to mysql .
Command: grep 'temporary password' /var/log/mysqld.log
The Jb2h<%lp9itY part is the default password
9.2. Modify the my.cnf file (/etc/my.cnf)
9.2.1. Modify password policy
There are three password policies for MySQL :
0或LOW:Length
1或MEDIUM:Length; numeric, lowercase/uppercase, and special characters
2或STRONG:Length; numeric, lowercase/uppercase, and special characters; dictionary file
Add the following settings to the mysql configuration file my.cnf file
#If password policy is not required, disable password policy
validate_password = off
#Password selection policy 0-LOW , 1-MEDIUM , 2-STRONG need to provide password dictionary file
validate_password_policy = 0
9.2.2. Modify character encoding to utf8
Add the following configuration under [mysqld] in my.cnf
character_set_server = utf8
init_connect = 'SET NAMES utf8'
Command: systemctl restart mysqld
10. Login to mysql
Command: mysql -uroot -p
Enter the password: the default is Jb2h<%lp9itY just found
11. Change password
命令:ALTER USER 'root'@'localhost' IDENTIFIED BY '12345678';
或命令:set password for 'root'@'localhost'=password('12345678');
12. Add a remote account
命令:GRANT ALL PRIVILEGES ON *.* TO 'remote'@'%' IDENTIFIED BY '12345678' WITH GRANT OPTION;
Command: FLUSH PRIVILEGES; make the settings take effect
three. Install PHP
1. Download address: http://cn2.php.net/distributions/php-7.1.11.tar.gz
wget http://cn2.php.net/distributions/php-7.1.11.tar.gz
tar -zxvf php-7.1.11.tar.gz
.. install php dependencies
yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel
./configure --prefix=/usr/local/lnmp/PHP \--with-config-file-path=/etc \--enable-fpm \--with-fpm-user=nginx \--with-fpm-group=nginx \--enable-inline-optimization \--disable-debug \--disable-rpath \--enable-shared \--enable-soap \--with-libxml-dir \--with-xmlrpc \--with-openssl \--with-mcrypt \--with-mhash \--with-pcre-regex \--with-sqlite3 \--with-zlib \--enable-bcmath \--with-iconv \--with-bz2 \--enable-calendar \--with-curl \--with-cdb \--enable-dom \--enable-exif \--enable-fileinfo \--enable-filter \--with-pcre-dir \--enable-ftp \--with-gd \--with-openssl-dir \--with-jpeg-dir \--with-png-dir \--with-zlib-dir \--with-freetype-dir \--enable-gd-native-ttf \--enable-gd-jis-conv \--with-gettext \--with-gmp \--with-mhash \--enable-json \--enable-mbstring \--enable-mbregex \--enable-mbregex-backtrack \--with-libmbfl \--with-onig \--enable-pdo\--with-mysqli=mysqlnd \--with-pdo-mysql=mysqlnd \--with-zlib-dir \--with-pdo-sqlite \--with-readline \--enable-session \--enable-shmop \--enable-simplexml \--enable-sockets \--enable-sysvmsg \--enable-sysvsem \--enable-sysvshm \--enable-wddx \--with-libxml-dir \--with-xsl \--enable-zip \--enable-mysqlnd-compression-support \--with-pear \--enable-opcache
.Compile and install
# make && make install
It takes a long time to make here , be patient
.Add PHP command to environment variable
# vim /etc/profile
add at the end
PATH=$PATH:/usr/local/php/bin
export PATH
To make changes take effect immediately
# source /etc/profile
View environment variables
# echo $PATH
check php version
# php -v
configure php-fpm
# cp php.ini-production /etc/php.ini
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# chmod +x /etc/init.d/php-fpm
start php-fpm
# /etc/init.d/php-fpm start
. restart nginx
# service nginx reload
<?php
phpinfo();
The following information can be viewed