前景提要:
因为跨域问题,前期找服务。
1. 进入linux服务器找到配置nginx安装位置
ps aux|grep nginx
root 19556 0.0 0.0 46920 4012 ? S 16:40 0:00 nginx: worker process
root 21100 0.0 0.0 46920 3032 ? Ss 1月09 0:00 nginx: master process ./nginx -c /usr/local/nginx/conf/nginx.conf
root 25898 0.0 0.0 112728 988 pts/3 S+ 18:16 0:00 grep --color=auto nginx
所以我的nignx的地址是 /usr/local/nginx/conf/nginx.conf
cd /usr/local/nginx/conf
2. 查看内部有什么文件
简单的ls就可以看到其中有各种配置文件,还有一些配置文件
vim nginx.conf
可以看到nginx配置文件的全貌(说起来,我之前搭过nginx服务器,但是现在完全忘记了,nginx服务配置是不是完全修改一个配置文件)
3.大致浏览一下默认的nginx.conf有什么内容
#user nobody;
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 {
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;
#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;
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;
# }
#}
}
来自菜鸟教程(没有广告,只是引用)的文件结构:
... #全局块
events { #events块
...
}
http #http块
{
... #http全局块
server #server块
{
... #server全局块
location [PATTERN] #location块
{
...
}
location [PATTERN]
{
...
}
}
server
{
...
}
... #http全局块
}
小记:暂时这样子吧,稍微能看懂一点,迟点加点注释。初碰就这样子吧;主要是我哥突然跟我说给我介绍对象,我有点接受不了。
引用
Nginx配置详情https://www.runoob.com/w3cnote/nginx-setup-intro.html