```[root@server nginx]# pwd
/opt/nginx
vim conf/nginx.conf
# 默认 开启工作进程的用户
#user nobody;
#开启的工作进程数量,一般等于cpu减一,或减二
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
# 每个工作进程允许的连接数
worker_connections 1024;
}
http {
# 浏览器和用户交互的数据类型,如 form_data、application/json等
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"';
# '$remote_addr: 访问的ip
# $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;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
# 域名
server_name localhost;
# 多域名
# server_name baidu.com qq.com www.baidu.com;
# 默认主机
server_name localhost default_server;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
# root 等于 cd,先cd到html 文件夹,再去找 后面的页面
root html;
# alias , 就是别名,访问/ 就是访问 html/img
#alias html/img/ ;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}