s28 LNMP架构服务搭建
nginx-location使用
location语法
实现配置
server {
listen 80;
server_name www.etiantian.org etiantian.org;
root html/www;
location / {
return 401;
}
location = / {
return 402;
}
location /documents/ {
return 403;
}
location ^~ /images/ {
return 404;
}
location ~* \.(gif|jpg|jpeg)$ {
return 500;
}
access_log logs/access_www.log main ;
}
x
[root@www extra]# cat www.conf
server {
listen 80;
server_name www.etiantian.org etiantian.org;
root html/www;
location / {
return 401;
}
location = / {
return 402;
}
location /documents/ {
return 403;
}
location ^~ /images/ {
return 404;
}
location ~* \.(gif|jpg|jpeg)$ {
return 500;
}
access_log logs/access_www.log main ;
}
测试
小结
nginx-rewrite短域名跳转
rewrite配置
server {
listen 80;
server_name etiantian.org;
rewrite (^.*) http://www.etiantian.org/$1 permanent;
}
server {
listen 80;
server_name www.etiantian.org ;
access_log logs/access_www.log main;
location / {
root html/www;
index index.html index.htm;
}
}
[root@web01 extra]# cat www.conf
server {
listen 80;
server_name etiantian.org;
rewrite (^.*) http://www.etiantian.org/$1 permanent;
}
server {
listen 80;
server_name www.etiantian.org ;
access_log logs/access_www.log main;
location / {
root html/www;
index index.html index.htm;
}
}
测试
web01 www.etiantian.org
[root@web01 extra]# curl -Lv 、
* About to connect() to etiantian.org port 80 (#0)
* Trying 10.0.0.8... connected
* Connected to etiantian.org (10.0.0.8) port 80 (#0)
> GET /index.html HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.21 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: etiantian.org
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Server: nginx/1.12.2
< Date: Tue, 27 Feb 2018 12:31:27 GMT
< Content-Type: text/html
< Content-Length: 185
< Connection: keep-alive
< Location: http://www.etiantian.org//index.html
<
* Ignoring the response-body
* Connection #0 to host etiantian.org left intact
* Issue another request to this URL: 'http://www.etiantian.org//index.html'
* About to connect() to www.etiantian.org port 80 (#1)
* Trying 10.0.0.8... connected
* Connected to www.etiantian.org (10.0.0.8) port 80 (#1)
> GET //index.html HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.21 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: www.etiantian.org
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx/1.12.2
< Date: Tue, 27 Feb 2018 12:31:27 GMT
< Content-Type: text/html
< Content-Length: 24
< Last-Modified: Mon, 12 Feb 2018 18:11:30 GMT
< Connection: keep-alive
< ETag: "5a81d8d2-18"
< Accept-Ranges: bytes
<
web01 www.etiantian.org
* Connection #1 to host www.etiantian.org left intact
* Closing connection #0
* Closing connection #
[root@web01 extra]# curl -L etiantian.org/index.html
web01 www.etiantian.org
[root@web01 extra]# curl -Lv 、
* About to connect() to etiantian.org port 80 (#0)
* Trying 10.0.0.8... connected
* Connected to etiantian.org (10.0.0.8) port 80 (#0)
> GET /index.html HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.21 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: etiantian.org
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Server: nginx/1.12.2
< Date: Tue, 27 Feb 2018 12:31:27 GMT
< Content-Type: text/html
< Content-Length: 185
< Connection: keep-alive
< Location: http://www.etiantian.org//index.html
<
* Ignoring the response-body
* Connection #0 to host etiantian.org left intact
* Issue another request to this URL: 'http://www.etiantian.org//index.html'
* About to connect() to www.etiantian.org port 80 (#1)
* Trying 10.0.0.8... connected
* Connected to www.etiantian.org (10.0.0.8) port 80 (#1)
> GET //index.html HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.21 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: www.etiantian.org
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx/1.12.2
< Date: Tue, 27 Feb 2018 12:31:27 GMT
< Content-Type: text/html
< Content-Length: 24
< Last-Modified: Mon, 12 Feb 2018 18:11:30 GMT
< Connection: keep-alive
< ETag: "5a81d8d2-18"
< Accept-Ranges: bytes
<
web01 www.etiantian.org
* Connection #1 to host www.etiantian.org left intact
* Closing connection #0
* Closing connection #
HTTP/1.1 302 Moved Temporarily
Server: JengineD/1.7.2.1
Date: Tue, 27 Feb 2018 12:37:26 GMT
Content-Type: text/html
Content-Length: 165
Location: http://www.jd.com
Connection: keep-alive
HTTP/1.1 200 OK
Date: Tue, 27 Feb 2018 12:37:27 GMT
Server: Apache
Last-Modified: Tue, 12 Jan 2010 13:48:00 GMT
ETag: "51-47cf7e6ee8400"
Accept-Ranges: bytes
Content-Length: 81
Cache-Control: max-age=86400
Expires: Wed, 28 Feb 2018 12:37:27 GMT
Connection: Keep-Alive
Content-Type: text/html
HTTP/1.1 302 Found
Server: Tengine
Date: Tue, 27 Feb 2018 12:37:27 GMT
Content-Type: text/html
Content-Length: 258
Connection: keep-alive
Location: http://www.taobao.com/
[root@web01 extra]# curl status.lewen.com
Active connections: 1
server accepts handled requests
84 84 135
Reading: 0 Writing: 1 Waiting: 0
[root@web01 extra]# curl -I jd.com baidu.com taobao.com
HTTP/1.1 302 Moved Temporarily
Server: JengineD/1.7.2.1
Date: Tue, 27 Feb 2018 12:37:26 GMT
Content-Type: text/html
Content-Length: 165
Location: http://www.jd.com
Connection: keep-alive
HTTP/1.1 200 OK
Date: Tue, 27 Feb 2018 12:37:27 GMT
Server: Apache
Last-Modified: Tue, 12 Jan 2010 13:48:00 GMT
ETag: "51-47cf7e6ee8400"
Accept-Ranges: bytes
Content-Length: 81
Cache-Control: max-age=86400
Expires: Wed, 28 Feb 2018 12:37:27 GMT
Connection: Keep-Alive
Content-Type: text/html
HTTP/1.1 302 Found
Server: Tengine
Date: Tue, 27 Feb 2018 12:37:27 GMT
Content-Type: text/html
Content-Length: 258
Connection: keep-alive
Location: http://www.taobao.com/
[root@web01 extra]# curl status.lewen.com
Active connections: 1
server accepts handled requests
84 84 135
Reading: 0 Writing: 1 Waiting: 0
Nginx status
server {
listen 80;
server_name status.etiantian.org;
location / {
stub_status on;
access_log off;
auth_basic "closed site";
auth_basic_user_file /application/nginx/conf/htpasswd;
}
}
##status.conf
server {
listen 80;
server_name status.etiantian.org;
location / {
stub_status on;
access_log off;
auth_basic "closed site";
auth_basic_user_file /application/nginx/conf/htpasswd;
}
}
登录验证
Enter host password for user 'oldboy':
<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.14.0</center>
</body>
</html>
[root@web01 extra]# curl -u oldboy status.lewen.com
Enter host password for user 'oldboy':
<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.14.0</center>
</body>
</html>

2018/09/02 19:31:29 [error] 2577#0: *44 open() "/application/nginx-1.14.0//conf/conf/htpasswd" failed (2: No such file or directory), client: 10.0.0.1, server: status.lewen.com, request: "GET / HTTP/1.1", host: "status.lewen.com"

Active connections: 1
server accepts handled requests
46 46 80
Reading: 0 Writing: 1 Waiting: 0
[root@web01 extra]# curl -u oldboy:123456 status.lewen.com
Active connections: 1
server accepts handled requests
46 46 80
Reading: 0 Writing: 1 Waiting: 0
本章回顾

mysql二进制部署
https://downloads.mysql.com/archives/community/
原因:缺少libaio库文件
解决方法:yum install libaio* numactl -y
Installing MySQL system tables.../application/mysql/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
原因:缺少libaio库文件
解决方法:yum install libaio* numactl -y
如果安装mysql出现了以上的报错信息.这是却少numactl这个时候如果是Centos就yum -y install numactl就可以解决这个问题了.
Installing MySQL system tables.../application/mysql/bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
如果安装mysql出现了以上的报错信息.这是却少numactl这个时候如果是Centos就yum -y install numactl就可以解决这个问题了.
#####support-files/mysql.server to the right place for your system
#####mysql启动脚本 默认放在support-files/mysql.server
#####
#####记得给MySQL设置个密码
#####PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
#####To do so, start the server, then issue the following commands:
#####
##### /application/mysql/bin/mysqladmin -u root password 'new-password'
##### /application/mysql/bin/mysqladmin -u root -h web01 password 'new-password'
#####To start mysqld at boot time you have to copy
#####support-files/mysql.server to the right place for your system
#####mysql启动脚本 默认放在support-files/mysql.server
#####
#####记得给MySQL设置个密码
#####PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
#####To do so, start the server, then issue the following commands:
#####
##### /application/mysql/bin/mysqladmin -u root password 'new-password'
##### /application/mysql/bin/mysqladmin -u root -h web01 password 'new-password'

cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
####8.修改启动脚本 和 mysql命令 中的路径
sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld
####9.复制 默认的配置文件
\cp /application/mysql/support-files/my-default.cnf /etc/my.cnf
/etc/init.d/mysqld start
[root@web01 ~]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/application/mysql/data/web01.err'.
. SUCCESS!
####查看
[root@web01 ~]# ss -lntup |grep 3306
tcp LISTEN 0 80 :::3306 :::* users:(("mysqld",1898,10))
####7.复制启动脚本 授权
cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
####8.修改启动脚本 和 mysql命令 中的路径
sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld
####9.复制 默认的配置文件
\cp /application/mysql/support-files/my-default.cnf /etc/my.cnf
/etc/init.d/mysqld start
[root@web01 ~]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/application/mysql/data/web01.err'.
. SUCCESS!
####查看
[root@web01 ~]# ss -lntup |grep 3306
tcp LISTEN 0 80 :::3306 :::* users:(("mysqld",1898,10))
echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile
source /etc/profile
which mysql
[root@web01 ~]# which mysql
/application/mysql/bin/mysql
####11.加入开机自启动
chkconfig --add mysqld
chkconfig mysqld on
####12.给MySQL root用户设置密码
/application/mysql/bin/mysqladmin -u root password 'oldboy123'
####13.重新登录MySQL数据库
mysql -uroot -poldboy123
####14.数据库基础框架
#1.数据库 test mysql
#2.表格
####10.PATH路径 添加到系统路径
echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile
source /etc/profile
which mysql
[root@web01 ~]# which mysql
/application/mysql/bin/mysql
####11.加入开机自启动
chkconfig --add mysqld
chkconfig mysqld on
####12.给MySQL root用户设置密码
/application/mysql/bin/mysqladmin -u root password 'oldboy123'
####13.重新登录MySQL数据库
mysql -uroot -poldboy123
####14.数据库基础框架
#1.数据库 test mysql
#2.表格
##1./tmp权限
##2.主机名解析 hosts解析 #ping 主机名
##3.一步一步执行
##
##/application/mysql/bin/mysql
##Welcome to the MySQL monitor. Commands end with ; or \g.
##Your MySQL connection id is 1
##Server version: 5.5.49 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>
###故障
##1./tmp权限
##2.主机名解析 hosts解析 #ping 主机名
##3.一步一步执行
##
##/application/mysql/bin/mysql
##Welcome to the MySQL monitor. Commands end with ; or \g.
##Your MySQL connection id is 1
##Server version: 5.5.49 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>
mysql SQL语句
mysql> show databases; ********
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.07 sec)
mysql> #查看当前都有啥
mysql> show databases; ********
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.07 sec)
##使用某一个数据库
###相当于进入 mysql 数据库中 cd mysql ; cd test
#use mysql
##我想查看当前在哪? pwd 当前正在使用哪个数据库
select database();
+------------+
| database() |
+------------+
| mysql |
+------------+
1 row in set (0.00 sec)
##我是谁? 查看当前用户
select user();
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)
###当前系统都有什么用户? 他们可以在哪里登录? *****
select user,host from mysql.user;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1 |
| | localhost |
| root | localhost |
| | web01 |
| root | web01 |
+------+-----------+
6 rows in set (0.02 sec)
####初级 查看系列-结束
###show databases;
###select user,host from mysql.user;
####初级 查看系列-开始
##使用某一个数据库
###相当于进入 mysql 数据库中 cd mysql ; cd test
#use mysql
##我想查看当前在哪? pwd 当前正在使用哪个数据库
select database();
+------------+
| database() |
+------------+
| mysql |
+------------+
1 row in set (0.00 sec)
##我是谁? 查看当前用户
select user();
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)
###当前系统都有什么用户? 他们可以在哪里登录? *****
select user,host from mysql.user;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1 |
| | localhost |
| root | localhost |
| | web01 |
| root | web01 |
+------+-----------+
6 rows in set (0.02 sec)
####初级 查看系列-结束
###show databases;
###select user,host from mysql.user;
#创建数据库
create database wordpress;
#删除数据库
drop database wordpress;
#添加用户
grant all on wordpress.* to 'wordpress'@'172.16.1.0/255.255.255.0' identified by '123456';
grant all on wordpress.* to 'wordpress'@'172.16.1.0/255.255.255.0' identified by '123456';
授权所有的权限, wordpress数据库所有的权限 给 wordpress用户 可以在172.16.1.0/255.255.255.0 网段登录数据库 这个用户的密码123456;
#更新系统的权限表
flush privileges;
###进行测试
mysql -uwordpress -p123456
mysql -uwordpress -p -h 172.16.1.8
#删除用户
drop user wordpress@'172.16.1.8';
####初级 添加删除系列
#创建数据库
create database wordpress;
#删除数据库
drop database wordpress;
#添加用户
grant all on wordpress.* to 'wordpress'@'172.16.1.0/255.255.255.0' identified by '123456';
grant all on wordpress.* to 'wordpress'@'172.16.1.0/255.255.255.0' identified by '123456';
授权所有的权限, wordpress数据库所有的权限 给 wordpress用户 可以在172.16.1.0/255.255.255.0 网段登录数据库 这个用户的密码123456;
#更新系统的权限表
flush privileges;
###进行测试
mysql -uwordpress -p123456
mysql -uwordpress -p -h 172.16.1.8
#删除用户
drop user wordpress@'172.16.1.8';
Enter password:
####前面创建用户时限制了访问ip 要想本地访问就得再创建一个
ERROR 1045 (28000): Access denied for user 'wordpress'@'localhost' (using password: YES)
####制定ip 登录
[root@web01 ~]# mysql -uwordpress -h 172.16.1.8 -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 24
Server version: 5.6.41 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
[root@web01 ~]# mysql -uwordpress -p
Enter password:
####前面创建用户时限制了访问ip 要想本地访问就得再创建一个
ERROR 1045 (28000): Access denied for user 'wordpress'@'localhost' (using password: YES)
####制定ip 登录
[root@web01 ~]# mysql -uwordpress -h 172.16.1.8 -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 24
Server version: 5.6.41 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
###2.查看都有什么用户
###3.添加用户
#help sql语句。
#跳过授权表(不用密码登录)
#/etc/init.d/mysqld restart --skip-grant-table
#mysql 命令行
#-u 指定用户
#-p 指定密码(不要有空格)
#-h 连接到某一台服务器
#更改密码 mysqladmin -uroot -poldboy123 password '新的密码'
db01上部署一个mysql5.6.39
###1.查看都有什么数据库
###2.查看都有什么用户
###3.添加用户
#help sql语句。
#跳过授权表(不用密码登录)
#/etc/init.d/mysqld restart --skip-grant-table
#mysql 命令行
#-u 指定用户
#-p 指定密码(不要有空格)
#-h 连接到某一台服务器
#更改密码 mysqladmin -uroot -poldboy123 password '新的密码'
db01上部署一个mysql5.6.39
yum install freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel -y
rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel curl-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel
yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel curl-devel -y
yum install freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel -y
rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel curl-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel
部署php
安装PHP过程
tar xf php-5.5.32.tar.gz
cd php-5.5.32 #----正式编译前也可以把这个软件安装上(libxslt*)
./configure --prefix=/application/php-5.5.32 \
--with-mysql=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--enable-short-tags \
--enable-static \
--with-xsl \
--with-fpm-user=www \
--with-fpm-group=www \
--enable-ftp \
--enable-opcache=no
####编译配置
tar xf php-5.5.32.tar.gz
cd php-5.5.32 #----正式编译前也可以把这个软件安装上(libxslt*)
./configure --prefix=/application/php-5.5.32 \
--with-mysql=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--enable-short-tags \
--enable-static \
--with-xsl \
--with-fpm-user=www \
--with-fpm-group=www \
--enable-ftp \
--enable-opcache=no
##提示 如下内容 即成功
Generating files
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+
Thank you for using PHP.
config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/fpm/php-fpm.conf
config.status: creating sapi/fpm/init.d.php-fpm
config.status: creating sapi/fpm/php-fpm.service
config.status: creating sapi/fpm/php-fpm.8
config.status: creating sapi/fpm/status.html
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands
编译过程
##提示 如下内容 即成功
Generating files
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+
Thank you for using PHP.
config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/fpm/php-fpm.conf
config.status: creating sapi/fpm/init.d.php-fpm
config.status: creating sapi/fpm/php-fpm.service
config.status: creating sapi/fpm/php-fpm.8
config.status: creating sapi/fpm/status.html
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands
Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
clicommand.inc
pharcommand.inc
invertedregexiterator.inc
directorygraphiterator.inc
directorytreeiterator.inc
phar.inc
Build complete.
[root@web01 php-5.5.32]# make install
Installing PHP CLI binary: /application/php-5.5.32/bin/
Installing PHP CLI man page: /application/php-5.5.32/php/man/man1/
Installing PHP FPM binary: /application/php-5.5.32/sbin/
Installing PHP FPM config: /application/php-5.5.32/etc/
Installing PHP FPM man page: /application/php-5.5.32/php/man/man8/
Installing PHP FPM status page: /application/php-5.5.32/php/php/fpm/
Installing PHP CGI binary: /application/php-5.5.32/bin/
Installing PHP CGI man page: /application/php-5.5.32/php/man/man1/
Installing build environment: /application/php-5.5.32/lib/php/build/
Installing header files: /application/php-5.5.32/include/php/
Installing helper programs: /application/php-5.5.32/bin/
program: phpize
program: php-config
Installing man pages: /application/php-5.5.32/php/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /application/php-5.5.32/lib/php/
[PEAR] Archive_Tar - installed: 1.4.0
[PEAR] Console_Getopt - installed: 1.4.1
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util - installed: 1.3.0
[PEAR] PEAR - installed: 1.10.1
Wrote PEAR system config file at: /application/php-5.5.32/etc/pear.conf
You may want to add: /application/php-5.5.32/lib/php to your php.ini include_path
/home/oldboy/tools/php-5.5.32/build/shtool install -c ext/phar/phar.phar /application/php-5.5.32/bin
ln -s -f phar.phar /application/php-5.5.32/bin/phar
Installing PDO headers: /application/php-5.5.32/include/php/ext/pdo/
[root@web01 php-5.5.32]# echo $?
0
安装过程
Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
clicommand.inc
pharcommand.inc
invertedregexiterator.inc
directorygraphiterator.inc
directorytreeiterator.inc
phar.inc
Build complete.
[root@web01 php-5.5.32]# make install
Installing PHP CLI binary: /application/php-5.5.32/bin/
Installing PHP CLI man page: /application/php-5.5.32/php/man/man1/
Installing PHP FPM binary: /application/php-5.5.32/sbin/
Installing PHP FPM config: /application/php-5.5.32/etc/
Installing PHP FPM man page: /application/php-5.5.32/php/man/man8/
Installing PHP FPM status page: /application/php-5.5.32/php/php/fpm/
Installing PHP CGI binary: /application/php-5.5.32/bin/
Installing PHP CGI man page: /application/php-5.5.32/php/man/man1/
Installing build environment: /application/php-5.5.32/lib/php/build/
Installing header files: /application/php-5.5.32/include/php/
Installing helper programs: /application/php-5.5.32/bin/
program: phpize
program: php-config
Installing man pages: /application/php-5.5.32/php/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /application/php-5.5.32/lib/php/
[PEAR] Archive_Tar - installed: 1.4.0
[PEAR] Console_Getopt - installed: 1.4.1
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util - installed: 1.3.0
[PEAR] PEAR - installed: 1.10.1
Wrote PEAR system config file at: /application/php-5.5.32/etc/pear.conf
You may want to add: /application/php-5.5.32/lib/php to your php.ini include_path
/home/oldboy/tools/php-5.5.32/build/shtool install -c ext/phar/phar.phar /application/php-5.5.32/bin
ln -s -f phar.phar /application/php-5.5.32/bin/phar
Installing PDO headers: /application/php-5.5.32/include/php/ext/pdo/
[root@web01 php-5.5.32]# echo $?
0
#复制php.ini配置文件
[root@web01 php-5.5.32]# cp /home/oldboy/tools/php-5.5.32/php.ini-production /application/php-5.5.32/lib/php.ini
#复制php-fpm配置文件
[root@web01 php-5.5.32]# cd /application/php-5.5.32/etc/
[root@web01 etc]# ls
pear.conf php-fpm.conf.default
[root@web01 etc]# cp php-fpm.conf.default php-fpm.conf
[root@web01 etc]# ll
total 52
-rw-r--r-- 1 root root 1332 Feb 27 22:53 pear.conf
-rw-r--r-- 1 root root 22609 Feb 27 22:56 php-fpm.conf
-rw-r--r-- 1 root root 22609 Feb 27 22:53 php-fpm.conf.default
####安装完
#复制php.ini配置文件
[root@web01 php-5.5.32]# cp /home/oldboy/tools/php-5.5.32/php.ini-production /application/php-5.5.32/lib/php.ini
#复制php-fpm配置文件
[root@web01 php-5.5.32]# cd /application/php-5.5.32/etc/
[root@web01 etc]# ls
pear.conf php-fpm.conf.default
[root@web01 etc]# cp php-fpm.conf.default php-fpm.conf
[root@web01 etc]# ll
total 52
-rw-r--r-- 1 root root 1332 Feb 27 22:53 pear.conf
-rw-r--r-- 1 root root 22609 Feb 27 22:56 php-fpm.conf
-rw-r--r-- 1 root root 22609 Feb 27 22:53 php-fpm.conf.default
[root@web01 etc]# /application/php-5.5.32/sbin/php-fpm -t
[27-Feb-2018 22:56:53] NOTICE: configuration file /application/php-5.5.32/etc/php-fpm.conf test is successful
[root@web01 etc]# /application/php-5.5.32/sbin/php-fpm
[root@web01 etc]# ss -lntup |grep 9000
tcp LISTEN 0 16384 127.0.0.1:9000 *:* users:(("php-fpm",129733,7),("php-fpm",129734,0),("php-fpm",129735,0))
####添加到系统命令
[root@web01 etc]# ln -s /application/php-5.5.32/sbin/php-fpm /usr/bin/
#### 启动
[root@web01 etc]# /application/php-5.5.32/sbin/php-fpm -t
[27-Feb-2018 22:56:53] NOTICE: configuration file /application/php-5.5.32/etc/php-fpm.conf test is successful
[root@web01 etc]# /application/php-5.5.32/sbin/php-fpm
[root@web01 etc]# ss -lntup |grep 9000
tcp LISTEN 0 16384 127.0.0.1:9000 *:* users:(("php-fpm",129733,7),("php-fpm",129734,0),("php-fpm",129735,0))
####添加到系统命令
[root@web01 etc]# ln -s /application/php-5.5.32/sbin/php-fpm /usr/bin/
LNMP搭建网站前测试。
测试nginx与php
listen 80;
server_name blog.etiantian.org;
root html/blog;
index index.php index.html index.htm;
location ~ .*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
echo '<?php phpinfo();?>' >/application/nginx/html/blog/test_info.php
server {
listen 80;
server_name blog.etiantian.org;
root html/blog;
index index.php index.html index.htm;
location ~ .*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
echo '<?php phpinfo();?>' >/application/nginx/html/blog/test_info.php

测试php与MySQL
<?php
//$link_id=mysql_connect('主机名','用户','密码');
$link_id=mysql_connect('172.16.1.51','wordpress','123456') or mysql_error();
if($link_id){
echo "mysql successful by oldboy ! \n";
}else{
echo mysql_error();
}
?>
test_mysql.php
<?php
//$link_id=mysql_connect('主机名','用户','密码');
$link_id=mysql_connect('172.16.1.51','wordpress','123456') or mysql_error();
if($link_id){
echo "mysql successful by oldboy ! \n";
}else{
echo mysql_error();
}
?>
部署博客


[root@web01 blog]# rm -f .maintenance
负载均衡与反向代理
区别图例

实际部署

lb01 10.0.0.5 Nginx主负载均衡器
lb02 10.0.0.6 Nginx辅负载均衡器
web01 10.0.0.8 web01服务器
web02 10.0.0.7 web02服务器
HOSTNAME IP 说明
lb01 10.0.0.5 Nginx主负载均衡器
lb02 10.0.0.6 Nginx辅负载均衡器
web01 10.0.0.8 web01服务器
web02 10.0.0.7 web02服务器
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
server {
listen 80;
server_name www.lewen.com;
location / {
root html/www;
index index.html index.htm;
}
access_log logs/access_www.log main;
}
server {
listen 80;
server_name bbs.lewen.com;
location / {
root html/bbs;
index index.html index.htm;
}
access_log logs/access_bbs.log main;
}
}
#web01 web02 nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
server {
listen 80;
server_name www.lewen.com;
location / {
root html/www;
index index.html index.htm;
}
access_log logs/access_www.log main;
}
server {
listen 80;
server_name bbs.lewen.com;
location / {
root html/bbs;
index index.html index.htm;
}
access_log logs/access_bbs.log main;
}
}
for name in www bbs blog ;do echo "`hostname` $name.etiantian.org" > /application/nginx/html/$name/oldboy.html; done
[root@web01 ~]# for name in www bbs blog ;do cat /application/nginx/html/$name/oldboy.html; done
web01 www.etiantian.org
web01 bbs.etiantian.org
web01 blog.etiantian.org
tree /application/nginx/html/ -Ld 1
for name in www bbs blog ;do echo "`hostname` $name.etiantian.org" > /application/nginx/html/$name/oldboy.html; done
[root@web01 ~]# for name in www bbs blog ;do cat /application/nginx/html/$name/oldboy.html; done
web01 www.etiantian.org
web01 bbs.etiantian.org
web01 blog.etiantian.org
[root@lb01 ~]# curl 10.0.0.8/oldboy.html
web01 bbs.etiantian.org
[root@lb01 ~]# curl 10.0.0.7/oldboy.html
web02 bbs.etiantian.org
[root@lb01 ~]# curl -H Host:www.etiantian.org 10.0.0.8/oldboy.html
web01 www.etiantian.org
[root@lb01 ~]# curl -H Host:www.etiantian.org 10.0.0.7/oldboy.html
web02 www.etiantian.org
#web01 web02环境准备完成
[root@lb01 ~]# curl 10.0.0.8/oldboy.html
web01 bbs.etiantian.org
[root@lb01 ~]# curl 10.0.0.7/oldboy.html
web02 bbs.etiantian.org
[root@lb01 ~]# curl -H Host:www.etiantian.org 10.0.0.8/oldboy.html
web01 www.etiantian.org
[root@lb01 ~]# curl -H Host:www.etiantian.org 10.0.0.7/oldboy.html
web02 www.etiantian.org
下面错误的配置
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream server_pools {
server 10.0.0.7:80 weight=1;
server 10.0.0.8:80 weight=1;
}
server {
listen 80;
server_name www.etiantian.org;
location / {
proxy_pass http://server_pools;
}
}
#lb01
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream server_pools {
server 10.0.0.7:80 weight=1;
server 10.0.0.8:80 weight=1;
}
server {
listen 80;
server_name www.etiantian.org;
location / {
proxy_pass http://server_pools;
}
}

wireshark 进行抓包观察
[root@lb01 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;
upstream server_pools {
server 10.0.0.7:80 weight=1;
server 10.0.0.8:80 weight=1;
}
server {
listen 80;
server_name bbs.lewen.com;
location / {
proxy_pass http://server_pools;
proxy_set_header Host $host;
}
}
server {
listen 80;
server_name www.lewen.com;
location / {
proxy_pass http://server_pools;
proxy_set_header Host $host;
}
}
}
proxy_set_header 修改反向代理 向后面发出请求的时候的 请求头的信息
验证故障:
wireshark 进行抓包观察
[root@lb01 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;
upstream server_pools {
server 10.0.0.7:80 weight=1;
server 10.0.0.8:80 weight=1;
}
server {
listen 80;
server_name bbs.lewen.com;
location / {
proxy_pass http://server_pools;
proxy_set_header Host $host;
}
}
server {
listen 80;
server_name www.lewen.com;
location / {
proxy_pass http://server_pools;
proxy_set_header Host $host;
}
}
}
proxy_set_header 修改反向代理 向后面发出请求的时候的 请求头的信息
正确的配置
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream server_pools {
server 10.0.0.7:80 weight=1;
server 10.0.0.8:80 weight=1;
}
server {
listen 80;
server_name bbs.lewen.com;
location / {
proxy_pass http://server_pools;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
server {
listen 80;
server_name www.lewen.com;
location / {
proxy_pass http://server_pools;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
}
让web服务器记录真实的用户ip地址
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream server_pools {
server 10.0.0.7:80 weight=1;
server 10.0.0.8:80 weight=1;
}
server {
listen 80;
server_name bbs.lewen.com;
location / {
proxy_pass http://server_pools;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
server {
listen 80;
server_name www.lewen.com;
location / {
proxy_pass http://server_pools;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
}
测试
web02 www.lewen.com
[root@lb01 conf]# curl -H Host:www.lewen.com 10.0.0.6/oldboy.html
web01 www.lewen.com
[root@lb01 conf]# curl -H Host:www.lewen.com 10.0.0.6/oldboy.html
web02 www.lewen.com
[root@lb01 conf]# curl -H Host:www.lewen.com 10.0.0.6/oldboy.html
web01 www.lewen.com
[root@lb01 conf]# curl -H Host:bbs.lewen.com 10.0.0.6/oldboy.html
web02 bbs.lewen.com
[root@lb01 conf]# curl -H Host:bbs.lewen.com 10.0.0.6/oldboy.html
web01 bbs.lewen.com
[root@lb01 conf]# curl -H Host:bbs.lewen.com 10.0.0.6/oldboy.html
web02 bbs.lewen.com
[root@lb01 conf]# curl -H Host:bbs.lewen.com 10.0.0.6/oldboy.html
web01 bbs.lewen.com
[root@lb01 conf]# curl -H Host:bbs.lewen.com 10.0.0.5/oldboy.html
web01 bbs.lewen.com
[root@lb01 conf]# curl -H Host:bbs.lewen.com 10.0.0.5/oldboy.html
web02 bbs.lewen.com
[root@lb01 conf]# curl -H Host:www.lewen.com 10.0.0.5/oldboy.html
web01 www.lewen.com
[root@lb01 conf]# curl -H Host:www.lewen.com 10.0.0.5/oldboy.html
web02 www.lewen.com
[root@lb01 conf]# curl -H Host:www.lewen.com 10.0.0.6/oldboy.html
web02 www.lewen.com
[root@lb01 conf]# curl -H Host:www.lewen.com 10.0.0.6/oldboy.html
web01 www.lewen.com
[root@lb01 conf]# curl -H Host:www.lewen.com 10.0.0.6/oldboy.html
web02 www.lewen.com
[root@lb01 conf]# curl -H Host:www.lewen.com 10.0.0.6/oldboy.html
web01 www.lewen.com
[root@lb01 conf]# curl -H Host:bbs.lewen.com 10.0.0.6/oldboy.html
web02 bbs.lewen.com
[root@lb01 conf]# curl -H Host:bbs.lewen.com 10.0.0.6/oldboy.html
web01 bbs.lewen.com
[root@lb01 conf]# curl -H Host:bbs.lewen.com 10.0.0.6/oldboy.html
web02 bbs.lewen.com
[root@lb01 conf]# curl -H Host:bbs.lewen.com 10.0.0.6/oldboy.html
web01 bbs.lewen.com
[root@lb01 conf]# curl -H Host:bbs.lewen.com 10.0.0.5/oldboy.html
web01 bbs.lewen.com
[root@lb01 conf]# curl -H Host:bbs.lewen.com 10.0.0.5/oldboy.html
web02 bbs.lewen.com
[root@lb01 conf]# curl -H Host:www.lewen.com 10.0.0.5/oldboy.html
web01 www.lewen.com
[root@lb01 conf]# curl -H Host:www.lewen.com 10.0.0.5/oldboy.html
web02 www.lewen.com
yum install -y keepalived


global_defs {
router_id LB01
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.3/24 dev eth0 label eth0:1
}
}
#keepalive配置文件详解
global_defs {
router_id LB01
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.3/24 dev eth0 label eth0:1
}
}




keepalive基于 服务器 ,除非网段了,电断了,才会飘
#!/bin/bash
if [ `ps -ef |grep nginx|grep -v grep` -eq 0 ];then
/etc/init.d/keepalived stop
fi
[root@lb01 conf]# chmod +x /server/scripts/check_lb.sh
[root@lb01 conf]# cat /server/scripts/check_lb.sh
#!/bin/bash
if [ `ps -ef |grep nginx|grep -v grep` -eq 0 ];then
/etc/init.d/keepalived stop
fi
[root@lb01 conf]# chmod +x /server/scripts/check_lb.sh


script "/server/scripts/check_lb01.sh"
interval 2
weight 2
}
注意 {} 的空格 注意格式标准正确
vrrp_script check_nginx {
script "/server/scripts/check_lb01.sh"
interval 2
weight 2
}
注意 {} 的空格 注意格式标准正确
global_defs {
router_id LB01
}
vrrp_script check_lb {
script "/server/scripts/check_lb.sh"
interval 2
weight 2
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.3/24 dev eth0 label eth0:1
}
track_script {
check_lb
}
}
[root@lb01 keepalived]# cat keepalived.conf
global_defs {
router_id LB01
}
vrrp_script check_lb {
script "/server/scripts/check_lb.sh"
interval 2
weight 2
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.3/24 dev eth0 label eth0:1
}
track_script {
check_lb
}
}




s28 LNMP架构服务搭建的更多相关文章
- Linux:LNMP架构的搭建
LNMP架构的搭建 centos6.8-i686 MySQL PHP Nginx 搭建前先安装一些必要的rpm和php组件(全新系统) yum install -y wget gcc vim* lib ...
- LNMP架构的搭建
第9章 LNMP架构的搭建 9.1 什么是LNMP 9.1.1 LNMP的组成 L linux N nginx:实现静态的服务处理 M ...
- LNMP架构基础搭建
LNMP架构+wordpress博客 环境: centos6.7 2.6.32-573.el6.x86_64 nginx-1.6.3 mysql-5.5.49 php-5.3.27 wordpress ...
- LNMP架构之搭建wordpress博客网站
系统环境版本 [root@db02 ~]# cat /etc/redhat-release CentOS release 6.9 (Final) [root@db02 ~]# uname -a Lin ...
- 企业级LNMP架构搭建实例(基于Centos6.x)
1.1 部署LNMP架构说明 1.1.1 LNMP架构内容 01.部署linux系统 02.部署nginx网站服务 03.部署mysql数据库服务 04.部署php动态解析服务 1.1.2 配置LNM ...
- LNMP架构下Discuz论坛的搭建
在上一节中,我们对lnmp架构下的mysql.php.nginx进行源码的安装,并设置了相关的安装参数.现在我们将在上一节的基础上,把三者联系起来进行一个论坛的部署. 一.首先进行Discuz(社区论 ...
- 部署企业LNMP架构搭建bbs
部署企业LNMP架构 1===============部署Nginx 2===============安装及部署Mysql数据库 3===============安装PHP解析环境 4======== ...
- 高性能Web服务之lnmp架构应用
传统上基于进程或线程模型架构的web服务通过每进程或每线程处理并发连接请求,这势必会在网络和I/O操作时产生阻塞,其另一个必然结果则是对内存或CPU的利用率低下.生成一个新的进程/线程需要事先备好其运 ...
- Linux系统下LNMP架构搭建
一.防火墙状态: 1.查看防火墙状态: systemctl status firewalld service iptables status firewall-cmd --state 2.永久有效开启 ...
随机推荐
- SSM总结
1 报错: cvc-complex-type.2.4.a: Invalid content was found starting with element 'async-supported'. ...
- Kotlin语言学习笔记(5)
委托模式(Delegation) 类的委托 interface Base { fun print() } class BaseImpl(val x: Int) : Base { override fu ...
- time和datetime
一.time模块常用函数1. time()函数time()函数返回的是时间戳(timestamp).所谓时间戳指的是从1970年1月1日00:00:00开始按秒计算的偏移量.其他返回时间戳方式的函数还 ...
- Nexus 安装 使用说明
1 . 私服简介 私服是架设在局域网的一种特殊的远程仓库,目的是代理远程仓库及部署第三方构件.有了私服之后,当 Maven 需要下载构件时,直接请求私服,私服上存在则下载到本地仓库:否则,私服请求外部 ...
- 我在JS上解惑之路1
1.为什么既然存在等号(==)非等号 (!=),又会有全等号(===)非全等号(!==)? *唯一的不同是后者判断时不进行类型转换. 例:var sNum = "66"; var ...
- org.apache.cxf.interceptor.Fault: Unmarshalling Error: 意外的元素 (uri:"", local:"mixornot")。
三月 09, 2018 3:09:14 下午 org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging警告: Interceptor fo ...
- MYSQL错误:You can't specify target table for update in FROM clause
这句话意思是:不能先select再更新(修改)同一个表. 可以再外嵌套多一层,这个问题只有mysql有,mssql和oracle都没有. # 出错delete from Person where Id ...
- 安装完CentOS可以不做的事
添加用户到sudo. 打开/etc/sudoers 找到root ALL=(ALL) ALL这一行,在后面再加上一行就可以了(不用引号): username ALL=(ALL) ALL 注意,都用ta ...
- tcp连接需要注意的问题
当有子进程时,子进程终止时会返回SIGCHLD信号,默认忽略,此时会有僵尸进程. 处理方法: 捕获信号,并waitpid. 当慢系统调用被中断时(如信号中断),有些系统不会自动重启调用,此时系统调用可 ...
- 【Python基础教程第2版】——第二讲:列表和元组
引言: 什么是数据结构? 数据结果是通过某种方式(例如对元素进行编号)组织在一起的数据元素的集合.Python中最常用的数据结构是序列. Python包含6种内建的序列:列表和元组(最常用:列表可以修 ...