nginx 的安裝配置與啟動(dòng)
-
nginx 安裝配置與啟動(dòng)
1.安裝官方倉(cāng)庫(kù)源 [root@web01 ~]# cat /etc/yum.repos.d/nginx.repo [nginx-stable] name=nginx stable repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key 2.使用yum直接安裝 [root@web01 ~]# yum install nginx -y 3.啟動(dòng)nginx [root@web01 ~]# systemctl start nginx nginx安裝成功 [root@web01 ~]# netstat -lntp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 6408/rpcbind tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 7892/nginx: master tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 6703/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 6904/master tcp6 0 0 :::111 :::* LISTEN 6408/rpcbind tcp6 0 0 :::22 :::* LISTEN 6703/sshd tcp6 0 0 ::1:25 :::* LISTEN 6904/master nginx的配置文件 [root@web01 ~]# cat /etc/nginx/nginx.conf user nginx; #nginx進(jìn)程的用戶身份 worker_processes 1; #nginx的工作進(jìn)程數(shù) error_log /var/log/nginx/error.log warn; #錯(cuò)誤日志的路徑 pid /var/run/nginx.pid; #進(jìn)程運(yùn)行后,會(huì)產(chǎn)生一個(gè)pid events { #事件模型 worker_connections 1024; #每個(gè)worker能夠支持的連接數(shù) } http { include /etc/nginx/mime.types; #包含所有靜態(tài)資源的文件 default_type application/octet-stream; #默認(rèn)類型 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' #日志相關(guān)的 '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; #訪問日志的路徑 sendfile on; #tcp_nopush on; keepalive_timeout 65; #長(zhǎng)鏈接超時(shí)時(shí)間 #gzip on; #啟用壓縮功能 server { #使用Server配置網(wǎng)站, 每個(gè)Server{}代表一個(gè)網(wǎng)站 listen 80; server_name test.oldlia.com; location / { #控制網(wǎng)站訪問的路徑 root /***/abc&; } } include /etc/nginx/conf.d/*.conf; }
-
nginx中的http server location 之間的關(guān)系是什么?
http 標(biāo)簽主要用來解決用戶的請(qǐng)求與響應(yīng)长赞。 server 標(biāo)簽主要用來相應(yīng)具體的某一個(gè)網(wǎng)站 location 標(biāo)簽主要用來匹配具體url路徑
-