Nginx网站服务

相对于Apache体积小,性能高,支持并发30000~50000
编译安装(光盘共享)
yum -y install pcre-devel zlib-devel #前提条件
tar zxvf /abc/nginx-1.12.0.tar.gz -C /usr/src/
cd /usr/src/nginx-1.12.0/
useradd -M -s /sbin/nologin nginx #建立服务用户nginx
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module 统计模块
make && make install
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin
nginx -t #检测服务
nginx #启动服务
netstat -anpt | grep nginx
终端浏览器
yum -y install elinks
elinks http://localhost
主配置文件
vim /usr/local/nginx/conf/nginx.conf
全局配置php

处理进程数html

服务配置
servser {
listen 80; #表明监听的端口号 ip + 端口号
server_name www.baidu.com; #网站的域名
charset utf-8; #支持的字符集
location / { #根目录配置模块
root /var/www/html/; #网站根目录位置
index index.html index.php index.htm; #识别默认页
}
error_page 500 502 503 504 /50x.html; #错误反馈页面
location = /50x.html { #错误页面配置
root /var/www/html;
}
location /status { #配置统计模块
stub_status on; #开启统计功能
access_log off; #关闭日志功能
}nginx

}
关闭nginx
killall -3 nginx 或 killall -QUIT nginx
访问统计页面
http://127.0.0.1/status
Active connections: 2 #活跃链接数
server accepts handled requests
2 2 5 #TCP链接数 #成功握手数 #总处理数
Reading: 0 Writing: 1 Waiting: 1
虚拟主机
主配置文件添加server{}
建立每一个网站所对应的网页
修改vim /etc/hosts文件
127.0.0.1 www.benet.com
127.0.0.1 www.accp.com
重启nginx服务vim

相关文章
相关标签/搜索