nginx 网站搭建

时间:2022-12-15 07:14:33

nginx目录详解

默认nginx做了nginx配置文件的备份

#查看nginx配置文件去掉#号的内容,并且追加到nginx.conf.tmp

egrep -v "#|^$" nginx.conf > nginx.conf.tmp

mv nginx.conf.tmp nginx.conf #简化的配置文件

nginx虚拟主机配置-->基于域名

user nginx nginx; #nginx访问用户

worker_processes 8;#cpu 数量

events {

use epoll;

worker_connections 1024;

}

http {

include mime.types;

default_type application/octet-stream;

sendfile on;

keepalive_tiomeout 65;

server {

listen 80;

server_name www.baidu.com baidu.com;

location / {

root /data0/www/www;

index.html;

}

}

}

创建目录

mkdir /data0/www/{www,bbs,blog} -p

授权-->nginx 有权管理站点目录

chown -R nginx:nginx /data0/www

创建日志目录

mkdir /app/log -p

echo www>/data0/www/www/index.html

/workspace/nginx/sbin/nginx -t #检查语法错误

/workspace/nginx/sbin/nginx -s reload #平滑重启

ps aux |grep nginx

进程多了  原因:进程=cpu数X2