MySQL复制、MySQL-proxy
MariaDB, PerconaDB
Innobase
MySQL HA
web: Nginx, LNMP, Memcahed
http://nginx.org/ nginx官网
HTTP服务器,
反向代理:reverse proxy
http
http://www.netcraft.com/ 全球web服务器占有状况
C10K 连接超过10K的问题;
DMA 直接内存访问
单进错:阻塞
多进错:每个进程响应一个请求
进程量大,进错切换次数过多
每个进错的地址空间是独立,很多空间是重复数据,所以内存使用效率较低;
线程:thread, 轻量级进错,进程内部子运行单位,linux并不支持原生态线程;
Light Weight prcess, LMP 轻量级进程
Linux支持多少种类型的线程库?如何切换线程库?
每个线程响应一个请求;
线程依然切换:切换属于轻量级
同意个进程的线程可以共享进程诸多资源,比如打开的文件;
对内存的需求教之略有下降;
快速切换时会带来线程抖动
10K
多进程多线程
多线程:N个请求
一个线程响应多个请求
忙等:自旋锁 Spin lock
闲等:
select(1024)
多路IO, IO复用:
AIO: 异步IO
I/O动作如何执行?
进错无法直接操作I/O设备,其必须通过系统调用请求kernel来协助完成I/O动作
内核会为每个I/O设备维护一个buffer

对于输入而言,等待(wait)数据输入至buffer需要时间,而从buffer复制(copy)数据至进错也需要时间
根据等待模式不同,I/O动作可分为五种模式
Five I/O Models
blocking I/O: blocked all the way(阻塞式I/O)
monblocking I/O: if no data in buffer,immediate returns EWOULDBLOCK(非阻塞I/O)
I/O multiplexing (select and poll): blocked separately in wait and copy(I/O复用)
signal driven I/O (SIGIO): nonblocked in wait but blocked in copy (signaled when I/O can be initiated)(信号驱动I/O)
asynchronous I/O (aio_): nonblocked all the way (signaled when I/O is complete)(异步I/O)
同步I/O和异步I/O
Synchronous I/O: 引起请求进程阻塞,直到I/O完成;
Asynchronous I/O: 不导致请求进错阻塞;

Comparison of Five I/O Models

