#安裝nginxhtml
yum -y install nginx
#啓動nginx服務node
systemctl start nginx
#查看nginx服務進程nginx
ps -ef|grep nginx
#yum安裝nginx的默認站點目錄瀏覽器
/usr/share/nginx/htmlbash
#全磁盤查找nginx配置文件服務器
find / -name nginx.conf
#備份配置文件併發
cp nginx.conf nginx.conf.ori.20171019
#修改nginx配置文件(/etc/nginx/nginx.conf,這是yum安裝nginx的默認配置文件所在的路徑)app
[root@iZ2ze4260oe720hZnginx]# cat nginx.conf # For moreinformation on configuration, see: # * Official English Documentation:http://nginx.org/en/docs/ # * Official Russian Documentation:http://nginx.org/ru/docs/ user nginx; worker_processesauto; error_log/var/log/nginx/error.log; pid/run/nginx.pid; # Load dynamicmodules. See /usr/share/nginx/README.dynamic. include/usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { 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 /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the/etc/nginx/conf.d directory. # Seehttp://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; server { listen 80 default_server; root /usr/share/nginx/html; # Loadconfiguration files for the default server block. include/etc/nginx/default.d/*.conf; location /{ index index.html index.htm; autoindexon; #開啓nginx目錄瀏覽功能 autoindex_exact_size off; #文件大小從KB開始顯示 #默認爲on,顯示出文件的確切大小,單位是bytes。 #改成off後,顯示出文件的大概大小,單位是kB或者MB或者GB autoindex_localtime on; #顯示文件修改時間爲服務器本地時間 charsetutf-8,gbk; #顯示中文 # limit_conn one 8; #併發數 limit_rate100k; #單個線程最大下載速度,單位KB/s } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } } }
#重啓nginx服務tcp
systemctl restart nginx
#在瀏覽器查看下載界面ide
參考文檔:
https://my.oschina.net/Jacedy/blog/618131——利用Nginx訪問、下載本機目錄文件
http://2853725.blog.51cto.com/2843725/1381509——nginx報錯zero sizeshared memory zone "one"