导图社区 Nginx
这是一篇关于Nginx的思维导图,主要内容包括:Linux常用命令,Linux安装,介绍,nginx配制文件,Nginx常用命令。
编辑于2024-03-28 15:30:38Nginx
Linux常用命令
显示系统相关信息
uname -a
查看端口占用情况
查看全部
netstat -tanlp
筛 选
netstat -tanlp | grep 8080
杀掉进程
kill -9 PID
防火墙
查看firewall服务状态
systemctl status firewalld
开启、重启、关闭、firewalld.service服务
开启
service firewalld start
关闭
service firewalld stop
重启
service firewalld restart
查看防火墙规则
查看全部信息
firewall-cmd --list-all
只看端口信息
firewall-cmd --list-ports
开端口命令
firewall-cmd --zone=public --add-port=80/tcp --permanent
含义:--zone #作用域 --add-port=80/tcp #添加端口,格式为:端口/通讯协议 --permanent #永久生效,没有此参数重启后失效
重启防火墙
systemctl restart firewalld.service
查找
find / -name mysql # 查找名字为mysql的相关文件
介绍
Nginx (engine x) 是一个高性能的HTTP和反向代理服务器。
特点:占有内存少,并发能力强。
Linux安装
安装
下载Nginx
https://nginx.org/en/download.html
解压安装包
tar -zxvf nginx-1.20.1.tar.gz
安装gcc
yum install gcc-c++
进入nginx目录
执行 ./configure
报错
执行 yum install -y pcre-devel
报错
执行 yum install -y zlib-devel
执行 make
执行 make install
Nginx常用命令
使用nginx操作命令的前提,要进入到nginx的目录中去
/usr/local/nginx/sbin
查看nginx版本号
./nginx -v
关闭nginx
./nginx -s stop
启动nginx
./nginx
重新加载nginx
./nginx -s reload
nginx配制文件
位置
/usr/local/nginx/conf
全局快
从配置文件开始到events块之间的内容,主要会设置一些影响nginx服务器整体运行的配置指令。
events块
events主要影响nginx服务器与用户的网络连接。
http块
nginx配置最频繁的部分,http块包含 http全局快、server块。
配制文件
#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 8888; server_name 8.140.157.45; #charset koi8-r; #access_log logs/host.access.log main; #location / { # root html; # index index.html index.htm; #} location ~ /eduservice/ { proxy_pass http://localhost:8001; } location ~ /user/ { proxy_pass http://localhost:8001; } location ~ /eduoss/ { proxy_pass http://localhost:8002; } #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; # } #} }