水平触发
边缘触发
event-drive I/O事件驱动
select(1024),poll(没有文件上限限制,工作机制跟select一样,每段都阻塞)
事件驱动I/O复用:
epoll
/dev/pool
kqueue
mmap: 内存映射
AIO, mmap, event-driven,
httpd:
MPM
prefork: 一个进程响应一个请求,1024
worker: 一个线程响应一个请求,多进程,一个进称生存多个线程
event: 基于事件驱动,
URL rewrite
rabbitma, zeromq(队列管理器): 连接池
keepalive + ningx: 实现高可用
corosync + ningx
IO:模型
nginx:
web服务器
反向代理
web
Tengine(淘宝)
varnish, squid
varnish, nginx: cache(disk)
httpd: cache(disk, memory)
memcache
nginx热部署:平滑升级
referer(反盗链)
user
group
worker
http {
}
server{
localtion{
}
}
}
mail {
}
Nginx
File AIO
Asynchronous
Event-drivent edge trigger
Web服务器
Alias, virtual host, location, authentication, ssl, LEMP
Web reverse proxy
Mail reverse proxy
nginx:
server{}: 虚拟主机
location{}:
location /URI/ {
root "/web/htdocs";
}
httpd:
<DocoumentRoot "">
</DocoumnetRoot>
<Location "/bbs">
</Location>
URI路径:
http://www.magedu.com/
location [ = | ~ | ~* | ^~ ] url { ... }
location URI {}:
对当前路径及子路径下的所有对象都生效
location = URI {}:
精确匹配指定的路径,不包括子路径,因此只对当前资源生效
localtion ~ {}:
localtion ~* {}:
模式匹配URI,此处的URI可使用正则表达式,~区分字符大小写,~*不区分字符大小写;
localtion ^~ URL {}:
不使用正则表达式;
如果被多个模式匹配,匹配顺序:
1、=等于号是优先级最高的;
2、如果没有被=等于号匹配到,所以被非正则表达式匹配到的优先级次之;
3、正则表达式无论是区分大小写还是不区分大小写排在第三位;
4、最后没加任何符号;
/a/3.gif
htpasswd:
第二次不能使用-c选项:
已经接受连接的个数,已经处理的连接的个数,已经处理的请求的个数;
reading: nginx正在读取其首部请求的个数;
writing: nginx正在读取其主体的请求的个数、或正处理着其请求内容的请求的个数或者正在向客户端发送响应的个数;
waiting: 长连接模式中保持连接个数;
LEMP:
PHP+MySQL,
FastCGI:
php-fpm:
127.0.0.1:9000
编译: php
xcache
LEMP: RHEL 6.4 + Nginx-1.4.1 + MySQL-5.6.10 + php-5.4.13 + Xcache-3.0
在网络拥塞控制领域,我们知道有一个非常有名的算法叫做Nagle算法(Nagle algorithm),这是使用它的发明人John Nagle的名字来命名的,John Nagle在1984年首次用这个算法来尝试解决福特汽车公司的网络拥塞问题(RFC 896),该问题的具体描述是:如果我们的应用程序一次产生1个字节的数据,而这个1个字节数据又以网络数据包的形式发送到远端服务器,那么就很容易导致网络由于太多的数据包而过载。比如,当用户使用Telnet连接到远程服务器时,每一次击键操作就会产生1个字节数据,进而发送出去一个数据包,所以,在典型情况下,传送一个只拥有1个字节有效数据的数据包,却要发费40个字节长包头(即ip头20字节+tcp头20字节)的额外开销,这种有效载荷(payload)利用率极其低下的情况被统称之为愚蠢窗口症候群(Silly Window Syndrome)。可以看到,这种情况对于轻负载的网络来说,可能还可以接受,但是对于重负载的网络而言,就极有可能承载不了而轻易的发生拥塞瘫痪。
针对上面提到的这个状况,Nagle算法的改进在于:如果发送端欲多次发送包含少量字符的数据包(一般情况下,后面统一称长度小于MSS的数据包为小包,与此相对,称长度等于MSS的数据包为大包,为了某些对比说明,还有中包,即长度比小包长,但又不足一个MSS的包),则发送端会先将第一个小包发送出去,而将后面到达的少量字符数据都缓存起来而不立即发送,直到收到接收端对前一个数据包报文段的ACK确认、或当前字符属于紧急数据,或者积攒到了一定数量的数据(比如缓存的字符数据已经达到数据包报文段的最大长度)等多种情况才将其组成一个较大的数据包发送出去。
TCP中的Nagle算法默认是启用的,但是它并不是适合任何情况,对于telnet或rlogin这样的远程登录应用的确比较适合(原本就是为此而设计),但是在某些应用场景下我们却又需要关闭它。
Negale算法是指发送方发送的数据不会立即发出, 而是先放在缓冲区, 等缓存区满了再发出. 发送完一批数据后, 会等待接收方对这批数据的回应, 然后再发送下一批数据。Negale 算法适用于发送方需要发送大批量数据, 并且接收方会及时作出回应的场合, 这种算法通过减少传输数据的次数来提高通信效率。如果发送方持续地发送小批量的数据, 并且接收方不一定会立即发送响应数据, 那么Negale算法会使发送方运行很慢. 对于GUI 程序, 如网络游戏程序(服务器需要实时跟踪客户端鼠标的移动), 这个问题尤其突出. 客户端鼠标位置改动的信息需要实时发送到服务器上, 由于Negale 算法采用缓冲, 大大减低了实时响应速度, 导致客户程序运行很慢。这个时候就需要使用TCP_NODELAY选项。
传统上基于进程或线程模型架构的web服务通过每进程或每线程处理并发连接请求,这势必会在网络和I/O操作时产生阻塞,其另一个必然结果则是对内存或CPU的利用率低下。生成一个新的进程/线程需要事先备好其运行时环境,这包括为其分配堆内存和栈内存,以及为其创建新的执行上下文等。这些操作都需要占用CPU,而且过多的进程/线程还会带来线程抖动或频繁的上下文切换,系统性能也会由此进一步下降。
在设计的最初阶段,nginx的主要着眼点就是其高性能以及对物理计算资源的高密度利用,因此其采用了不同的架构模型。受启发于多种操作系统设计中基于“事件”的高级处理机制,nginx采用了模块化、事件驱动、异步、单线程及非阻塞的架构,并大量采用了多路复用及事件通知机制。在nginx中,连接请求由为数不多的几个仅包含一个线程的进程worker以高效的回环(run-loop)机制进行处理,而每个worker可以并行处理数千个的并发连接及请求。
如果负载以CPU密集型应用为主,如SSL或压缩应用,则worker数应与CPU数相同;如果负载以IO密集型为主,如响应大量内容给客户端,则worker数应该为CPU个数的1.5或2倍。
Nginx会按需同时运行多个进程:一个主进程(master)和几个工作进程(worker),配置了缓存时还会有缓存加载器进程(cache loader)和缓存管理器进程(cache manager)等。所有进程均是仅含有一个线程,并主要通过“共享内存”的机制实现进程间通信。主进程以root用户身份运行,而worker、cache loader和cache manager均应以非特权用户身份运行。
主进程主要完成如下工作:
1. 读取并验正配置信息;
2. 创建、绑定及关闭套接字;
3. 启动、终止及维护worker进程的个数;
4. 无须中止服务而重新配置工作特性;
5. 控制非中断式程序升级,启用新的二进制程序并在需要时回滚至老版本;
6. 重新打开日志文件,实现日志滚动;
7. 编译嵌入式perl脚本;
worker进程主要完成的任务包括:
1. 接收、传入并处理来自客户端的连接;
2. 提供反向代理及过滤功能;
3. nginx任何能完成的其它任务;
cache loader进程主要完成的任务包括:
1. 检查缓存存储中的缓存对象;
2. 使用缓存元数据建立内存数据库;
cache manager进程的主要任务:
1. 缓存的失效及过期检验;
Nginx的配置有着几个不同的上下文:main、http、server、upstream和location(还有实现邮件服务反向代理的mail)。配置语法的格式和定义方式遵循所谓的C风格,因此支持嵌套,还有着逻辑清晰并易于创建、阅读和维护等优势。
Nginx的代码是由一个核心和一系列的模块组成, 核心主要用于提供Web Server的基本功能,以及Web和Mail反向代理的功能;还用于启用网络协议,创建必要的运行时环境以及确保不同的模块之间平滑地进行交互。不过,大多跟协议相关的功能和某应用特有的功能都是由nginx的模块实现的。这些功能模块大致可以分为事件模块、阶段性处理器、输出过滤器、变量处理器、协议、upstream和负载均衡几个类别,这些共同组成了nginx的http功能。事件模块主要用于提供OS独立的(不同操作系统的事件机制有所不同)事件通知机制如kqueue或epoll等。协议模块则负责实现nginx通过http、tls/ssl、smtp、pop3以及imap与对应的客户端建立会话。
在nginx内部,进程间的通信是通过模块的pipeline或chain实现的;换句话说,每一个功能或操作都由一个模块来实现。例如,压缩、通过FastCGI或uwsgi协议与upstream服务器通信,以及与memcached建立会话等。
一、安装Nginx:
1、解决依赖关系
编译安装nginx需要事先需要安装开发包组"Development Tools"和 "Development Libraries"。同时,还需要专门安装pcre-devel包:
# yum -y install pcre-devel
2、安装
首先添加用户nginx,实现以之运行nginx服务进程:
# groupadd -r nginx
# useradd -r -g nginx nginx
接着开始编译和安装:
# ./configure \
--prefix=/usr \(默认安装路径)
--sbin-path=/usr/sbin/nginx \(可执行程序路径)
--conf-path=/etc/nginx/nginx.conf \(主配置文件路径)
--error-log-path=/var/log/nginx/error.log \(错误日志)
--http-log-path=/var/log/nginx/access.log \(访问日志)
--pid-path=/var/run/nginx/nginx.pid \(进程文件)
--lock-path=/var/lock/nginx.lock \(锁文件)
--user=nginx \
--group=nginx \
--with-http_ssl_module \(使用http_ssl模块)
--with-http_flv_module \(使用http_flv模块)
--with-http_stub_status_module \(使用http_stub模块,服务器状态模块)
--with-http_gzip_static_module \(使用http_gzip模块,gzip压缩工具)
--http-client-body-temp-path=/var/tmp/nginx/client/ \(用户请求报文到达之后我们要缓存,请求报文主体,)
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \(代理使用临时目录)
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \(fastcgi使用的临时目录)
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \(uwsgi使用的临时目录)
--http-scgi-temp-path=/var/tmp/nginx/scgi \(scgi使用的临时目录)
--with-pcre(使用pcre)
# make && make install
说明:如果想使用nginx的perl模块,可以通过为configure脚本添加--with-http_perl_module选项来实现,但目前此模块仍处于实验性使用阶段,可能会在运行中出现意外,因此,其实现方式这里不再介绍。如果想使用基于nginx的cgi功能,也可以基于FCGI来实现,具体实现方法请参照网上的文档。
3、为nginx提供SysV init脚本:
新建文件/etc/rc.d/init.d/nginx,内容如下:
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/etc/nginx/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs() {
# make required directories
user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
options=`$nginx -V 2>&1 | grep 'configure arguments:'`
for opt in $options; do
if [ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d "=" -f 2`
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
}
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
sleep 1
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
而后为此脚本赋予执行权限:
# chmod +x /etc/rc.d/init.d/nginx
添加至服务管理列表,并让其开机自动启动:
# chkconfig --add nginx
# chkconfig nginx on
而后就可以启动服务并测试了:
# service nginx start
二、安装mysql-5.5.28
1、准备数据存放的文件系统
新建一个逻辑卷,并将其挂载至特定目录即可。这里不再给出过程。
这里假设其逻辑卷的挂载目录为/mydata,而后需要创建/mydata/data目录做为mysql数据的存放目录。
2、新建用户以安全方式运行进程:
# groupadd -r mysql
# useradd -g mysql -r -s /sbin/nologin -M -d /mydata/data mysql
# chown -R mysql:mysql /mydata/data
3、安装并初始化mysql-5.5.28
首先下载平台对应的mysql版本至本地,这里是32位平台,因此,选择的为mysql-5.5.28-linux2.6-i686.tar.gz,其下载位置为ftp://172.16.0.1/pub/Sources/mysql-5.5。
# tar xf mysql-5.5.28-linux2.6-i686.tar.gz -C /usr/local
# cd /usr/local/
# ln -sv mysql-5.5.24-linux2.6-i686 mysql
# cd mysql
# chown -R mysql:mysql .
# scripts/mysql_install_db --user=mysql --datadir=/mydata/data
# chown -R root .
4、为mysql提供主配置文件:
# cd /usr/local/mysql
# cp support-files/my-large.cnf /etc/my.cnf
并修改此文件中thread_concurrency的值为你的CPU个数乘以2,比如这里使用如下行:
thread_concurrency = 2
另外还需要添加如下行指定mysql数据文件的存放位置:
datadir = /mydata/data
5、为mysql提供sysv服务脚本:
# cd /usr/local/mysql
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
添加至服务列表:
# chkconfig --add mysqld
# chkconfig mysqld on
而后就可以启动服务测试使用了。
为了使用mysql的安装符合系统使用规范,并将其开发组件导出给系统使用,这里还需要进行如下步骤:
6、输出mysql的man手册至man命令的查找路径:
编辑/etc/man.config,添加如下行即可:
MANPATH /usr/local/mysql/man
7、输出mysql的头文件至系统头文件路径/usr/include:
这可以通过简单的创建链接实现:
# ln -sv /usr/local/mysql/include /usr/include/mysql
8、输出mysql的库文件给系统库查找路径:
# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
而后让系统重新载入系统库:
# ldconfig
9、修改PATH环境变量,让系统可以直接使用mysql的相关命令。具体实现过程这里不再给出。
三、编译安装php-5.4.4
1、解决依赖关系:
请配置好yum源(可以是本地系统光盘)后执行如下命令:
# yum -y groupinstall "X Software Development"
如果想让编译的php支持mcrypt、mhash扩展和libevent,此处还需要下载ftp://172.16.0.1/pub/Sources/ngnix目录中的如下几个rpm包并安装之:
libmcrypt-2.5.8-4.el5.centos.i386.rpm
libmcrypt-devel-2.5.8-4.el5.centos.i386.rpm
mhash-0.9.9-1.el5.centos.i386.rpm
mhash-devel-0.9.9-1.el5.centos.i386.rpm
mcrypt-2.6.8-1.el5.i386.rpm
最好使用升级的方式安装上面的rpm包,命令格式如下:
# rpm -Uvh
另外,也可以根据需要安装libevent,系统一般会自带libevent,但版本有些低。因此可以升级安装之,它包含如下两个rpm包。
libevent-2.0.17-2.i386.rpm
libevent-devel-2.0.17-2.i386.rpm
说明:libevent是一个异步事件通知库文件,其API提供了在某文件描述上发生某事件时或其超时时执行回调函数的机制,它主要用来替换事件驱动的网络服务器上的event loop机制。目前来说, libevent支持/dev/poll、kqueue、select、poll、epoll及Solaris的event ports。
2、编译安装php-5.4.4
首先下载源码包至本地目录,下载位置ftp://172.16.0.1/pub/Sources/new_lamp。
# tar xf php-5.4.4.tar.bz2
# cd php-5.4.4
# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --enable-fpm --enable-sockets --enable-sysvshm --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-libxml-dir=/usr --enable-xml --with-mhash --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --with-curl
说明:如果前面第1步解决依赖关系时安装mcrypt相关的两个rpm包,此./configure命令还可以带上--with-mcrypt选项以让php支持mycrpt扩展。--with-snmp选项则用于实现php的SNMP扩展,但此功能要求提前安装net-snmp相关软件包。
# make
# make test
# make intall
为php提供配置文件:
# cp php.ini-production /etc/php.ini
为php-fpm提供Sysv init脚本,并将其添加至服务列表:
# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
# chmod +x /etc/rc.d/init.d/php-fpm
# chkconfig --add php-fpm
# chkconfig php-fpm on
为php-fpm提供配置文件:
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
编辑php-fpm的配置文件:
# vim /usr/local/php/etc/php-fpm.conf
配置fpm的相关选项为你所需要的值,并启用pid文件(如下最后一行):
pm.max_children = 150(最大子进程个数)
pm.start_servers = 8(刚开始启动个数)
pm.min_spare_servers = 5(最小空闲数)
pm.max_spare_servers = 10(最大空闲数)
pid = /usr/local/php/var/run/php-fpm.pid(进错文件)
接下来就可以启动php-fpm了:
# service php-fpm start
使用如下命令来验正(如果此命令输出有中几个php-fpm进程就说明启动成功了):
# ps aux | grep php-fpm
四、整合nginx和php5
1、编辑/etc/nginx/nginx.conf,启用如下选项:
location ~ \.php$ {
root html;(网页文件目录)
fastcgi_pass 127.0.0.1:9000;(反省代理,以fastcgi方式,由127.0.0.1:9000处理)
fastcgi_index index.php;(主页面)
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;(fastcgi额外参数配置文件,把脚本名称原样不动的传给fpm的服务器端)
include fastcgi_params;(其他参数包含文件)
}
2、编辑/etc/nginx/fastcgi_params,将其内容更改为如下内容:
fastcgi_param GATEWAY_INTERFACE CGI/1.1;(cgi的接口)
fastcgi_param SERVER_SOFTWARE nginx;(服务器端软件程序)
fastcgi_param QUERY_STRING $query_string;(查询方式)
fastcgi_param REQUEST_METHOD $request_method;(请求方法)
fastcgi_param CONTENT_TYPE $content_type;(内容类型)
fastcgi_param CONTENT_LENGTH $content_length;(内容长度)
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;(网页文件根目录)
fastcgi_param SCRIPT_NAME $fastcgi_script_name;(用户请求的.php页面名称)
fastcgi_param REQUEST_URI $request_uri;(请求那个uri)
fastcgi_param DOCUMENT_URI $document_uri;(网页路径uri)
fastcgi_param DOCUMENT_ROOT $document_root;(根目录)
fastcgi_param SERVER_PROTOCOL $server_protocol;(服务器协议版本)
fastcgi_param REMOTE_ADDR $remote_addr;(远端主机地址,客户端地址)
fastcgi_param REMOTE_PORT $remote_port;(远端主机端口,客户端端口)
fastcgi_param SERVER_ADDR $server_addr;(服务器端地址)
fastcgi_param SERVER_PORT $server_port;(服务器端端口)
fastcgi_param SERVER_NAME $server_name;(服务器端名称)
并在所支持的主页面格式中添加php格式的主页,类似如下:
location / {
root html;
index index.php index.html index.htm;
}
而后重新载入nginx的配置文件:
# service nginx reload
3、在/usr/html新建index.php的测试页面,测试php是否能正常工作:
# cat > /usr/html/index.php << EOF
<?php
phpinfo();
?>
接着就可以通过浏览器访问此测试页面了。
五、安装xcache,为php加速:
1、安装
# tar xf xcache-2.0.0.tar.gz
# cd xcache-2.0.0
# /usr/local/php/bin/phpize
# ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config
# make && make install
安装结束时,会出现类似如下行:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20100525/
2、编辑php.ini,整合php和xcache:
首先将xcache提供的样例配置导入php.ini
# mkdir /etc/php.d
# cp xcache.ini /etc/php.d
说明:xcache.ini文件在xcache的源码目录中。
接下来编辑/etc/php.d/xcache.ini,找到zend_extension开头的行,修改为如下行:
zend_extension = /usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so
注意:如果php.ini文件中有多条zend_extension指令行,要确保此新增的行排在第一位。
3、重新启动php-fpm
# service php-fpm restart
六、补充说明
如果要在SSL中使用php,需要在php的location中添加此选项:
fastcgi_param HTTPS on;
补充阅读材料:
Events is one of paradigms to achieve asynchronous execution. But not all asynchronous systems use events. That is about semantic meaning of these two - one is super-entity of another.
epoll and aio use different metaphors:
epoll is a blocking operation (epoll_wait()) - you block the thread until some event happens and then you dispatch the event to different procedures/functions/branches in your code.
In AIO you pass address of you callback function (completion routine) to the system and the system calls your function when something happens.
Problem with AIO is that your callback function code runs from system thread and so on top of system stack. A few problems with that as you can imagine.
[root@Smoke ~]# yum grouplist(查看Yum源软件包组)
Failed to set locale, defaulting to C
Loaded plugins: product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Group Process
Installed Groups:(已经安装的组)
E-mail server
Fonts
General Purpose Desktop
Graphical Administration Tools
Input Methods
Legacy X Window System compatibility
Installed Language Groups:(已经安装跟语言相关的组)
Chinese Support [zh]
Available Groups:(可以安装的组)
Additional Development
Backup Client
Backup Server
Base
CIFS file server
Client management tools
Compatibility libraries(兼容库)
Console internet tools
Debugging Tools
Desktop
Desktop Debugging and Performance Tools
Desktop Platform
Desktop Platform Development(桌面平台开发)
Development tools(开发工具)
Dial-up Networking Support
Directory Client
Directory Server
Eclipse
Emacs
FCoE Storage Client
FTP server
Graphics Creation Tools
Hardware monitoring utilities
Identity Management Server
Infiniband Support
Internet Browser
Java Platform
KDE Desktop
Large Systems Performance
Legacy UNIX compatibility
Mainframe Access
Messaging Client Support
MySQL Database client
MySQL Database server
NFS file server
Network Infrastructure Server
Network Storage Server
Network file system client
Networking Tools
PHP Support
Performance Tools
Perl Support
PostgreSQL Database client
PostgreSQL Database server
Print Server
Printing client
Remote Desktop Clients
Ruby Support
SNMP Support
Scientific support
Security Tools
Server Platform
Server Platform Development(服务器平台开发)
Smart card support
Storage Availability Tools
System Management
System administration tools
Systems Management Messaging Server support
TeX support
Technical Writing
TurboGears application framework
Virtualization
Virtualization Client
Virtualization Platform
Virtualization Tools
Web Server
Web Servlet Engine
Web-Based Enterprise Management
X Window System
iSCSI Storage Client
Available Language Groups:(支持的语言)
Afrikaans Support [af]
Albanian Support [sq]
Amazigh Support [ber]
Arabic Support [ar]
Armenian Support [hy]
Assamese Support [as]
Azerbaijani Support [az]
Basque Support [eu]
Belarusian Support [be]
Bengali Support [bn]
Bhutanese Support [dz]
Brazilian Portuguese Support [pt_BR]
Breton Support [br]
Bulgarian Support [bg]
Catalan Support [ca]
Chhattisgarhi Support [hne]
Chichewa Support [ny]
Coptic Support [cop]
Croatian Support [hr]
Czech Support [cs]
Danish Support [da]
Dutch Support [nl]
English (UK) Support [en_GB]
Esperanto Support [eo]
Estonian Support [et]
Ethiopic Support [am]
Faroese Support [fo]
Fijian Support [fj]
Filipino Support [fil]
Finnish Support [fi]
French Support [fr]
Frisian Support [fy]
Friulian Support [fur]
Gaelic Support [gd]
Galician Support [gl]
Georgian Support [ka]
German Support [de]
Greek Support [el]
Gujarati Support [gu]
Hebrew Support [he]
Hiligaynon Support [hil]
Hindi Support [hi]
Hungarian Support [hu]
Icelandic Support [is]
Indonesian Support [id]
Interlingua Support [ia]
Inuktitut Support [iu]
Irish Support [ga]
Italian Support [it]
Japanese Support [ja]
Kannada Support [kn]
Kashmiri Support [ks]
Kashubian Support [csb]
Kazakh Support [kk]
Khmer Support [km]
Kinyarwanda Support [rw]
Konkani Support [kok]
Korean Support [ko]
Kurdish Support [ku]
Lao Support [lo]
Latin Support [la]
Latvian Support [lv]
Lithuanian Support [lt]
Low Saxon Support [nds]
Luxembourgish Support [lb]
Macedonian Support [mk]
Maithili Support [mai]
Malagasy Support [mg]
Malay Support [ms]
Malayalam Support [ml]
Maltese Support [mt]
Manx Support [gv]
Maori Support [mi]
Marathi Support [mr]
Mongolian Support [mn]
Myanmar (Burmese) Support [my]
Nepali Support [ne]
Northern Sotho Support [nso]
Norwegian Support [nb]
Occitan Support [oc]
Oriya Support [or]
Persian Support [fa]
Polish Support [pl]
Portuguese Support [pt]
Punjabi Support [pa]
Romanian Support [ro]
Russian Support [ru]
Sanskrit Support [sa]
Sardinian Support [sc]
Serbian Support [sr]
Sindhi Support [sd]
Sinhala Support [si]
Slovak Support [sk]
Slovenian Support [sl]
Somali Support [so]
Southern Ndebele Support [nr]
Southern Sotho Support [st]
Spanish Support [es]
Swahili Support [sw]
Swati Support [ss]
Swedish Support [sv]
Tagalog Support [tl]
Tajik Support [tg]
Tamil Support [ta]
Telugu Support [te]
Tetum Support [tet]
Thai Support [th]
Tibetan Support [bo]
Tsonga Support [ts]
Tswana Support [tn]
Turkish Support [tr]
Turkmen Support [tk]
Ukrainian Support [uk]
Upper Sorbian Support [hsb]
Urdu Support [ur]
Uzbek Support [uz]
Venda Support [ve]
Vietnamese Support [vi]
Walloon Support [wa]
Welsh Support [cy]
Xhosa Support [xh]
Zulu Support [zu]
Done
[root@Smoke ~]# yum -y groupinstall "Development Tools" "Server Platform Libraries"(通过yum源安装开发工具和服务器平台库)
[root@Smoke ~]# lftp 172.16.0.1(连接ftp服务器)
cd ok, cwd=/pub/Sources
lftp 172.16.0.1:/pub/Sources> cd nginx/(切换到nginx目录)
lftp 172.16.0.1:/pub/Sources/nginx> get nginx-1.4.1.tar.gz(下载nginx-1.4.1文件)
767107 bytes transferred
lftp 172.16.0.1:/pub/Sources/nginx> byte(退出)
[root@Smoke ~]# ls(查看当前目录文件及子目录)
anaconda-ks.cfg install.log install.log.syslog nginx-1.4.1.tar.gz
[root@Smoke ~]# date(查看系统时间)
2016年 06月 23日 星期四 08:51:07 CST
[root@Smoke ~]# ntpdate 172.16.100.30(向ntp服务器同步时间)
29 Jun 22:06:17 ntpdate[1815]: step time server 172.16.100.30 offset 88.002380 sec
[root@Smoke ~]# date(查看系统时间)
2016年 06月 29日 星期三 22:10:32 CST
[root@Smoke ~]# tar xf nginx-1.4.1.tar.gz(解压nginx-1.4.1,x解压,f后面跟文件名)
[root@Smoke ~]# ll -h(查看当前目录文件及子目录详细信息)
总用量 784K
-rw-------. 1 root root 865 6月 23 08:13 anaconda-ks.cfg
-rw-r--r--. 1 root root 13K 6月 23 08:13 install.log
-rw-r--r--. 1 root root 3.5K 6月 23 08:12 install.log.syslog
drwxr-xr-x. 8 1001 1001 4.0K 5月 6 2013 nginx-1.4.1
-rw-r--r--. 1 root root 750K 6月 23 08:49 nginx-1.4.1.tar.gz
[root@Smoke ~]# du -sh nginx-1.4.1(查看nginx-1.4.1文件总体大小,-s所有文件总体大小,-h单位换算)
5.2M nginx-1.4.1
[root@Smoke ~]# cd nginx-1.4.1(切换到nginx-1.4.1目录)
[root@Smoke nginx-1.4.1]# ls(查看当前目录文件及子目录)
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
[root@Smoke nginx-1.4.1]# groupadd -r -g 108 nginx(添加nginx系统用户,-r系统用户,-g指定gid)
[root@Smoke nginx-1.4.1]# useradd -r -g 108 -u 108 nginx(添加nginx系统用户,-r指定为系统用户,-g指定加入组,-u指定uid)
[root@Smoke nginx-1.4.1]# rpm -q pcre-devel(查看是否安装pcre-devel软件)
package pcre-devel is not installed
[root@Smoke nginx-1.4.1]# yum -y install pcre-devel(通过yum源安装pcre-devel)
[root@Smoke nginx-1.4.1]# ./configure --help | less(查看nginx的配置帮助)
--help print this message
--prefix=PATH set installation prefix
--sbin-path=PATH set nginx binary pathname
--conf-path=PATH set nginx.conf pathname
--error-log-path=PATH set error log pathname
--pid-path=PATH set nginx.pid pathname
--lock-path=PATH set nginx.lock pathname
--user=USER set non-privileged user for
worker processes
--group=GROUP set non-privileged group for
worker processes
--builddir=DIR set build directory
--with-rtsig_module enable rtsig module(实时信号模块)
--with-select_module enable select module
--without-select_module disable select module
--with-poll_module enable poll module
--without-poll_module disable poll module
--with-file-aio enable file AIO support(支持异步I/O)
--with-ipv6 enable IPv6 support(支持ipv6)
--with-http_ssl_module enable ngx_http_ssl_module
--with-http_spdy_module enable ngx_http_spdy_module
--with-http_realip_module enable ngx_http_realip_module
--with-http_addition_module enable ngx_http_addition_module
--with-http_xslt_module enable ngx_http_xslt_module
--with-http_image_filter_module enable ngx_http_image_filter_module(可以实现图片过滤)
--with-http_geoip_module enable ngx_http_geoip_module(根据用户地理位置信息来做相应处理)
--with-http_sub_module enable ngx_http_sub_module
--with-http_dav_module enable ngx_http_dav_module
--with-http_flv_module enable ngx_http_flv_module
--with-http_mp4_module enable ngx_http_mp4_module
--with-http_gunzip_module enable ngx_http_gunzip_module
--with-http_gzip_static_module enable ngx_http_gzip_static_module
--with-http_random_index_module enable ngx_http_random_index_module
--with-http_secure_link_module enable ngx_http_secure_link_module
--with-http_degradation_module enable ngx_http_degradation_module
--with-http_stub_status_module enable ngx_http_stub_status_module
--without-http_charset_module disable ngx_http_charset_module
--without-http_gzip_module disable ngx_http_gzip_module
--without-http_ssi_module disable ngx_http_ssi_module
--without-http_userid_module disable ngx_http_userid_module
--without-http_access_module disable ngx_http_access_module
--without-http_auth_basic_module disable ngx_http_auth_basic_module
--without-http_autoindex_module disable ngx_http_autoindex_module
--without-http_geo_module disable ngx_http_geo_module
--without-http_map_module disable ngx_http_map_module
--without-http_split_clients_module disable ngx_http_split_clients_module
--without-http_referer_module disable ngx_http_referer_module
--without-http_rewrite_module disable ngx_http_rewrite_module
--without-http_proxy_module disable ngx_http_proxy_module
--without-http_fastcgi_module disable ngx_http_fastcgi_module
--without-http_uwsgi_module disable ngx_http_uwsgi_module
--without-http_scgi_module disable ngx_http_scgi_module
--without-http_memcached_module disable ngx_http_memcached_module
--without-http_limit_conn_module disable ngx_http_limit_conn_module(连接数限制)
--without-http_limit_req_module disable ngx_http_limit_req_module
--without-http_empty_gif_module disable ngx_http_empty_gif_module
--without-http_browser_module disable ngx_http_browser_module
--without-http_upstream_ip_hash_module
disable ngx_http_upstream_ip_hash_module
--without-http_upstream_least_conn_module
disable ngx_http_upstream_least_conn_module
--without-http_upstream_keepalive_module
disable ngx_http_upstream_keepalive_module
--with-http_perl_module enable ngx_http_perl_module(解析perl脚本模块)
--with-perl_modules_path=PATH set Perl modules path(perl模块位置)
--with-perl=PATH set perl binary pathname
--http-log-path=PATH set http access log pathname
--http-client-body-temp-path=PATH set path to store
http client request body temporary files
--http-proxy-temp-path=PATH set path to store
http proxy temporary files
--http-fastcgi-temp-path=PATH set path to store
http fastcgi temporary files
--http-uwsgi-temp-path=PATH set path to store
http uwsgi temporary files
--http-scgi-temp-path=PATH set path to store
http scgi temporary files
--without-http disable HTTP server
--without-http-cache disable HTTP cache
--with-mail enable POP3/IMAP4/SMTP proxy module
--with-mail_ssl_module enable ngx_mail_ssl_module
--without-mail_pop3_module disable ngx_mail_pop3_module
--without-mail_imap_module disable ngx_mail_imap_module
--without-mail_smtp_module disable ngx_mail_smtp_module
--with-google_perftools_module enable ngx_google_perftools_module
--with-cpp_test_module enable ngx_cpp_test_module
--add-module=PATH enable an external module
--with-cc=PATH set C compiler pathname
--with-cpp=PATH set C preprocessor pathname
--with-cc-opt=OPTIONS set additional C compiler options
--with-ld-opt=OPTIONS set additional linker options
--with-cpu-opt=CPU build for the specified CPU, valid values:
pentium, pentiumpro, pentium3, pentium4,
athlon, opteron, sparc32, sparc64, ppc64
--without-pcre disable PCRE library usage
--with-pcre force PCRE library usage
--with-pcre=DIR set path to PCRE library sources
--with-pcre-opt=OPTIONS set additional build options for PCRE
--with-pcre-jit build PCRE with JIT compilation support
--with-md5=DIR set path to md5 library sources
--with-md5-opt=OPTIONS set additional build options for md5
--with-md5-asm use md5 assembler sources
--with-sha1=DIR set path to sha1 library sources
--with-sha1-opt=OPTIONS set additional build options for sha1
--with-sha1-asm use sha1 assembler sources
--with-zlib=DIR set path to zlib library sources
--with-zlib-opt=OPTIONS set additional build options for zlib
--with-zlib-asm=CPU use zlib assembler sources optimized
for the specified CPU, valid values:
pentium, pentiumpro
--with-libatomic force libatomic_ops library usage
--with-libatomic=DIR set path to libatomic_ops library sources
--with-openssl=DIR set path to OpenSSL library sources
--with-openssl-opt=OPTIONS set additional build options for OpenSSL
--with-debug enable debug logging
[root@Smoke nginx-1.4.1]# ./configure \(配置nginx)
> --prefix=/usr \
> --sbin-path=/usr/sbin/nginx \
> --conf-path=/etc/nginx/nginx.conf \
> --error-log-path=/var/log/nginx/error.log \
> --http-log-path=/var/log/nginx/access.log \
> --pid-path=/var/run/nginx/nginx.pid \
> --lock-path=/var/lock/nginx.lock \
> --user=nginx \
> --group=nginx \
> --with-http_ssl_module \
> --with-http_flv_module \
> --with-http_stub_status_module \
> --with-http_gzip_static_module \
> --http-client-body-temp-path=/var/tmp/nginx/client/ \
> --http-proxy-temp-path=/var/tmp/nginx/proxy/ \
> --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
> --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
> --http-scgi-temp-path=/var/tmp/nginx/scgi \
> --with-pcre \
> --with-file-aio \
> --with-http_image_filter_module
checking for OS
+ Linux 2.6.32-358.el6.i686 i686
checking for C compiler ... found
+ using GNU C compiler
+ gcc version: 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
checking for gcc -pipe switch ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... not found
checking for sys/param.h ... found
checking for sys/mount.h ... found
checking for sys/statvfs.h ... found
checking for crypt.h ... found
checking for Linux specific features
checking for epoll ... found
checking for sendfile() ... found
checking for sendfile64() ... found
checking for sys/prctl.h ... found
checking for prctl(PR_SET_DUMPABLE) ... found
checking for sched_setaffinity() ... found
checking for crypt_r() ... found
checking for sys/vfs.h ... found
checking for poll() ... found
checking for /dev/poll ... not found
checking for kqueue ... not found
checking for crypt() ... not found
checking for crypt() in libcrypt ... found
checking for F_READAHEAD ... not found
checking for posix_fadvise() ... found
checking for O_DIRECT ... found
checking for F_NOCACHE ... not found
checking for directio() ... not found
checking for statfs() ... found
checking for statvfs() ... found
checking for dlopen() ... not found
checking for dlopen() in libdl ... found
checking for sched_yield() ... found
checking for SO_SETFIB ... not found
checking for SO_ACCEPTFILTER ... not found
checking for TCP_DEFER_ACCEPT ... found
checking for TCP_KEEPIDLE, TCP_KEEPINTVL, TCP_KEEPCNT ... found
checking for TCP_INFO ... found
checking for accept4() ... found
checking for kqueue AIO support ... not found
checking for Linux AIO support ... found
checking for int size ... 4 bytes
checking for long size ... 4 bytes
checking for long long size ... 8 bytes
checking for void * size ... 4 bytes
checking for uint64_t ... found
checking for sig_atomic_t ... found
checking for sig_atomic_t size ... 4 bytes
checking for socklen_t ... found
checking for in_addr_t ... found
checking for in_port_t ... found
checking for rlim_t ... found
checking for uintptr_t ... uintptr_t found
checking for system byte ordering ... little endian
checking for size_t size ... 4 bytes
checking for off_t size ... 8 bytes
checking for time_t size ... 4 bytes
checking for setproctitle() ... not found
checking for pread() ... found
checking for pwrite() ... found
checking for sys_nerr ... found
checking for localtime_r() ... found
checking for posix_memalign() ... found
checking for memalign() ... found
checking for mmap(MAP_ANON|MAP_SHARED) ... found
checking for mmap("/dev/zero", MAP_SHARED) ... found
checking for System V shared memory ... found
checking for POSIX semaphores ... not found
checking for POSIX semaphores in libpthread ... found
checking for struct msghdr.msg_control ... found
checking for ioctl(FIONBIO) ... found
checking for struct tm.tm_gmtoff ... found
checking for struct dirent.d_namlen ... not found
checking for struct dirent.d_type ... found
checking for sysconf(_SC_NPROCESSORS_ONLN) ... found
checking for openat(), fstatat() ... found
checking for getaddrinfo() ... found
checking for PCRE library ... found
checking for PCRE JIT support ... not found
checking for OpenSSL library ... not found
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.
提示:found找到,not found没有找到,错误,ssl模块需要openssl库;
[root@Smoke nginx-1.4.1]# yum list all | grep openssl(查看yum源只显示openssl相关)
openssl.i686 1.0.0-27.el6 @anaconda-RedHatEnterpriseLinux-201301301449.i386/6.4
krb5-pkinit-openssl.i686 1.10.3-10.el6 Packages
openssl-devel.i686 1.0.0-27.el6 Packages
openssl098e.i686 0.9.8e-17.el6_2.2 Packages
[root@Smoke nginx-1.4.1]# yum info openssl-devel(查看openssl-devel信息)
Loaded plugins: product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Available Packages
Name : openssl-devel
Arch : i686
Version : 1.0.0
Release : 27.el6
Size : 1.1 M
Repo : Packages
Summary : Files for development of applications which will use OpenSSL
URL : http://www.openssl.org/
License : OpenSSL
Description : OpenSSL is a toolkit for supporting cryptography. The openssl-devel
: package contains include files needed to develop applications which
: support various cryptographic algorithms and protocols.
[root@Smoke nginx-1.4.1]# yum -y install openssl-devel(通过yum源安装openssl-devel)
[root@Smoke nginx-1.4.1]# rpm -qi openssl-devel(查看openssl-devel相关信息)
Name : openssl-devel Relocations: (not relocatable)
Version : 1.0.0 Vendor: Red Hat, Inc.
Release : 27.el6 Build Date: 2012年10月12日 星期五 17时55分13秒
Install Date: 2016年06月29日 星期三 22时40分22秒 Build Host: x86-022.build.eng.bos.redhat.com
Group : Development/Libraries(组信息) Source RPM: openssl-1.0.0-27.el6.src.rpm
Size : 2161472 License: OpenSSL
Signature : RSA/8, 2013年01月21日 星期一 22时18分01秒, Key ID 199e2f91fd431d51
Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
URL : http://www.openssl.org/
Summary : Files for development of applications which will use OpenSSL
Description :
OpenSSL is a toolkit for supporting cryptography. The openssl-devel
package contains include files needed to develop applications which
support various cryptographic algorithms and protocols.
[root@Smoke nginx-1.4.1]# ./configure --prefix=/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=
/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.l
ock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_st
atic_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path
=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre --with-file
-aio --with-http_image_filter_module(配置nginx)
checking for OS
+ Linux 2.6.32-358.el6.i686 i686
checking for C compiler ... found
+ using GNU C compiler
+ gcc version: 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
checking for gcc -pipe switch ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... not found
checking for sys/param.h ... found
checking for sys/mount.h ... found
checking for sys/statvfs.h ... found
checking for crypt.h ... found
checking for Linux specific features
checking for epoll ... found
checking for sendfile() ... found
checking for sendfile64() ... found
checking for sys/prctl.h ... found
checking for prctl(PR_SET_DUMPABLE) ... found
checking for sched_setaffinity() ... found
checking for crypt_r() ... found
checking for sys/vfs.h ... found
checking for poll() ... found
checking for /dev/poll ... not found
checking for kqueue ... not found
checking for crypt() ... not found
checking for crypt() in libcrypt ... found
checking for F_READAHEAD ... not found
checking for posix_fadvise() ... found
checking for O_DIRECT ... found
checking for F_NOCACHE ... not found
checking for directio() ... not found
checking for statfs() ... found
checking for statvfs() ... found
checking for dlopen() ... not found
checking for dlopen() in libdl ... found
checking for sched_yield() ... found
checking for SO_SETFIB ... not found
checking for SO_ACCEPTFILTER ... not found
checking for TCP_DEFER_ACCEPT ... found
checking for TCP_KEEPIDLE, TCP_KEEPINTVL, TCP_KEEPCNT ... found
checking for TCP_INFO ... found
checking for accept4() ... found
checking for kqueue AIO support ... not found
checking for Linux AIO support ... found
checking for int size ... 4 bytes
checking for long size ... 4 bytes
checking for long long size ... 8 bytes
checking for void * size ... 4 bytes
checking for uint64_t ... found
checking for sig_atomic_t ... found
checking for sig_atomic_t size ... 4 bytes
checking for socklen_t ... found
checking for in_addr_t ... found
checking for in_port_t ... found
checking for rlim_t ... found
checking for uintptr_t ... uintptr_t found
checking for system byte ordering ... little endian
checking for size_t size ... 4 bytes
checking for off_t size ... 8 bytes
checking for time_t size ... 4 bytes
checking for setproctitle() ... not found
checking for pread() ... found
checking for pwrite() ... found
checking for sys_nerr ... found
checking for localtime_r() ... found
checking for posix_memalign() ... found
checking for memalign() ... found
checking for mmap(MAP_ANON|MAP_SHARED) ... found
checking for mmap("/dev/zero", MAP_SHARED) ... found
checking for System V shared memory ... found
checking for POSIX semaphores ... not found
checking for POSIX semaphores in libpthread ... found
checking for struct msghdr.msg_control ... found
checking for ioctl(FIONBIO) ... found
checking for struct tm.tm_gmtoff ... found
checking for struct dirent.d_namlen ... not found
checking for struct dirent.d_type ... found
checking for sysconf(_SC_NPROCESSORS_ONLN) ... found
checking for openat(), fstatat() ... found
checking for getaddrinfo() ... found
checking for PCRE library ... found
checking for PCRE JIT support ... not found
checking for OpenSSL library ... found
checking for zlib library ... found
checking for GD library ... not found
checking for GD library in /usr/local/ ... not found
checking for GD library in /usr/pkg/ ... not found
checking for GD library in /opt/local/ ... not found
./configure: error: the HTTP image filter module requires the GD library.
You can either do not enable the module or install the libraries.
提示:http image filter模块需要gd库;
[root@Smoke nginx-1.4.1]# yum list all | grep gd(查看yum源列表只显示gd相关)
eggdbus.i686 0.6-3.el6 @anaconda-RedHatEnterpriseLinux-201301301449.i386/6.4
gdb.i686 7.2-60.el6 @Packages
gdbm.i686 1.8.0-36.el6 @anaconda-RedHatEnterpriseLinux-201301301449.i386/6.4
cgdcbxd.i686 1.0.1-2.el6 Packages
gd.i686 2.0.35-11.el6 Packages(gd库)
gdb-gdbserver.i686 7.2-60.el6 Packages
gdm.i686 1:2.30.4-39.el6 Packages
gdm-libs.i686 1:2.30.4-39.el6 Packages
gdm-plugin-fingerprint.i686 1:2.30.4-39.el6 Packages
gdm-plugin-smartcard.i686 1:2.30.4-39.el6 Packages
gdm-user-switch-applet.i686 1:2.30.4-39.el6 Packages
hunspell-gd.noarch 1.0.0-0.3.rc.2.el6 Packages
php-gd.i686 5.3.3-22.el6 Packages
plymouth-gdm-hooks.i686 0.8.3-27.el6 Packages
pulseaudio-gdm-hooks.i686 0.9.21-14.el6_3 Packages
[root@Smoke nginx-1.4.1]# yum -y install gd(通过yum源安装gd)
[root@Smoke nginx-1.4.1]# ./configure --prefix=/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=
/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.l
ock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_st
atic_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path
=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre --with-file
-aio --with-http_image_filter_module(配置nginx)
提示:http image filter模块需要gd库;
[root@Smoke nginx-1.4.1]# rpm -qi gd(查看gd软件信息)
Name : gd Relocations: (not relocatable)
Version : 2.0.35 Vendor: Red Hat, Inc.
Release : 11.el6 Build Date: 2012年09月10日 星期一 14时49分27秒
Install Date: 2016年06月29日 星期三 22时46分08秒 Build Host: x86-001.build.bos.redhat.com
Group : System Environment/Libraries Source RPM: gd-2.0.35-11.el6.src.rpm
Size : 536520 License: MIT
Signature : RSA/8, 2012年09月13日 星期四 21时20分21秒, Key ID 199e2f91fd431d51
Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
URL : http://www.libgd.org/Main_Page
Summary : A graphics library for quick creation of PNG or JPEG images
Description :
The gd graphics library allows your code to quickly draw images
complete with lines, arcs, text, multiple colors, cut and paste from
other images, and flood fills, and to write out the result as a PNG or
JPEG file. This is particularly useful in Web applications, where PNG
and JPEG are two of the formats accepted for inline images by most
browsers. Note that gd is not a paint program.
[root@Smoke nginx-1.4.1]# ldconfig(让系统共享动态链接库)
[root@Smoke nginx-1.4.1]# ./configure --prefix=/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=
/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.l
ock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_st
atic_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path
=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre --with-file
-aio --with-http_image_filter_module(配置nginx)
checking for OS
+ Linux 2.6.32-358.el6.i686 i686
checking for C compiler ... found
+ using GNU C compiler
+ gcc version: 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
checking for gcc -pipe switch ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... not found
checking for sys/param.h ... found
checking for sys/mount.h ... found
checking for sys/statvfs.h ... found
checking for crypt.h ... found
checking for Linux specific features
checking for epoll ... found
checking for sendfile() ... found
checking for sendfile64() ... found
checking for sys/prctl.h ... found
checking for prctl(PR_SET_DUMPABLE) ... found
checking for sched_setaffinity() ... found
checking for crypt_r() ... found
checking for sys/vfs.h ... found
checking for poll() ... found
checking for /dev/poll ... not found
checking for kqueue ... not found
checking for crypt() ... not found
checking for crypt() in libcrypt ... found
checking for F_READAHEAD ... not found
checking for posix_fadvise() ... found
checking for O_DIRECT ... found
checking for F_NOCACHE ... not found
checking for directio() ... not found
checking for statfs() ... found
checking for statvfs() ... found
checking for dlopen() ... not found
checking for dlopen() in libdl ... found
checking for sched_yield() ... found
checking for SO_SETFIB ... not found
checking for SO_ACCEPTFILTER ... not found
checking for TCP_DEFER_ACCEPT ... found
checking for TCP_KEEPIDLE, TCP_KEEPINTVL, TCP_KEEPCNT ... found
checking for TCP_INFO ... found
checking for accept4() ... found
checking for kqueue AIO support ... not found
checking for Linux AIO support ... found
checking for int size ... 4 bytes
checking for long size ... 4 bytes
checking for long long size ... 8 bytes
checking for void * size ... 4 bytes
checking for uint64_t ... found
checking for sig_atomic_t ... found
checking for sig_atomic_t size ... 4 bytes
checking for socklen_t ... found
checking for in_addr_t ... found
checking for in_port_t ... found
checking for rlim_t ... found
checking for uintptr_t ... uintptr_t found
checking for system byte ordering ... little endian
checking for size_t size ... 4 bytes
checking for off_t size ... 8 bytes
checking for time_t size ... 4 bytes
checking for setproctitle() ... not found
checking for pread() ... found
checking for pwrite() ... found
checking for sys_nerr ... found
checking for localtime_r() ... found
checking for posix_memalign() ... found
checking for memalign() ... found
checking for mmap(MAP_ANON|MAP_SHARED) ... found
checking for mmap("/dev/zero", MAP_SHARED) ... found
checking for System V shared memory ... found
checking for POSIX semaphores ... not found
checking for POSIX semaphores in libpthread ... found
checking for struct msghdr.msg_control ... found
checking for ioctl(FIONBIO) ... found
checking for struct tm.tm_gmtoff ... found
checking for struct dirent.d_namlen ... not found
checking for struct dirent.d_type ... found
checking for sysconf(_SC_NPROCESSORS_ONLN) ... found
checking for openat(), fstatat() ... found
checking for getaddrinfo() ... found
checking for PCRE library ... found
checking for PCRE JIT support ... not found
checking for OpenSSL library ... found
checking for zlib library ... found
checking for GD library ... not found
checking for GD library in /usr/local/ ... not found
checking for GD library in /usr/pkg/ ... not found
checking for GD library in /opt/local/ ... not found
./configure: error: the HTTP image filter module requires the GD library.
You can either do not enable the module or install the libraries.
提示:还是缺少gd库,先去掉http image filter模块支持;
[root@Smoke nginx-1.4.1]# ./configure --prefix=/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=
/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.
lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_
static_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-p
ath=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre --with-
file-aio(配置nginx)
[root@Smoke nginx-1.4.1]# make(编译)
[root@Smoke nginx-1.4.1]# make install(安装)
make -f objs/Makefile install
make[1]: Entering directory `/root/nginx-1.4.1'
test -d '/usr' || mkdir -p '/usr'
test -d '/usr/sbin' || mkdir -p '/usr/sbin'
test ! -f '/usr/sbin/nginx' || mv '/usr/sbin/nginx' '/usr/sbin/nginx.old'
cp objs/nginx '/usr/sbin/nginx'
test -d '/etc/nginx' || mkdir -p '/etc/nginx'
cp conf/koi-win '/etc/nginx'
cp conf/koi-utf '/etc/nginx'
cp conf/win-utf '/etc/nginx'
test -f '/etc/nginx/mime.types' || cp conf/mime.types '/etc/nginx'
cp conf/mime.types '/etc/nginx/mime.types.default'
test -f '/etc/nginx/fastcgi_params' || cp conf/fastcgi_params '/etc/nginx'
cp conf/fastcgi_params '/etc/nginx/fastcgi_params.default'
test -f '/etc/nginx/fastcgi.conf' || cp conf/fastcgi.conf '/etc/nginx'
cp conf/fastcgi.conf '/etc/nginx/fastcgi.conf.default'
test -f '/etc/nginx/uwsgi_params' || cp conf/uwsgi_params '/etc/nginx'
cp conf/uwsgi_params '/etc/nginx/uwsgi_params.default'
test -f '/etc/nginx/scgi_params' || cp conf/scgi_params '/etc/nginx'
cp conf/scgi_params '/etc/nginx/scgi_params.default'
test -f '/etc/nginx/nginx.conf' || cp conf/nginx.conf '/etc/nginx/nginx.conf'
cp conf/nginx.conf '/etc/nginx/nginx.conf.default'
test -d '/var/run/nginx' || mkdir -p '/var/run/nginx'
test -d '/var/log/nginx' || mkdir -p '/var/log/nginx'
test -d '/usr/html' || cp -R html '/usr'
test -d '/var/log/nginx' || mkdir -p '/var/log/nginx'
make[1]: Leaving directory `/root/nginx-1.4.1'
[root@Smoke nginx-1.4.1]# vim /etc/rc.d/init.d/nginx(编辑nginx服务脚本)
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/etc/nginx/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs() {
# make required directories
user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
options=`$nginx -V 2>&1 | grep 'configure arguments:'`
for opt in $options; do
if [ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d "=" -f 2`
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
}
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
sleep 1
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
[root@Smoke nginx-1.4.1]# chmod +x /etc/rc.d/init.d/nginx(给nginx执行权限)
[root@Smoke nginx-1.4.1]# chkconfig --add nginx(将nginx添加到服务列表)
[root@Smoke nginx-1.4.1]# chkconfig --list nginx(查看nginx服务在相关系统级别启动情况)
nginx 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
[root@Smoke nginx-1.4.1]# service nginx start(启动nginx服务)
正在启动 nginx: [确定]
[root@Smoke nginx-1.4.1]# ls /var/tmp/(查看/var/tmp目录文件及子目录)
nginx
[root@Smoke nginx-1.4.1]# ls /var/tmp/nginx/(查看/var/tmp/nginx目录文件及子目录)
client fcgi proxy scgi uwsgi
测试:通过windows的ie浏览器访问http://172.16.100.106,正常访问;

[root@Smoke ~]# cd /usr/html/(切换到/usr/html目录)
[root@Smoke html]# ls(查看当前目录文件及子目录)
50x.html index.html
[root@Smoke html]# less index.html(分页显示index.html文件内容)
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
(END)
[root@Smoke html]# pwd(查看当前所处的路径)
/usr/html
[root@Smoke html]# cd /etc/nginx/(切换到/etc/nginx目录)
[root@Smoke nginx]# ls(查看当前目录文件及子目录)
fastcgi.conf(实现fastcgi) fastcgi_params(实现fastcgi) koi-utf mime.types(多用途互联网邮件扩展,识别非文本文档的)
nginx.conf(主配置文件) scgi_params uwsgi_params(跟phton结合) win-utf
fastcgi.conf.default fastcgi_params.default koi-win mime.types.default nginx.conf.default
scgi_params.default uwsgi_params.default
提示:.default是nginx安装默认提供的配置文件,其他都是指定编译选项修改以后的版本,
[root@Smoke nginx]# cp nginx.conf nginx.conf.bak(复制nginx.conf为nginx.conf.bak)
[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
#user nobody;(全局参数)
worker_processes 2;(启动的worker线程数,跟cpu个数相关)
#error_log logs/error.log;(定义错误日志)
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;(定义pid文件)
events {
worker_connections 1024;(事件驱动当中每一个每一个worker所能能支持的连接数,两个worker支持2048个连接)
}
http {
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;(打开sendfile功能)
#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;(相对于uri网页的位置)
index index.html index.htm;(主页面)
}
error_page 500 502 503 504 /50x.html;(定义错误页面,如果错误代码是500、502、503、504就读取/50x.html文件)
location = /50x.html {(如果访问的是50x.html)
root html;(到html找这个文件)
}
[root@Smoke ~]# cd /usr/html/(切换到/usr/html目录)
[root@Smoke html]# ls(查看当前目录文件及子目录)
50x.html index.html
[root@Smoke html]# mkdir -pv /web/htdocs(创建/web/htdocs目录,-p递归创建,-v显示创建过程)
mkdir: 已创建目录 "/web"
mkdir: 已创建目录 "/web/htdocs"
[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
location / {
root /web/htdocs;(修改网页文件工作目录)
index index.html index.htm;
}
[root@Smoke nginx]# service nginx reload(重新载入nginx服务)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新载入 nginx: [确定]
[root@Smoke nginx]# vim /web/htdocs/index.html(编辑index.html文件)
<h1>Test Page </h1>
测试:通过Windows的ie浏览器访问http://172.16.100.106,可以正常访问;

[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
location / {
root /web/htdocs;
index index.html index.htm;
}
location /bbs {
root /web/bbs;
}
[root@Smoke nginx]# mkdir /web/bbs(创建目录/web/bbs)
[root@Smoke nginx]# vim /web/bbs/index.html(编辑index.html文件)
<h1>BBS</h1>
[root@Smoke nginx]# service nginx reload(重启nginx服务)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新载入 nginx: [确定]
测试:通过Windows的ie浏览器访问http:/172.16.100.106/bbs,无法访问;

测试:通过Windows的ie浏览器访问http:/172.16.100.106/bbs/index.html,无法访问;

[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
location / {
root /web/htdocs;
index index.html index.htm;
}
location /bbs/ {(给/bbs后面加/斜线)
root /web/bbs;
}
[root@Smoke nginx]# service nginx reload(重新载入nginx)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新载入 nginx: [确定]
测试:通过Windows的ie浏览器访问http:/172.16.100.106/bbs,无法访问;

测试:通过Windows的ie浏览器访问http:/172.16.100.106/bbs/index.html,无法访问;

[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
location / {
root /web/htdocs;
index index.html index.htm;
}
location /bbs/ {
root /web/bbs;
index index.html index.htm;
}
[root@Smoke nginx]# service nginx reload(重新加载nginx服务)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新载入 nginx: [确定]
[root@Smoke nginx]# service nginx restart(重启nginx服务)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
停止 nginx: [确定]
正在启动 nginx: [确定]
测试:通过Windows的ie浏览器访问http:/172.16.100.106/bbs,无法访问;

测试:通过Windows的ie浏览器访问http:/172.16.100.106/bbs/index.html,无法访问;

[root@Smoke nginx]# tail /var/log/nginx/access.log(查看access.log访问日志后10行)
172.16.100.254 - - [30/Jun/2016:00:51:23 +0800] "GET /bbs/index.html HTTP/1.1" 404 570 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36"
172.16.100.254 - - [30/Jun/2016:00:51:26 +0800] "GET /bbs HTTP/1.1" 404 570 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36"
172.16.100.254 - - [30/Jun/2016:00:51:27 +0800] "GET /bbs/index.html HTTP/1.1" 404 570 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36"
172.16.100.254 - - [30/Jun/2016:00:51:27 +0800] "GET /bbs/index.html HTTP/1.1" 404 570 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36"
172.16.100.254 - - [30/Jun/2016:00:51:28 +0800] "GET /bbs/index.html HTTP/1.1" 404 570 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36"
172.16.100.254 - - [30/Jun/2016:00:51:28 +0800] "GET /bbs/index.html HTTP/1.1" 404 570 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36"
172.16.100.254 - - [30/Jun/2016:00:51:28 +0800] "GET /bbs/index.html HTTP/1.1" 404 570 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36"
172.16.100.254 - - [30/Jun/2016:00:51:32 +0800] "GET /bbs HTTP/1.1" 404 570 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36"
172.16.100.254 - - [30/Jun/2016:00:51:34 +0800] "GET /bbs/ HTTP/1.1" 404 570 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36"
172.16.100.254 - - [30/Jun/2016:00:51:35 +0800] "GET /bbs/ HTTP/1.1" 404 570 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36"
[root@Smoke nginx]# tail /var/log/nginx/error.log(查看error.log日志文件后10行)
2016/06/30 00:51:23 [error] 9454#0: *1 open() "/web/bbs/bbs/index.html" failed (2: No such file or directory), client: 172.16.100.254,
server: localhost, request: "GET /bbs/index.html HTTP/1.1", host: "172.16.100.106"
2016/06/30 00:51:26 [error] 9454#0: *1 open() "/web/htdocs/bbs" failed (2: No such file or directory), client: 172.16.100.254, server:
localhost, request: "GET /bbs HTTP/1.1", host: "172.16.100.106"
2016/06/30 00:51:27 [error] 9454#0: *1 open() "/web/bbs/bbs/index.html" failed (2: No such file or directory), client: 172.16.100.254,
server: localhost, request: "GET /bbs/index.html HTTP/1.1", host: "172.16.100.106"
2016/06/30 00:51:27 [error] 9454#0: *1 open() "/web/bbs/bbs/index.html" failed (2: No such file or directory), client: 172.16.100.254,
server: localhost, request: "GET /bbs/index.html HTTP/1.1", host: "172.16.100.106"
2016/06/30 00:51:28 [error] 9454#0: *1 open() "/web/bbs/bbs/index.html" failed (2: No such file or directory), client: 172.16.100.254,
server: localhost, request: "GET /bbs/index.html HTTP/1.1", host: "172.16.100.106"
2016/06/30 00:51:28 [error] 9454#0: *1 open() "/web/bbs/bbs/index.html" failed (2: No such file or directory), client: 172.16.100.254,
server: localhost, request: "GET /bbs/index.html HTTP/1.1", host: "172.16.100.106"
2016/06/30 00:51:28 [error] 9454#0: *1 open() "/web/bbs/bbs/index.html" failed (2: No such file or directory), client: 172.16.100.254,
server: localhost, request: "GET /bbs/index.html HTTP/1.1", host: "172.16.100.106"
2016/06/30 00:51:32 [error] 9454#0: *1 open() "/web/htdocs/bbs" failed (2: No such file or directory), client: 172.16.100.254, server:
localhost, request: "GET /bbs HTTP/1.1", host: "172.16.100.106"
2016/06/30 00:51:34 [error] 9454#0: *1 "/web/bbs/bbs/index.html" is not found (2: No such file or directory), client: 172.16.100.254,
server: localhost, request: "GET /bbs/ HTTP/1.1", host: "172.16.100.106"
2016/06/30 00:51:35 [error] 9454#0: *1 "/web/bbs/bbs/index.html" is not found (2: No such file or directory), client: 172.16.100.254,
server: localhost, request: "GET /bbs/ HTTP/1.1", host: "172.16.100.106"
[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
location / {
root /web/htdocs;
index index.html index.htm;
}
location /bbs/ {
root /web;(网页目录要合并起来,/web/bbs)
index index.html index.htm;
}
[root@Smoke nginx]# service nginx reload(重新翟如nginx服务)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新载入 nginx: [确定]
测试:通过Windows的ie浏览器访问http://172.16.100.106/bbs,正常访问;

[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
error_page 404 /404.html;(启用404的错误页面)
[root@Smoke nginx]# vim /web/htdocs/404.html(编辑404.html文件)
<h1>404 page</h1>
[root@Smoke nginx]# service nginx reload(重新载入nginx服务)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新载入 nginx: [确定]
测试:通过Windows的ie浏览器访问http://172.16.100.106/6.html,返回错误页面,6.html是个不存在的页面,访问不存在的页面就返回404页面,一旦产生404请求就返回自定义404页面;

[root@Smoke nginx]# vim nginx.conf(编辑)
location /bbs/ {
root /web;
index index.html index.htm;
deny 172.16.100.254;(拒绝172.16.100.254访问)
}
[root@Smoke nginx]# service nginx reload(重新翟如nginx服务)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新载入 nginx: [确定]
测试:通过Windows的ie浏览器访问http://172.16.100.106/bbs,无法访问;

测试:通过其他linux主机访问http://172.16.100.106:/bbs,正常访问;
[root@localhost ~]# curl http://172.16.100.106/bbs/index.htmlhtml(访问172.16.100.106/bbs/index.html网页)
<h1>BBS</h1>
[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf文件)
location /bbs/ {
root /web;
index index.html index.htm;
allow 172.16.100.254;(允许172.16.100.254访问)
}
[root@Smoke nginx]# service nginx reload(重新载入nginx服务)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新载入 nginx: [确定]
测试:通过Windows的ie浏览器访问http://172.16.100.106/bbs,正常访问;

测试:通过其他linux主机访问http://172.16.100.106:/bbs,正常访问;
[root@localhost ~]# curl http://172.16.100.106/bbs/index.htmlhtml(访问172.16.100.106/bbs/index.html网页)
<h1>BBS</h1>
提示:默认过滤规则是允许的,所以要想拒绝所有必须要明确显示声明;
[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
location /bbs/ {
root /web;
index index.html index.htm;
allow 172.16.100.254;
deny all;
}
[root@Smoke nginx]# service nginx reload(重新载入nginx服务)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新载入 nginx: [确定]
测试:通过Windows的ie浏览器访问http://172.16.100.106/bbs,正常访问;

测试:通过其他linux主机访问http://172.16.100.106:/bbs,无法访问;
[root@localhost ~]# curl http://172.16.100.106/bbs/index.html(访问172.16.100.106/bbs/index.html网页)
<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.4.1</center>
</body>
</html>
[root@Smoke nginx]# yum -y install httpd(安装httpd软件)
[root@Smoke nginx]# chkconfig --list httpd(查看httpd服务开机启动情况)
httpd 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
[root@Smoke nginx]# htpasswd --help(查看htpasswd命令帮助)
Usage:
htpasswd [-cmdpsD] passwordfile(密码文件) username(用户名)
htpasswd -b[cmdpsD] passwordfile username password
htpasswd -n[mdps] username
htpasswd -nb[mdps] username password
-c Create a new file.(创建文件)
-n Don't update file; display results on stdout.
-m Force MD5 encryption of the password.(md5加密)
-d Force CRYPT encryption of the password (default).
-p Do not encrypt the password (plaintext).
-s Force SHA encryption of the password.
-b Use the password from the command line rather than prompting for it.
-D Delete the specified user.
On Windows, NetWare and TPF systems the '-m' flag is used by default.
On all other systems, the '-p' flag will probably not work.
[root@Smoke nginx]# htpasswd -c -m /etc/nginx/.users tom(创建tom用户认证文件.users,-c创建,-m使用md5加密存放,)
New password:
Re-type new password:
Adding password for user tom
[root@Smoke nginx]# htpasswd -m /etc/nginx/.users jerry(创建jerry用户认证文件.users,-c创建,-m指定使用md5加密存放)
New password:
Re-type new password:
Adding password for user jerry
[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
location /bbs/ {
root /web;
index index.html index.htm;
auth_basic "Restricted Area...";(指定认证提示符)
auth_basic_user_file /etc/nginx/.users;(指定认证文件)
}
[root@Smoke nginx]# service nginx reload(重新载入nginx服务)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新载入 nginx: [确定]
测试:通过Windows的ie浏览器访问http://172.16.100.106/bbs,需要认证,输入帐号tom,密码redhat;

正常访问;

[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
location / {
root /web/htdocs;
index home.html;(修改主页为home.html)
}
location /bbs/ {
root /web;
index home.html;(修改主页为home.html)
auth_basic "Restricted Area...";
auth_basic_user_file /etc/nginx/.users;
}
[root@Smoke nginx]# service nginx reload(重新载入nginx服务)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新载入 nginx: [确定]
测试:通过Windows的ie浏览器访问http://172.16.100.106,无法访问,默认不允许autoindex;

[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
location / {
root /web/htdocs;
index home.html;
autoindex on;(启用自动索引,如果没有主页,列出文件列表)
}
[root@Smoke nginx]# service nginx reload(重新载入nginx服务)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新载入 nginx: [确定]
测试:通过Windows的ie浏览器访问http://172.16.100.106,可以访问,显示根目录文件列表;

[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
location / {
root /web/htdocs;
index home.html;
autoindex on;
}
location /status {
stub_status on;(开启状态)
}
location /bbs/ {
root /web;
index home.html;
auth_basic "Restricted Area...";
auth_basic_user_file /etc/nginx/.users;
}
[root@Smoke nginx]# service nginx reload(重新翟如nginx服务)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新载入 nginx: [确定]
测试:通过Windows的ie浏览器访问172.16.100.106/status,正常访问;

提示:当前活动连接数1,接受的请求个数23,已经处理过的连接数23,已经处理过的请求数38,Reading:正在接进来请求个数,Writing:读了请求主题,除了请求,正在响应客户端,Waiting:处理长连接状态,而目前又处于活动状态;
[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
HTTPS server
server {
listen 443;
server_name localhost;
ssl on;(打开ssl功能)
ssl_certificate /etc/nginx/ssl/nginx.cert;(证书)
ssl_certificate_key /etc/nginx/ssl/nginx.key;(私钥)
ssl_session_timeout 5m;(会话超时时间)
ssl_protocols SSLv2 SSLv3 TLSv1;(使用的协议)
ssl_ciphers HIGH:!aNULL:!MD5;(加密算法)
ssl_prefer_server_ciphers on;(是否允许服务端选择倾向的加密算法)
location / {
root html;(网页文件位置)
index index.html index.htm;
}
}
:.,$s/^\([[:space:]]*\)#/\1/g(查找当前行到最后一行,以任意长度空白行开始后面为#号的行替换为小括号内的内容)
[root@Smoke nginx]# vim /etc/pki/tls/openssl.cnf(编辑openssl.cnf配置文件)
[ CA_default ]
dir = /etc/pki/CA # Where everything is kept
certs = $dir/certs # Where the issued certs are kept
crl_dir = $dir/crl # Where the issued crl are kept
database = $dir/index.txt # database index file.
#unique_subject = no # Set to 'no' to allow creation of
# several ctificates with same subject.
new_certs_dir = $dir/newcerts # default place for new certs.
certificate = $dir/cacert.pem # The CA certificate
serial = $dir/serial # The current serial number
crlnumber = $dir/crlnumber # the current crl number
# must be commented out to leave a V1 CRL
crl = $dir/crl.pem # The current CRL
private_key = $dir/private/cakey.pem# The private key
RANDFILE = $dir/private/.rand # private random number file
[root@Smoke nginx]# cd /etc/pki/CA/(切换到/etc/pki/CA目录)
[root@Smoke CA]# ls(查看当前目录文件及子目录)
certs crl newcerts private
[root@Smoke CA]# ls private/(查看private目录文件及子目录)
[root@Smoke CA]# (umask 077;openssl genrsa 2048 > private/cakey.pem)(创建cakey.pem私钥,长度为2048,umask指定文件遮罩码)
Generating RSA private key, 2048 bit long modulus
.....+++
.........+++
e is 65537 (0x10001)
[root@Smoke CA]# openssl req -new -x509 -key private/cakey.pem -out cacert.pem(生成自签证书,-new新的请求,-x509自签证书,-key指定私钥文件,-out指定
生成证书报文目录)
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:HA
Locality Name (eg, city) [Default City]:ZZ
Organization Name (eg, company) [Default Company Ltd]:MageEdu
Organizational Unit Name (eg, section) []:Tech
Common Name (eg, your name or your server's hostname) []:ca.magedu.com
Email Address []:caadmin@magedu.com
[root@Smoke CA]# touch serial(创建serial文件)
[root@Smoke CA]# echo 01 > serial(显示01到serial文件)
[root@Smoke CA]# touch index.txt(创建index.txt文件)
[root@Smoke CA]# cd(切换到用户家目录)
[root@Smoke ~]# cd /etc/nginx/(切换到/etc/nginx目录)
[root@Smoke nginx]# mkdir ssl(创建ssl目录)
[root@Smoke nginx]# cd ssl/(切换到ssl目录)
[root@Smoke ssl]# (umask 077;openssl genrsa 1024 > nginx.key)(生成私钥)
Generating RSA private key, 1024 bit long modulus
........................++++++
...............................++++++
e is 65537 (0x10001)
[root@Smoke ssl]# openssl req -new -key nginx.key -out nginx.csr(生成证书请求,-new新的,-key指定私钥,-out指定保存路径)
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:HA
Locality Name (eg, city) [Default City]:ZZ
Organization Name (eg, company) [Default Company Ltd]:MageEdu
Organizational Unit Name (eg, section) []:Tech
Common Name (eg, your name or your server's hostname) []:www.magedu.com
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
[root@Smoke ssl]# openssl ca -in nginx.csr -out nginx.crt -days 3650(签发证书请求,-in指定证书请求,-out指定签发后保存目录,-days指定有效期限)
Using configuration from /etc/pki/tls/openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
Serial Number: 1 (0x1)
Validity
Not Before: Jun 29 19:06:43 2016 GMT
Not After : Jun 27 19:06:43 2026 GMT
Subject:
countryName = CN
stateOrProvinceName = HA
organizationName = MageEdu
organizationalUnitName = Tech
commonName = www.magedu.com
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
Netscape Comment:
OpenSSL Generated Certificate
X509v3 Subject Key Identifier:
52:7C:B3:9B:1E:C2:00:36:DA:88:B9:1C:8B:3D:12:BF:09:09:46:03
X509v3 Authority Key Identifier:
keyid:D5:9C:0F:21:AC:8B:8A:85:C5:10:A2:95:F8:B1:C0:E6:19:9F:8A:22
Certificate is to be certified until Jun 27 19:06:43 2026 GMT (3650 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
[root@Smoke ssl]# service nginx reload(重新加载nginx服务,)
nginx: [emerg] BIO_new_file("/etc/nginx/ssl/nginx.cert") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen
('/etc/nginx/ssl/nginx.cert','r') error:2006D080:BIO routines:BIO_new_file:no such file)
nginx: configuration file /etc/nginx/nginx.conf test failed
提示:/etc/nginx/ssl/nginx.cert写错了,应该为nginx.crt;
[root@Smoke ssl]# cd ..(切换到上级目录)
[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
server {
listen 443;
server_name localhost;
ssl on;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root /web/ssl;
index index.html index.htm;
}
}
[root@Smoke nginx]# service nginx reload(重新加载nginx服务)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新载入 nginx: [确定]
[root@Smoke nginx]# netstat -tnlp(查看系统服务,-t代表tcp,-n以数字显示,-l监听端口,-p显示服务名称)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 9451/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1059/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1137/master
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 9628/sshd
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 9451/nginx
tcp 0 0 :::22 :::* LISTEN 1059/sshd
tcp 0 0 ::1:25 :::* LISTEN 1137/master
tcp 0 0 ::1:6010 :::* LISTEN 9628/sshd
测试:通过Windows的ie浏览器访问https://172.16.100.106,无法访问;

[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
server {
listen 443;
server_name localhost;
ssl on;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root /web/htdocs;
index index.html index.htm;
}
}
[root@Smoke nginx]# service nginx reload(重新翟如nginx服务)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新载入 nginx: [确定]
测试:通过Windows的ie浏览器访问https://172.16.100.106,正常访问;

[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
server {
listen 80;
server_name www.magedu.com;
server {
listen 80;
server_name www.a.org;
location / {
root /web/a.org;
index index.html;
}
}
:set nohlsearch(去掉高亮搜索显示)
[root@Smoke nginx]# mkdir /web/a.org(创建/web/a.org目录)
[root@Smoke nginx]# vim /web/a.org/index.html(编辑index.html文件)
a.org
[root@Smoke nginx]# nginx -t(测试nginx配置文件语法)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@Smoke nginx]# service nginx configtest(测试nginx配置文件语法)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@Smoke nginx]# service nginx reload(重新加载nginx服务)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新载入 nginx: [确定]
测试:通过linux访问基于主机名的虚拟主机,正常访问;
[root@localhost ~]# vim /etc/hosts(编辑hosts文件) # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 172.16.100.106 www.magedu.com 172.16.100.106 www.a.org [root@localhost ~]# curl http://www.magedu.com/index.html(访问主机名为www.magedu.com的index.html网页文件) <h1>Test Page </h1> [root@localhost ~]# curl http://www.a.org/index.html(访问主机名为www.a.org的index.html网页文件) a.org [root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
LEMP配置:
[root@Smoke nginx]# cd(切换到用户家目录)
[root@Smoke nginx]# lftp 172.16.0.1(连接ftp服务器)
cd ok, cwd=/pub/Sources
lftp 172.16.0.1:/pub/Sources> cd mysql-5.6/(切换到mysql-5.6目录)
lftp 172.16.0.1:/pub/Sources/mysql-5.6> get mysql-5.6.10-linux.glibc2.5-i686.tar.gz(下载mysql-5.6.10)
295416271 bytes transferred in 9 seconds (31.28M/s)
lftp 172.16.0.1:/pub/Sources/mysql-5.6> bye(退出)
[root@Smoke ~]# ls(查看当前目录文件及子目录)
anaconda-ks.cfg install.log install.log.syslog mysql-5.6.10-linux-glibc2.5-i686.tar.gz nginx-1.4.1 nginx-1.4.1.tar.gz
[root@Smoke ~]# tar xf mysql-5.6.10-linux-glibc2.5-i686.tar.gz -C /usr/local/(解压mysql-5.6.10到/usr/local)
[root@Smoke ~]# mkdir -pv /mydata/data(创建/mydata/data目录,-p递归创建,-v显示创建过程)
mkdir: 已创建目录 "/mydata"
mkdir: 已创建目录 "/mydata/data"
[root@Smoke ~]# useradd -r mysql(添加系统用户mysql)
[root@Smoke ~]# chown -R mysql.mysql /mydata/data/(更改/mydata/data目录文件属主属组为mysql,-R递归更改)
[root@Smoke ~]# cd /usr/local/(切换到/usr/local目录)
[root@Smoke local]# ls(查看当前目录文件及子目录)
bin etc games include lib libexec mysql-5.6.10-linux-glibc2.5-i686 sbin share src
[root@Smoke local]# ln -sv mysql-5.6.10-linux-glibc2.5-i686 mysql(给mysql-5.6.10创建软连接叫mysql,-s软连接,-v显示创建过程)
"mysql" -> "mysql-5.6.10-linux-glibc2.5-i686"
[root@Smoke local]# cd mysql(切换到mysql目录)
[root@Smoke mysql]# ll(查看当前目录文件及子目录详细信息)
总用量 76
drwxr-xr-x. 2 root root 4096 6月 30 03:50 bin
-rw-r--r--. 1 7161 wheel 17987 1月 23 2013 COPYING
drwxr-xr-x. 4 root root 4096 6月 30 03:50 data
drwxr-xr-x. 2 root root 4096 6月 30 03:50 docs
drwxr-xr-x. 3 root root 4096 6月 30 03:50 include
-rw-r--r--. 1 7161 wheel 7468 1月 23 2013 INSTALL-BINARY
drwxr-xr-x. 3 root root 4096 6月 30 03:50 lib
drwxr-xr-x. 4 root root 4096 6月 30 03:50 man
drwxr-xr-x. 10 root root 4096 6月 30 03:51 mysql-test
-rw-r--r--. 1 7161 wheel 2552 1月 23 2013 README
drwxr-xr-x. 2 root root 4096 6月 30 03:50 scripts
drwxr-xr-x. 28 root root 4096 6月 30 03:50 share
drwxr-xr-x. 4 root root 4096 6月 30 03:50 sql-bench
drwxr-xr-x. 3 root root 4096 6月 30 03:50 support-files
[root@Smoke mysql]# chown -R root.mysql ./*(更改当前目录下所有文件的属主为root,属主为mysql,-R递归更改)
[root@Smoke mysql]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data/(初始化mysql,--user指定运行服务用户,--datadir指定数据目录)
WARNING: The host 'Smoke.com' could not be looked up with ./bin/resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...2016-06-30 04:10:23 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit
_defaults_for_timestamp server option (see documentation for more details).
2016-06-30 04:10:23 24146 [Note] InnoDB: The InnoDB memory heap is disabled
2016-06-30 04:10:23 24146 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation
2016-06-30 04:10:23 24146 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-06-30 04:10:23 24146 [Note] InnoDB: CPU does not support crc32 instructions
2016-06-30 04:10:23 24146 [Note] InnoDB: Using Linux native AIO
2016-06-30 04:10:23 24146 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-06-30 04:10:23 24146 [Note] InnoDB: Completed initialization of buffer pool
2016-06-30 04:10:23 24146 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2016-06-30 04:10:23 24146 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2016-06-30 04:10:23 24146 [Note] InnoDB: Database physically writes the file full: wait...
2016-06-30 04:10:23 24146 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2016-06-30 04:10:25 24146 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2016-06-30 04:10:26 24146 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2016-06-30 04:10:26 24146 [Warning] InnoDB: New log files created, LSN=45781
2016-06-30 04:10:26 24146 [Note] InnoDB: Doublewrite buffer not found: creating new
2016-06-30 04:10:26 24146 [Note] InnoDB: Doublewrite buffer created
2016-06-30 04:10:26 24146 [Note] InnoDB: 128 rollback segment(s) are active.
2016-06-30 04:10:26 24146 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-06-30 04:10:26 24146 [Note] InnoDB: Foreign key constraint system tables created
2016-06-30 04:10:26 24146 [Note] InnoDB: Creating tablespace and datafile system tables.
2016-06-30 04:10:26 24146 [Note] InnoDB: Tablespace and datafile system tables created.
2016-06-30 04:10:26 24146 [Note] InnoDB: Waiting for purge to start
2016-06-30 04:10:26 24146 [Note] InnoDB: 1.2.10 started; log sequence number 0
2016-06-30 04:10:27 24146 [Note] Binlog end
2016-06-30 04:10:27 24146 [Note] InnoDB: FTS optimize thread exiting.
2016-06-30 04:10:27 24146 [Note] InnoDB: Starting shutdown...
2016-06-30 04:10:28 24146 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK
Filling help tables...2016-06-30 04:10:28 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults
_for_timestamp server option (see documentation for more details).
2016-06-30 04:10:28 24169 [Note] InnoDB: The InnoDB memory heap is disabled
2016-06-30 04:10:28 24169 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation
2016-06-30 04:10:28 24169 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-06-30 04:10:28 24169 [Note] InnoDB: CPU does not support crc32 instructions
2016-06-30 04:10:28 24169 [Note] InnoDB: Using Linux native AIO
2016-06-30 04:10:28 24169 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-06-30 04:10:28 24169 [Note] InnoDB: Completed initialization of buffer pool
2016-06-30 04:10:28 24169 [Note] InnoDB: Highest supported file format is Barracuda.
2016-06-30 04:10:28 24169 [Note] InnoDB: 128 rollback segment(s) are active.
2016-06-30 04:10:28 24169 [Note] InnoDB: Waiting for purge to start
2016-06-30 04:10:28 24169 [Note] InnoDB: 1.2.10 started; log sequence number 1625977
2016-06-30 04:10:28 24169 [Note] Binlog end
2016-06-30 04:10:28 24169 [Note] InnoDB: FTS optimize thread exiting.
2016-06-30 04:10:28 24169 [Note] InnoDB: Starting shutdown...
2016-06-30 04:10:30 24169 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h Smoke.com password 'new-password'
Alternatively you can run:
./bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems with the ./bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
WARNING: Found existing config file ./my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as ./my-new.cnf,
please compare it with your file and take the changes you need.
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
[root@Smoke mysql]# vim my.cnf(编辑my.cnf配置文件)
datadir=/mydata/data(指定数据目录)
innodb_file_per_table=ON(指定innndb存储引擎每表一个表结构)
log-bin=master-bin(启用二进制日志)
[root@Smoke mysql]# cp support-files/mysql.server /etc/init.d/mysqld(复制mysql服务器启动脚本)
[root@Smoke mysql]# chkconfig --add mysqld(将mysqld添加到服务列表)
[root@Smoke mysql]# service mysqld start(启动mysql服务)
Starting MySQL. SUCCESS!
[root@Smoke mysql]# /usr/local/mysql/bin/mysql(连接mysql)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
提示:不能连接本地mysql的套接字文件;
[root@Smoke mysql]# ls /tmp/(查看/tmp目录文件及子目录)
yum.log
[root@Smoke mysql]# vim my.cnf(编辑my.cnf配置文件)
[root@Smoke mysql]# netstat -tnlp(查看系统服务,-t代表tcp,-n以数字显示,-l监听端口,-p显示服务名称)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 9451/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1059/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1137/master
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 9628/sshd
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 9451/nginx
tcp 0 0 :::3306 :::* LISTEN 24432/mysqld
tcp 0 0 :::22 :::* LISTEN 1059/sshd
tcp 0 0 ::1:25 :::* LISTEN 1137/master
tcp 0 0 ::1:6010 :::* LISTEN 9628/sshd
[root@Smoke mysql]# vim my.cnf(编辑my.cnf配置文件)
datadir=/mydata/data
innodb_file_per_table=ON
log-bin=master-bin
socket=/tmp/mysql.sock(定义套接字文件目录)
[root@Smoke mysql]# service mysqld restart(重启mysqld服务)
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
[root@Smoke mysql]# ls /tmp/(查看/tmp目录文件及子目录)
mysql.sock yum.log
[root@Smoke mysql]# /usr/local/mysql/bin/mysql(连接mysql数据库)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.10-log MySQL Community Server (GPL)
Copyright (c) 2000, 2013, 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> \q(退出)
Bye
[root@Smoke mysql]# vim /etc/ld.so.conf.d/mysql.conf(编辑mysql.cnf文件输出库文件)
/usr/local/mysql/lib
[root@Smoke mysql]# ldconfig -v(加载系统动态库连接,-v显示过程)
[root@Smoke mysql]# ln -sv /usr/local/mysql/include /usr/include/mysql(给/usr/local/mysql/include创建软连接叫/usr/include/mysql,输出头文件,
-s软连接,-v显示创建过程)
"/usr/include/mysql" -> "/usr/local/mysql/include"
[root@Smoke mysql]# cd(切换到用户家目录)
[root@Smoke ~]# lftp 172.16.0.1(连接ftp服务器)
cd ok, cwd=/pub/Sources
lftp 172.16.0.1:/pub/Sources> cd new_lamp(切换到new_lamp目录)
lftp 172.16.0.1:/pub/Sources/new_lamp> get php-5.4.13.tar.bz2(下载php-5.4.13)
11545777 bytes transferred
lftp 172.16.0.1:/pub/Sources/new_lamp> bye(退出)
[root@Smoke ~]# ls(查看当前目录文件及子目录)
anaconda-ks.cfg install.log.syslog nginx-1.4.1 php-5.4.13.tar.bz2
install.log mysql-5.6.10-linux-glibc2.5-i686.tar.gz nginx-1.4.1.tar.gz
[root@Smoke ~]# tar xf php-5.4.13.tar.bz2(解压php-5.4.13)
[root@Smoke ~]# cd php-5.4.13(切换到php-5.4.13)
[root@Smoke php-5.4.13]# cd(切换到用户家目录)
[root@Smoke ~]# rpm -q mcrypt(查看是否安装mcrypt软件)
package mcrypt is not installed
[root@Smoke ~]# yum -y install mcrypt(通过yum源安装mcrypt,-y所有询问回答yes)
Loaded plugins: product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Packages | 3.9 kB 00:00 ...
Setting up Install Process
No package mcrypt available.
Error: Nothing to do
提示:没有软件包;
[root@Smoke ~]# cd php-5.4.13(切换到php-5.4.13)
[root@Smoke php-5.4.13]# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --enable-fpm --enable-sockets
--enable-sysvshm --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir
--with-zlib-dir --with-libxml-dir=/usr --enable-xml --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --w
ith-curl(配置php)
checking libxml2 install dir... /usr
checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 installation.
提示:xml2-cnfig没有找到;
[root@Smoke php-5.4.13]# yum list all | grep libxml2(显示yum源列表,只显示libxml2相关)
libxml2.i686 2.7.6-8.el6_3.4 @anaconda-RedHatEnterpriseLinux-201301301449.i386/6.4
libxml2-python.i686 2.7.6-8.el6_3.4 @anaconda-RedHatEnterpriseLinux-201301301449.i386/6.4
libxml2-devel.i686 2.7.6-8.el6_3.4 Packages
[root@Smoke php-5.4.13]# yum -y install libxml2-devel(通过yum源安装libxml2-devel)
[root@Smoke php-5.4.13]# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --enable-fpm --enable-sockets
--enable-sysvshm --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir
--with-zlib-dir --with-libxml-dir=/usr --enable-xml --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --w
ith-curl(配置php)
checking for BZip2 support... yes
checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution
提示:BZip2没有找到;
[root@Smoke php-5.4.13]# yum list all | grep bzip2(显示yum源列表,只显示bzip2相关)
bzip2.i686 1.0.5-7.el6_0 @anaconda-RedHatEnterpriseLinux-201301301449.i386/6.4
bzip2-libs.i686 1.0.5-7.el6_0 @anaconda-RedHatEnterpriseLinux-201301301449.i386/6.4
bzip2-devel.i686 1.0.5-7.el6_0 Packages
[root@Smoke php-5.4.13]# yum -y install bzip2-devel(通过yum源安装bzip2-devel包)
[root@Smoke php-5.4.13]# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --enable-fpm --enable-sockets
--enable-sysvshm --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir
--with-zlib-dir --with-libxml-dir=/usr --enable-xml --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --w
ith-curl(配置php)
checking if we should use cURL for url streams... no
checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/
提示:libcurl没有找到;
[root@Smoke php-5.4.13]# yum list all | grep libcurl(显示yum源列表,只显示libcurl相关)
libcurl.i686 7.19.7-35.el6 @anaconda-RedHatEnterpriseLinux-201301301449.i386/6.4
libcurl-devel.i686 7.19.7-35.el6 Packages
[root@Smoke php-5.4.13]# yum -y install libcurl-devel(通过yum源安装libcurl-devel包)
[root@Smoke php-5.4.13]# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --enable-fpm --enable-sockets
--enable-sysvshm --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir
--with-zlib-dir --with-libxml-dir=/usr --enable-xml --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --w
ith-curl(配置php)
[root@Smoke php-5.4.13]# make && make install(编译并安装)
[root@Smoke php-5.4.13]# ls(查看当前目录文件及子目录)
acinclude.m4 configure.in libtool missing README.EXT_SKEL README.SUBMITTING_PATCH
stub.c aclocal.m4 CREDITS LICENSE mkinstalldirs README.GIT-RULES
README.TESTING svnclean.bat build ext ltmain.sh modules
README.input_filter README.TESTING2 tests buildconf EXTENSIONS
main netware README.MAILINGLIST_RULES README.UNIX-BUILD-SYSTEM TSRM
buildconf.bat footer makedist NEWS README.namespaces README.WIN32-BUILD-SYSTEM
UPGRADING CODING_STANDARDS generated_lists Makefile pear README.NEW-OUTPUT-API
run-tests.php UPGRADING.INTERNALS config.guess genfiles Makefile.frag
php5.spec README.PARAMETER_PARSING_API sapi vcsclean config.log
header Makefile.fragments php5.spec.in README.PHP4-TO-PHP5-THIN-CHANGES scripts
win32 config.nice include Makefile.gcov php.gif README.REDIST.BINS
server-tests-config.php Zend config.status INSTALL Makefile.global
php.ini-development README.RELEASE_PROCESS server-tests.php config.sub
install-sh Makefile.objects php.ini-production README.SELF-CONTAINED-EXTENSIONS snapshot
configure libs makerpm README.EXTENSIONS README.STREAMS stamp-h.in
[root@Smoke php-5.4.13]# cp php.ini-production /etc/php.ini(复制php的配置文件到/etc/目录叫php.ini)
[root@Smoke php-5.4.13]# cd /usr/local/php/etc/(切换到/usr/local/php/etc目录)
[root@Smoke etc]# ls(查看当前目录文件及子目录)
pear.conf php-fpm.conf.default
[root@Smoke etc]# cp php-fpm.conf.default php-fpm.conf(复制php-fpm.confi.default为php-fpm.conf)
[root@Smoke etc]# vim php-fpm.conf(复制php-fpm.conf配置文件)
pm = dynamic(动态设定最多启动多少个子进错)
pm.max_children = 150
pm.start_servers = 8(启动时候启动个数)
pm.min_spare_servers = 5(最少空闲)
pm.max_spare_servers = 10(最大空闲)
;pm.process_idle_timeout = 10s;(超时时间)
;pm.max_requests = 500(最大请求个数)
/pm
/max
[root@Smoke etc]# cd -(切换到上级目录)
/root/php-5.4.13
[root@Smoke php-5.4.13]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm(复制init.d.php-fpm到/etc/init.d/php-fpm,服务脚本)
[root@Smoke php-5.4.13]# vim /etc/init.d/php-fpm(编辑php-fpm文件)
[root@Smoke php-5.4.13]# chmod +x /etc/init.d/php-fpm(给php-fpm执行权限)
[root@Smoke php-5.4.13]# chkconfig --add php-fpm(添加php-fpm到服务列表)
[root@Smoke php-5.4.13]# service php-fpm start(启动php-fpm服务)
Starting php-fpm done
[root@Smoke php-5.4.13]# netstat -tnlp(查看系统服务,-t代表tcp,-n以数字显示,-l监听端口,-p显示服务名称)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 22844/php-fpm
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 9451/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1059/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1137/master
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 22783/sshd
tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN 22803/sshd
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 9451/nginx
tcp 0 0 :::3306 :::* LISTEN 26567/mysqld
tcp 0 0 :::22 :::* LISTEN 1059/sshd
tcp 0 0 ::1:25 :::* LISTEN 1137/master
tcp 0 0 ::1:6010 :::* LISTEN 22783/sshd
tcp 0 0 ::1:6011 :::* LISTEN 22803/sshd
提示:127.0.0.1:9000端口启动了;
[root@Smoke php-5.4.13]# cd /etc/nginx/(切换到/etc/nginx目录)
[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
[root@Smoke nginx]# ps auxf(查看所有终端进错包括子进错)
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 2 0.0 0.0 0 0 ? S Jun29 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S Jun29 0:00 \_ [migration/0]
root 4 0.0 0.0 0 0 ? S Jun29 0:00 \_ [ksoftirqd/0]
root 5 0.0 0.0 0 0 ? S Jun29 0:00 \_ [migration/0]
root 6 0.0 0.0 0 0 ? S Jun29 0:13 \_ [watchdog/0]
root 7 0.0 0.0 0 0 ? S Jun29 0:06 \_ [events/0]
root 8 0.0 0.0 0 0 ? S Jun29 0:00 \_ [cgroup]
root 9 0.0 0.0 0 0 ? S Jun29 0:00 \_ [khelper]
root 10 0.0 0.0 0 0 ? S Jun29 0:00 \_ [netns]
root 11 0.0 0.0 0 0 ? S Jun29 0:00 \_ [async/mgr]
root 12 0.0 0.0 0 0 ? S Jun29 0:00 \_ [pm]
root 13 0.0 0.0 0 0 ? S Jun29 0:01 \_ [sync_supers]
root 14 0.0 0.0 0 0 ? S Jun29 0:00 \_ [bdi-default]
root 15 0.0 0.0 0 0 ? S Jun29 0:00 \_ [kintegrityd/0]
root 16 0.0 0.0 0 0 ? S Jun29 0:09 \_ [kblockd/0]
root 17 0.0 0.0 0 0 ? S Jun29 0:00 \_ [kacpid]
root 18 0.0 0.0 0 0 ? S Jun29 0:00 \_ [kacpi_notify]
root 19 0.0 0.0 0 0 ? S Jun29 0:00 \_ [kacpi_hotplug]
root 20 0.0 0.0 0 0 ? S Jun29 0:00 \_ [ata/0]
root 21 0.0 0.0 0 0 ? S Jun29 0:00 \_ [ata_aux]
root 22 0.0 0.0 0 0 ? S Jun29 0:00 \_ [ksuspend_usbd]
root 23 0.0 0.0 0 0 ? S Jun29 0:00 \_ [khubd]
root 24 0.0 0.0 0 0 ? S Jun29 0:00 \_ [kseriod]
root 25 0.0 0.0 0 0 ? S Jun29 0:00 \_ [md/0]
root 26 0.0 0.0 0 0 ? S Jun29 0:00 \_ [md_misc/0]
root 27 0.0 0.0 0 0 ? S Jun29 0:00 \_ [khungtaskd]
root 28 0.0 0.0 0 0 ? S Jun29 0:00 \_ [kswapd0]
root 29 0.0 0.0 0 0 ? SN Jun29 0:00 \_ [ksmd]
root 30 0.0 0.0 0 0 ? S Jun29 0:00 \_ [aio/0]
root 31 0.0 0.0 0 0 ? S Jun29 0:00 \_ [crypto/0]
root 36 0.0 0.0 0 0 ? S Jun29 0:00 \_ [kthrotld/0]
root 37 0.0 0.0 0 0 ? S Jun29 0:00 \_ [pciehpd]
root 39 0.0 0.0 0 0 ? S Jun29 0:00 \_ [kpsmoused]
root 40 0.0 0.0 0 0 ? S Jun29 0:00 \_ [usbhid_resumer]
root 208 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_0]
root 211 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_1]
root 218 0.0 0.0 0 0 ? S Jun29 0:02 \_ [mpt_poll_0]
root 219 0.0 0.0 0 0 ? S Jun29 0:00 \_ [mpt/0]
root 220 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_2]
root 238 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_3]
root 239 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_4]
root 240 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_5]
root 241 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_6]
root 242 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_7]
root 243 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_8]
root 244 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_9]
root 245 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_10]
root 246 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_11]
root 247 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_12]
root 248 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_13]
root 249 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_14]
root 250 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_15]
root 251 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_16]
root 252 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_17]
root 253 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_18]
root 254 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_19]
root 255 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_20]
root 256 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_21]
root 257 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_22]
root 258 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_23]
root 259 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_24]
root 260 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_25]
root 261 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_26]
root 262 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_27]
root 263 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_28]
root 264 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_29]
root 265 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_30]
root 266 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_31]
root 267 0.0 0.0 0 0 ? S Jun29 0:00 \_ [scsi_eh_32]
root 369 0.1 0.0 0 0 ? S Jun29 0:35 \_ [kjournald]
root 644 0.0 0.0 0 0 ? S Jun29 0:00 \_ [vmmemctl]
root 695 0.0 0.0 0 0 ? S Jun29 0:11 \_ [flush-8:0]
root 708 0.0 0.0 0 0 ? S Jun29 0:00 \_ [bluetooth]
root 776 0.0 0.0 0 0 ? S Jun29 0:00 \_ [kstriped]
root 805 0.0 0.0 0 0 ? S Jun29 0:00 \_ [kjournald]
root 837 0.0 0.0 0 0 ? S Jun29 0:00 \_ [kauditd]
root 1 0.0 0.0 2900 1420 ? Ss Jun29 0:01 /sbin/init
root 448 0.0 0.0 2692 1124 ? S<s Jun29 0:00 /sbin/udevd -d
root 1184 0.0 0.0 3348 1872 ? S< Jun29 0:00 \_ /sbin/udevd -d
root 1187 0.0 0.0 3348 1788 ? S< Jun29 0:00 \_ /sbin/udevd -d
root 980 0.0 0.0 12932 828 ? S<sl Jun29 0:00 auditd
root 996 0.0 0.0 35976 1524 ? Sl Jun29 0:00 /sbin/rsyslogd -i /var/run/syslogd.pid -c 5
dbus 1008 0.0 0.0 13244 1100 ? Ssl Jun29 0:00 dbus-daemon --system
root 1059 0.0 0.0 8576 1024 ? Ss Jun29 0:00 /usr/sbin/sshd
root 22783 0.0 0.1 11652 3332 ? Ss 05:23 0:00 \_ sshd: root@pts/0
root 22787 0.0 0.0 6852 1764 pts/0 Ss 05:23 0:00 | \_ -bash
root 22855 0.0 0.0 6520 1032 pts/0 R+ 05:48 0:00 | \_ ps auxf
root 22803 0.0 0.1 11652 3340 ? Ss 05:24 0:00 \_ sshd: root@pts/1
root 22807 0.0 0.0 6740 1680 pts/1 Ss+ 05:24 0:00 \_ -bash
root 1137 0.0 0.1 12524 2520 ? Ss Jun29 0:00 /usr/libexec/postfix/master
postfix 1146 0.0 0.1 12668 2516 ? S Jun29 0:00 \_ qmgr -l -t fifo -u
postfix 26624 0.0 0.1 12600 2472 ? S 04:47 0:00 \_ pickup -l -t fifo -u
root 1147 0.0 0.0 7084 1268 ? Ss Jun29 0:01 crond
root 1160 0.0 0.0 6156 672 ? Ss Jun29 0:00 /usr/bin/rhsmcertd
root 1174 0.0 0.0 3900 1872 ? Ss Jun29 0:00 login -- root
root 1263 0.0 0.0 7984 1760 tty1 Ss+ Jun29 0:00 \_ -bash
root 1176 0.0 0.0 2008 512 tty2 Ss+ Jun29 0:00 /sbin/mingetty /dev/tty2
root 1178 0.0 0.0 2008 508 tty3 Ss+ Jun29 0:00 /sbin/mingetty /dev/tty3
root 1183 0.0 0.0 2008 512 tty4 Ss+ Jun29 0:00 /sbin/mingetty /dev/tty4
root 1186 0.0 0.0 2008 508 tty5 Ss+ Jun29 0:00 /sbin/mingetty /dev/tty5
root 1189 0.0 0.0 2008 512 tty6 Ss+ Jun29 0:00 /sbin/mingetty /dev/tty6
root 1196 0.0 0.1 21964 2928 ? Sl Jun29 0:00 /usr/sbin/console-kit-daemon --no-daemon
root 9451 0.0 0.1 7368 2224 ? Ss 00:51 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 9848 0.0 0.0 7536 1680 ? S 03:33 0:00 \_ nginx: worker process
nginx 9849 0.0 0.0 7536 1460 ? S 03:33 0:03 \_ nginx: worker process
root 26341 0.0 0.0 3044 1348 ? S 04:28 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/mydata/data --pid-file=
/mydata/data/Smoke.com.pi
mysql 26567 0.1 4.3 428092 83988 ? Sl 04:28 0:04 \_ /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/mydat
a/data --plugin-dir=/usr/
root 22844 0.0 0.1 38536 3432 ? Ss 05:44 0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
nobody 22845 0.0 0.1 38536 2584 ? S 05:44 0:00 \_ php-fpm: pool www
nobody 22846 0.0 0.1 38536 2584 ? S 05:44 0:00 \_ php-fpm: pool www
nobody 22847 0.0 0.1 38536 2584 ? S 05:44 0:00 \_ php-fpm: pool www
nobody 22848 0.0 0.1 38536 2584 ? S 05:44 0:00 \_ php-fpm: pool www
nobody 22849 0.0 0.1 38536 2584 ? S 05:44 0:00 \_ php-fpm: pool www
nobody 22850 0.0 0.1 38536 2584 ? S 05:44 0:00 \_ php-fpm: pool www
nobody 22851 0.0 0.1 38536 2584 ? S 05:44 0:00 \_ php-fpm: pool www
nobody 22852 0.0 0.1 38536 2584 ? S 05:44 0:00 \_ php-fpm: pool www
[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
location ~ \.php$ {
root /web/htdocs;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
[root@Smoke nginx]# vim fastcgi_params(编辑fastcgi_params配置文件)
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
:.,$d(删除当前行到最后一行)
[root@Smoke nginx]# nginx -t(检查nginx配置文件语法)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@Smoke nginx]# service nginx reload(重新加载nginx服务)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新载入 nginx: [确定]
[root@Smoke nginx]# cd /web/htdocs/(切换到/web/htdocs目录)
[root@Smoke htdocs]# ls(查看当前目录文件及子目录)
404.html index.html
[root@Smoke htdocs]# mv index.html index.php(重命名index.html叫index.php)
<h1>Test Page </h1>
<?php
phpinfo();
?>
测试:通过Windows的ie浏览器访问http://172.16.100.106,正常访问;

访问http://172.16.100.106/index.php,正常访问;

[root@Smoke htdocs]# cd -(切换到上级目录)
/etc/nginx
[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
#charset koi8-r;
#access_log logs/host.access.log main;
index index.php index.html;
/index
[root@Smoke nginx]# service nginx reload(重新加载nginx服务)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新载入 nginx: [确定]
测试:通过Windows的ie浏览器访问http://172.16.100.106,正常访问;

[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
location / {
root /web/htdocs;
index home.html;
autoindex off;(关闭自动索引列表,)
}
[root@Smoke nginx]# service nginx reload(重新加载nginx服务)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新载入 nginx: [确定]
测试:通过Windows的ie浏览器访问http://172.16.100.106,无法访问;

[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
location / {
root /web/htdocs;
index index.html;(改为index.html)
autoindex off;
}
[root@Smoke nginx]# service nginx reload(重新加载nginx服务)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新载入 nginx: [确定]
测试:通过Windows的ie浏览器访问http://172.16.100.106,无法访问;

[root@Smoke nginx]# vim nginx.conf(编辑nginx.conf配置文件)
location / {
root /web/htdocs;
index index.php index.html;(更改主页文件)
autoindex off;
}
[root@Smoke nginx]# service nginx reload(重启nginx服务)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新载入 nginx: [确定]
访问http://172.16.100.106,正常访问;

浙公网安备 33010602011771号