nginx搭建文件服務(wù)器的詳細(xì)過(guò)程
安裝nginx
yum -y install nginx
搭建文件服務(wù)器
1.改為root用戶
原來(lái)的nginx.conf里,第一行是
user ngix; # 不同版本的不一樣
改為
user root;
2.加一個(gè)server
①配置文件位置
[root@VM_0_9_centos ~]# find / -name nginx.conf /var/opt/gitlab/nginx/conf/nginx.conf /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/unicorn-5.1.0/examples/nginx.conf /opt/gitlab/embedded/conf/nginx.conf /etc/nginx/nginx.conf # 這個(gè)是要找的文件
②html目錄
/usr/share/nginx/html # 默認(rèn)的
③在原來(lái)的nginx.conf里加一個(gè)server配置
配置寫在http { } 里面,與其他server 同級(jí)別。
autoindex on;# 顯示目錄
autoindex_exact_size on;# 顯示文件大小
autoindex_localtime on;# 顯示文件時(shí)間
server {
listen 8080 default_server;
listen [::]:8080 default_server;
server_name _;
#root /usr/share/nginx/html;
root /data/;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}參考:http://m.fzitv.net/article/247578.htm
3.啟動(dòng)
service nginx start service nginx stop service nginx restart # 重啟 nginx -s reload # 修改配置后重啟,或者使用reload重載配置文件
4.訪問(wèn)界面

5.完整的nginx配置參考
user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. 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.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
include /etc/nginx/conf.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
autoindex on;# 顯示目錄
autoindex_exact_size on;# 顯示文件大小
autoindex_localtime on;# 顯示文件時(shí)間
server {
listen 6868 default_server;
listen [::]:6868 default_server;
server_name _;
#root /usr/share/nginx/html;
root /;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}到此這篇關(guān)于nginx搭建文件服務(wù)器的文章就介紹到這了,更多相關(guān)nginx文件服務(wù)器內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
針對(duì)OpenSSL安全漏洞調(diào)整Nginx服務(wù)器的方法
這篇文章主要介紹了針對(duì)OpenSSL漏洞調(diào)整Nginx服務(wù)器的方法,2014年爆出的SSL安全漏洞震驚了全世界,需要的朋友可以參考下2015-06-06
Nginx整合Tomcat實(shí)現(xiàn)跨域功能的完整指南
在現(xiàn)代Web開發(fā)中,前后端分離架構(gòu)越來(lái)越普遍,這種情況下,跨域請(qǐng)求成為了一個(gè)常見的問(wèn)題,本文將介紹如何通過(guò)Nginx和Tomcat的整合來(lái)解決跨域問(wèn)題,并實(shí)現(xiàn)高效的服務(wù)部署2025-09-09
503 service unavailable錯(cuò)誤解決方案講解
這篇文章主要介紹了503 service unavailable錯(cuò)誤解決方案講解,本篇文章通過(guò)簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-08-08
詳解nginx的請(qǐng)求限制(連接限制和請(qǐng)求限制)
這篇文章主要介紹了詳解nginx的請(qǐng)求限制(連接限制和請(qǐng)求限制),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-07-07
WebApi部署多服務(wù)器配置Nginx負(fù)載均衡的教程
這篇文章主要介紹了WebApi部署多服務(wù)器配置Nginx負(fù)載均衡 ,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-03-03
Nginx通過(guò)nginx-rtmp-module模塊搭建流媒體服務(wù)器實(shí)現(xiàn)直播
近日有客戶咨詢想用Nginx搭建流媒體服務(wù)器實(shí)現(xiàn)直播,方便他們打造自己的平臺(tái),經(jīng)過(guò)各種測(cè)試發(fā)現(xiàn)如下文章不錯(cuò),特分享給需要的朋友2023-10-10

