1. Introduction to the HTTP protocol
HTTP protocol, full name HyperText Transfer Protocol, Chinese name is Hypertext Transfer Protocol, is the most commonly used network protocol in the Internet. One of the most important applications of HTTP is the WWW service.
1.1 www
www, the full name of World Wide Web, often referred to as Web, Chinese translation for "World Wide Web". It is currently the most popular form of information service on the Internet. The default port of the WWW service application of the HTTP protocol is 80, and the default port of the https of another encrypted WWW service application is 443.
1.1.1 BS Architecture
HTTP protocol www applications are: browser (Browser) and server (Server), B/S architecture, good at wide area network (Internet) applications
1.1.2 CS Architecture
nfs ssh rsync is: client (Client) and server (Server), C/S architecture, used inside the local area network.
1.1.3 User access to the website process
User access website process framework
DNS resolution principle
TCP/IP three-way handshake principle
Principle of http protocol (request process of www service)
Large-scale website cluster architecture details
http protocol principle, response, message details
Principle of tcp/ip waving process four times
1.1.4 HTTP request method
In HTTP communication, each HTTP request message contains a method. You can tell the WEB server what specific actions need to be performed. These actions include: obtaining the specified web page, submitting content to the server, deleting resource files on the server, etc.
1.1.4.1 Common request methods
HTTP method |
Action description |
GET |
The client requests the specified resource information, and the server returns the specified resource |
HEAD |
Only request the HTTP headers in the response message |
POST |
Submit the client's data to the server |
PUT |
Replaces the specified document content with data sent from the client to the server |
DELETE |
Requests the server to delete the resource identified by the Request-URI |
MOVE |
Request the server to move the specified page to another network address |
1.1.5 HTTP Status Codes
HTTP Status Code (HTTP Status Code) is a numerical code used to indicate the status of the corresponding HTTP request of the Web server. Whenever a web client sends an HTTP request to the web server, the web server returns a status response code. This status code is a three-digit code that informs the Web client whether the request is successful this time, or whether to take other actions.
1.1.5.1 Common Status Codes and Functions
status code |
Detailed description |
200 - OK |
The server successfully returns the web page, which is the standard status code returned for a successful http request |
301 - Moved Permanently |
Permanent jump, all requested web pages will be permanently transferred to the set new location. |
403 - Forbidden |
Access is forbidden. This request is legal, but the server rejects the request of the corresponding client because it matches the preset rules. Such problems are generally caused by improper setting of server or service permissions. |
404 - Not Found |
The server cannot find the specified page requested by the client, which may be caused by the client requesting a resource that does not exist on the server. |
500 - Inernal Server Error |
Internal server error, the server encountered an unexpected condition and was unable to fulfill the client's request. This is a more general error, usually caused by server settings or internal program problems. For example: SElinux is turned on, and if there is a rule permission set for http, the client access is 500 |
502 - Bad Gateway |
A bad gateway is generally when a proxy server requests a back-end service, but the back-end service is unavailable or fails to respond to the gateway server. Usually caused by a problem with the node under the reverse proxy server |
503 - Service Unavailable |
The service is currently unavailable, possibly because the server is overloaded or down for maintenance, or there is no node behind the reverse proxy server that can provide the service |
504 - Gateway Timeout |
The gateway times out. Generally, when the gateway proxy server requests the backend, the backend service does not complete the processing request within a specific time. Generally, the server is overloaded and does not return data to the front-end proxy server within the specified time. |
1.1.6 HTTP message
There are many lines of content in the HTTP message. The fields of different lines are all ASCII code strings, and the lengths of each field are also different. There are two types of HTTP messages. One is the HTTP message sent from the Web client to the Web server, which is called a Request Message. The other is the message sent from the web server to the web client, called the response message (Response Message). The format of the HTTP request and response messages is similar.
1.1.6.1 Introduction to HTTP Request Packets
HTTP request message consists of: request line, request header (header), blank line and request message body
1.1.6.2 Introduction to HTTP Response Messages
The HTTP response message consists of: start line, response header, blank line, and response message body
1.2 Characteristics of static web pages
The program is parsed on the client's browser side and does not need to read the back-end database, so the performance and efficiency are high
Because the backend does not have the support of the database, the interaction with the user is poor, and the function implementation is very small.
1.3 Features of Dynamic Web Pages
Web page extension suffixes are commonly: asp, aspx, jsp, do, cgi, etc.
Web pages are generally based on database technology, which greatly reduces the workload of website maintenance.
Websites using dynamic web technology can achieve more functions, such as user registration, user login, online surveys, voting, user management, order management, posting blog posts and so on.
Dynamic web pages are not web files that exist independently on the server. When a user requests dynamic programs on the server, the server parses these programs and may read the database to return a complete web page content.
The "?" in dynamic web pages has certain problems in the indexing of search engines, and search engines generally do not access all web pages from the database of a website.
The program is parsed on the server side, which is equivalent to customer ordering, restaurant chef cooking, which takes a long time and is inefficient. Because the program is parsed on the server side, it will consume a lot of CPU, memory, I/O and other resources.
1.4 The role of pseudo-static web pages
Let search engines index the content of the website, so that more users can visit the content of the enterprise website
To improve user access experience, URLs registered with dynamic addresses with special symbols are not as comfortable as looking at static web page addresses.
1.4.1 Summary of Pseudo-Static Web Pages
Use rewrite technology to disguise dynamic web pages as static web pages (URL address rewriting)
Facilitate search engine search to improve user traffic and user experience
Access performance is improved, and converting pseudo-static will consume resources, so performance will decrease
Convert dynamic web pages to true static web pages as much as possible
When the amount of concurrency is not large or dynamic updates are too frequent, it is also good to use rewrite to implement pseudo-static
The implementation process of pseudo-static web pages is generally realized by the operation product's requirements, development and operation and maintenance.
1.5 Website Traffic Measurement Terminology
1.5.1 IP(Internet Protocol)
IP (Independent IP) stands for Internet Protocol, which refers to the number of independent IPs. The number of independent IPs refers to the total number of times that computers with different IP addresses access a website. Generally, a client with the same IP address visiting a website page within a day (00:00~24:00) is only counted as one visit
1.5.2 PV(Page View)
PV (Visit) is Page View. Chinese translation is page views, that is, page views or clicks. Regardless of whether the client is the same or not, and whether the IP is the same or not, a PV will be calculated every time a user visits a website page. The specific measurement method of PV is to send a request to the web server from the client browser. After the web server receives the request, it sends a web page (Page) corresponding to the request to the browser, and a PV is generated.
1.5.3 UV(Unique Visitor)
UV (Independent Visitor) is Unique Visitor. The same client (PC or mobile terminal) visiting a website is counted as a visitor, and the same client visiting the same website within a day (00:00~24:00) only calculates UV once , UV is generally based on client-side cookies and other technologies as the statistical basis, and the actual statistics will have errors.
2. Features and advantages of Nginx HTTP server
Support high concurrency: can support tens of thousands of concurrent connections (especially in the static small file business environment)
Less resource consumption: under 30,000 concurrent connections, starting 10 Nginx threads consumes less than 200MB of memory
It can do HTTP reverse proxy and accelerated cache, that is, load balancing function, built-in health check function of RS node server, which is equivalent to the function of professional haproxy software or lvs
It has the caching function of professional caching software such as squid
Support asynchronous network IO event model epoll
2.1 The main application scenarios of Nginx as a web server
Use Nginx to run HTML, JS, CSS, small pictures and other static data (this function is similar to lighttpd software)
Nginx combines FastCGI to run dynamic programs such as PHP (for example, using fastcgi_pass)
Nginx supports Java dynamic programs in combination with tomcat/resin (commonly used proxy_pass method)
2.2 Why Nginx has higher overall performance than Apache
Nginx uses the latest epoll and kqueue asynchronous network I/O models, while Apache uses the traditional select model.
2.3 How to install software in linux
rpm -ivh package name.rpm, there is a dependency problem. Disadvantage: cannot be customized
The yum installation automatically solves the dependency problem of the rpm installation, and the installation is simpler. Advantages: Simple, easy to use, efficient; Disadvantages: Cannot be customized
Compile ./configure (configure), make (compile), make install (install). Advantages: can be customized; Disadvantages: complex and inefficient.
Customize the rpm package, build the yum warehouse, put the customized rpm package in the yum warehouse, and install the yum. Advantages: Combines the advantages of yum installation and compilation installation; Disadvantages: complex.
2.4 nginx compilation and installation method
Create a software download directory
mkdir /home/s-linuxad/tools
cd /home/s-linuxad/tools
Create nginx user www
useradd www -s /sbin/nologin -M
Packages required for yum installation
yum install openssl openssl-devel -y
yum install pcre pcre-devel -y
Download nginx1.6.3
wget -q http://nginx.org/download/nginx-1.6.3.tar.gz
tar xf nginx-1.6.3.tar.gz
cd nginx-1.6.3
configure
./configure --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --prefix=/application/nginx-1.6.3
compile
make
Install
make install
make a soft link
ln -s /application/nginx-1.6.3/ /application/nginx
/application/nginx/sbin/nginx
The browser opens and the prompt is as follows, indicating that the installation is normal
2.4.1 Press and hold the win+R keys to add domain name resolution to the local hosts of the computer
Find /etc/hosts and edit
2.4.2 Add hosts parsing to linux server
2.5 Host type concept of virtual machine
The so-called virtual host is an independent website site in Web services. This site corresponds to an independent domain name (may be a port or IP), has an independent program and resource directory, and can independently provide external services for users to access. The nginx software uses a serve{} tag to denote a virtual host.
2.5.1 Types of virtual hosts
Domain-Based Virtual Hosting: Distinguish Virtual Hosts by Domain Name
Port-Based Virtual Hosting: Distinguish Virtual Hosts by Port
IP-based virtual hosting. hardly ever
2.5.2 Domain-based virtual hosting
The configuration file of nginx.conf is
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name www.123456789.com;
location / {
root html/www;
index index.html index.htm;
}
}
server {
listen 80;
server_name bbs.carlton.com;
location / {
root html/bbs;
index index.html index.htm;
}
}
Create www and bbs directories under html, and index.html
mkdir html/www
mkdir html/bbs
echo "www" >html/www/index.html
echo "bbs" >html/bbs/index.html
Then enter bbs.carlton.com in the web page
2.5.3 Implementation of port-based virtual host
server {
listen 80;
server_name bbs.carlton.com;
location / {
root html/bbs;
index index.html index.htm;
}
}
server {
listen 81;
server_name bbs.carlton.com;
location / {
root html/bbs;
index index.html index.htm;
}
}
2.5.4 Nginx configuration virtual host file steps summary
Add a complete server tag segment to the end. Note that it should be placed before the closing brace of http, that is, put the server tag segment into the http tag.
Change the server_name and the root directory of the corresponding web page. If you need other parameters, you can add or modify them.
Create the root directory of the web page corresponding to the server_name domain name, and create a test file. If there is no index home page, a 403 error will occur when accessing.
Check the syntax of the nginx configuration file, restart the nginx service smoothly, and quickly check the startup result.
Perform hosts resolution or DNS configuration on the domain name configured at server_name on the client, and check (ping the domain name to see if the returned IP is correct).
Enter the address in the Windows browser to access, or do hosts resolution in the Linux client, and use wget or curl to access the address.
2.6 Virtual host configuration optimization
Create extra in /application/nginx/conf
cd /application/nginx/conf
mkdir extra
Change the configuration file of nginx.conf to
[root@T-Ansible-v-szzb conf]# cat nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
include extra/www.conf;
include extra/bbs.conf;
include extra/blog.conf;
include extra/status.conf;
}
Then enter the extra directory and create a new bbs.conf www.conf blog.conf status.conf
[root@T-Ansible-v-szzb extra]# ll
total 20
-rw-r----- 1 www www 354 Apr 1 20:54 bbs.conf
-rw-r----- 1 www www 381 Apr 1 20:08 blog.conf
-rw-r----- 1 root root 107 Mar 28 22:27 default.conf.bak
-rw-r----- 1 root root 145 Mar 29 22:06 status.conf
-rw-r----- 1 www www 223 Mar 29 22:07 www.conf
[root@T-Ansible-v-szzb extra]# cat ./*
server {
listen 80;
server_name bbs.carlton.com;
location / {
root html/bbs;
index index.html index.htm;
}
}
server {
listen 81;
server_name bbs.carlton.com;
location / {
root html/bbs;
index index.html index.htm;
}
}
server {
listen 80;
server_name blog.carlton.com;
location / {
root html/blog;
index index.php index.html index.htm;
}
location ~.*\.(php|php5)?$ {
root html/blog;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
server
{
listen 80 default_server;
index index.html index.htm index.php;
root /tmp/123456;
}
##status
server {
listen 80;
server_name www.123456789.com;
location / {
root html/www;
index index.html index.htm;
}
access_log logs/www_access.log main;
}
2.6.1 Check the access status of web pages
/application/nginx/conf/extra create and write status.conf, the content is as follows
server{
listen 80;
server_name status.carlton.com;
location / {
stub_status on;
access_log off;
}
}
2.7 Define the access log of Nginx
In the nginx.conf file (log_format to the next 3 lines)
[root@T-Ansible-v-szzb conf]# cat nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
keepalive_timeout 65;
include extra/www.conf;
include extra/bbs.conf;
include extra/blog.conf;
include extra/status.conf;
}
Then in www..conf file add access_log logs/www_access.log main;
[root@T-Ansible-v-szzb extra]# cat www.conf
server {
listen 80;
server_name www.123456789.com;
location / {
root html/www;
index index.html index.htm;
}
access_log logs/www_access.log main;
}
then view
2.7.1 Cutting of Nginx access logs
Write a script access.sh
#!/bin/bash
cd /application/nginx/logs
/bin/mv www_access.log www_access_$(date +%F)
/application/nginx/sbin/nginx -s reload
Then write a scheduled task to execute the script at 0:00 every night
20 3 * * * /bin/sh access.sh
2.8 The use of Nginx location
2.8.1 The role of location
The function of the location instruction is to execute different applications according to the URI requested by the user.
2.8.2 location syntax
location [=|~|~*|^~] uri {
...
}
The location syntax shows that the uri part of the syntax is the key. This uri can be a common string address path or a regular expression. When the match is successful, the relevant instructions in the curly brackets will be executed. Regular expressions can also be preceded by special characters such as ~ or ~*.
"~" is used for case-sensitive matching; "~*" is used for case-insensitive matching. The function of "^~" is to not check the regular expression after the regular string matching check.
Description of the matching sequence of different URI and special character combinations
Different URI and special character combination matching order |
match description |
1st place: "location =/{" |
exact match/ |
Second place: "location ^~/images{" |
Match regular strings without regular matching checks |
Third place: "location ~*(gif|jpg|jpeg)${" |
regular match |
Fourth place: "location /documents/{" |
Match the regular string, if there is a regular, it will first match the regular |
Fifth place: "location /{" |
Default match where all locations cannot match |
2.8.3 Nginx Rewrite
2.8.4 What is Nginx Rewrite
The main function of Nginx Rewrite is to implement URL address rewriting. The Rewtire rules of Nginx require the support of PCRE software, that is, the rules are matched through Perl-compatible regular expression syntax.
2.8.5 Syntax of Rewrite
rewrite regular replacement content [flag]
rewrite ^/(.*) http://www.123456789.com/$1 permanent
rewrite is a fixed keyword, which means to open a rewrite matching rule. The regular part is ^/(.*), which means to match all. After the match is successful, jump to http://www.123456789.com/$1, where $1 is to go The content in the previous regular part (), ending with permanent, indicates a permanent 301 redirection mark.
Application location
server、location、if
Example
Edit the www.conf file, enter www.123456789.com for the purpose, and automatically jump to www.baidu.com
server {
listen 80;
server_name www.123456789.com;
location / {
root html/www;
index index.html index.htm;
}
location =/ {
rewrite ^/(.*) http://home.baidu.com/$1 permanent;
}
access_log logs/www_access.log main;
}
3. Mysql installation
安装cmake编译工具
cd /usr/local/src/lnmp
tar xzvf cmake-2.8.11.2.tar.gz
cd cmake-2.8.11.2/
./configure
make
make install
创建用于执行mysql服务程序的帐号:
useradd mysql -s /sbin/nologin
创建数据库程序和文件的目录,并设置目录的所属与所组:
useradd mysql -s /sbin/nologin
安装Mysql服务程序
cd /usr/local/src/lnmp
tar xzvf mysql-5.6.19.tar.gz
cd mysql-5.6.19/
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/var -DSYSCONFDIR=/etc
make
make install
删除系统默认的配置文件:
rm -rf /etc/my.cnf
生成系统数据库
cd /usr/local/mysql
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var
出现2个OK 就可以
ln -s /usr/local/mysql/my.cnf /etc/my.cnf
将mysqld服务程序添加到开机启动项:
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig mysqld on
编辑启动项的配置文件:
vim /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/usr/local/mysql/var
启动mysqld服务程序:
service mysqld start
把mysql服务程序命令目录添加到环境变量中
echo "export PATH=$PATH:/usr/local/mysql/bin" >>/etc/profile
source /etc/profile
将mysqld服务程序的库文件链接到默认的位置:
mkdir /var/lib/mysql
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
mysql重置密码
mysqladmin password 123456 mysql设置密码
mysqladmin -uroot –p123456 password 123321 mysql修改密码
4.PHP的安装
安装PHP之前的准备工作,nginx 和mysql 必须都要安装
[root@T-Ansible-v-szzb extra]# netstat -lntup |egrep "nginx|mysql"
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 12271/nginx: worker
tcp 0 0 0.0.0.0:81 0.0.0.0:* LISTEN 12271/nginx: worker
tcp6 0 0 :::3306 :::* LISTEN 17260/mysqld
[root@T-Ansible-v-szzb extra]# netstat -lntup |egrep "3306|80"
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 12271/nginx: worker
tcp6 0 0 :::3306 :::* LISTEN 17260/mysqld
udp6 0 0 :::41780 :::* -
[root@T-Ansible-v-szzb extra]#
安装步骤
yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel openssl-devel -y
rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel
cd /home/s-linuxad/tools
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar xf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make
make install
安装php相关扩展库
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum -y install libmcrypt-devel mhash mcrypt
rpm -qa libmcrypt-devel mhash mcrypt
开始编译
./configure \
--prefix=/application/php-5.3.27 \
--with-mysql=/usr/local/mysql \
--with-iconv-dir=/usr/local/libconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-safe-mode \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--with-curlwrappers \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--enable-short-tags \
--enable-zend-multibyte \
--enable-static \
--with-xsl \
--with-fpm-user=www \
--with-fpm-group=www \
--enable-ftp
安装两步之后在文件夹下面继续用
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/
touch ext/phar/phar/phar.phar
在进行make
提示错误 cannot find lltdl
解决:
yum install -y libtool-ltdl-devel
下一步make install 出现这个情况就表示成功
PHP配置正确的提示:
/home/s-linuxad/tools/php-5.3.27/build/shtool install -c ext/phar/phar.phar /php-5.3.27/bin
ln -s -f /php-5.3.27/bin/phar.phar /php-5.3.27/bin/phar
Installing PDO headers: /php-5.3.27/include/php/ext/pdo/
对文件的部分操作
cd /php/etc/
cp php-fpm.conf.default php-fpm.conf
/php/sbin/php-fpm
[root@T-Ansible-v-szzb ~]# lsof -i:9000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
php-fpm 10912 root 7u IPv4 26927553 0t0 TCP localhost:cslistener (LISTEN)
php-fpm 11867 www 0u IPv4 26927553 0t0 TCP localhost:cslistener (LISTEN)
php-fpm 11871 www 0u IPv4 26927553 0t0 TCP localhost:cslistener (LISTEN)
php-fpm 11880 www 0u IPv4 26927553 0t0 TCP localhost:cslistener (LISTEN)
[root@T-Ansible-v-szzb ~]# ps -ef |grep php-fpm
root 10912 1 0 18:53 ? 00:00:00 php-fpm: master process (/application/php-5.3.27/etc/php-fpm.conf)
www 11867 10912 0 20:20 ? 00:00:01 php-fpm: pool www
www 11871 10912 0 20:20 ? 00:00:01 php-fpm: pool www
www 11880 10912 0 20:20 ? 00:00:01 php-fpm: pool www
root 13430 13401 0 22:43 pts/0 00:00:00 grep --color=auto php-fpm
5.访问测试PHP和Nginx的连通
[root@T-Ansible-v-szzb extra]# cat blog.conf
server {
listen 80;
server_name blog.carlton.com;
location / {
root html/blog;
index index.php index.html index.htm;
}
location ~.*\.(php|php5)?$ {
root html/blog;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
[root@T-Ansible-v-szzb blog]# cat test_info.php
<?php phpinfo(); ?>
测试PHP和Nginx的是否连接输入:blog.carlton.com/test_info.php
6.测试php 和mysql 的连接性
[root@T-Ansible-v-szzb blog]# cat test_mysql.php
<?php
$link_id=mysql_connect('localhost','root','123456') or msyql_error();
if($link_id){
echo "mysql successful by Carlton !";
}else{
echo mysql_error();
}
?>
然后在网页中输入:blog.carlton.com/test_mysql.php
注:配置文件的属主和属组都必须是编译时的www用户
[root@T-Ansible-v-szzb blog]# ll
total 12
-rwxr-xr-x 1 www www 5 Mar 28 16:57 index.html
-rw-r----- 1 www www 20 Apr 1 19:38 test_info.php
-rw-r----- 1 www www 229 Apr 1 19:53 test_mysql.php
7.使用wordpress搭建个人博客
所有的环境是基于LNMP的基础之上的
[root@T-Ansible-v-szzb Carlton]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 21
Server version: 5.6.33 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create databases wordpress;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'databases wordpress' at line 1
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
| testt |
+--------------------+
5 rows in set (0.01 sec)
mysql> create database wordpress;
Query OK, 1 row affected (0.02 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
| testt |
| wordpress |
+--------------------+
6 rows in set (0.00 sec)
mysql> grant all on wordpress.* to wordpress@'localhost' identified by '123456'
-> ;
Query OK, 0 rows affected (0.02 sec)
mysql> select user,host from mysql.user;
+-----------+------------------+
| user | host |
+-----------+------------------+
| root | 127.0.0.1 |
| root | ::1 |
| | localhost |
| root | localhost |
| wordpress | localhost |
| | t-ansible-v-szzb |
| root | t-ansible-v-szzb |
+-----------+------------------+
7 rows in set (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql>
小总:
creat database wordpress;
show databases;
grant all on wordpress.* to wordpress@'localhost' identified by '123456';
select user,host from mysql.user;
show grants for wordpress@'localhost';
flush privileges; 刷新让权限生效
添加一行到之前的测试脚本里面
index index.php index.html index.htm;
下载
wget https://cn.wordpress.org/wordpress-4.7.4-zh_CN.zip
unzip wordpress-4.7.4-zh_CN.zip
cp -a wordpress/* /application/nginx/html/blog/
chown -R www.www /application/nginx/html/blog/
然后在网页中输入 blog.carlton.com 则出现下面的页面
安装完成