Nginx怎么改靜態(tài)文件的訪問路徑?

外網用戶訪問服務器的 Web 服務由 Nginx 提供,Nginx 需要配置靜態(tài)資源的路徑信息才能通過 url 正確訪問到服務器上的靜態(tài)資源。
打開 Nginx 的默認配置文件

創(chuàng)新互聯建站專注為客戶提供全方位的互聯網綜合服務,包含不限于做網站、成都網站制作、上黨網絡推廣、成都微信小程序、上黨網絡營銷、上黨企業(yè)策劃、上黨品牌公關、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務,您的肯定,是我們最大的嘉獎;創(chuàng)新互聯建站為所有大學生創(chuàng)業(yè)者提供上黨建站搭建服務,24小時服務熱線:13518219792,官方網址:muchs.cn

vim /usr/local/nginx/conf/nginx.conf

將service中添加如下配置

root 靜態(tài)文件根路徑

示例代碼:/etc/nginx/nginx.conf

user nobody nobody;
worker_processes 2;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;

events
{   
    use epoll;
    worker_connections 6000;
}

http
{   
    include mime.types;
    default_type application/octet-stream;
    server_names_hash_bucket_size 3526;
    server_names_hash_max_size 4096;
    log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'
    '$host "$request_uri" $status'
    '"$http_referer" "$http_user_agent"';
    sendfile on;
    tcp_nopush on;
    keepalive_timeout 30; 
        client_header_timeout 3m;
    client_body_timeout 3m;
    send_timeout 3m;
    connection_pool_size 256;
    client_header_buffer_size 1k;
    large_client_header_buffers 8 4k;
    request_pool_size 4k;
    output_buffers 4 32k;
    postpone_output 1460;
    client_max_body_size 10m;
    client_body_buffer_size 256k;
    client_body_temp_path /usr/local/nginx/client_body_temp;
    proxy_temp_path /usr/local/nginx/proxy_temp;
    fastcgi_temp_path /usr/local/nginx/fastcgi_temp;
    fastcgi_intercept_errors on;
    tcp_nodelay on;
    gzip on;
    gzip_min_length 1k;
    gzip_buffers 4 8k;
    gzip_comp_level 5;
    gzip_http_version 1.1;
    gzip_types text/plain application/x-javascript text/css text/htm application/xml;
        server
        {
            listen 80 default;
            server_name _;
            root /var/ftp/source;
        }
        include /usr/local/nginx/conf/host/*.conf;
}

使用以下命令,重新加載Nginx

./nginx -s reload

再次通過IP和80端口訪問時是以設置好的路徑為根路徑,可以依舊不同靜態(tài)文件的路徑訪問靜態(tài)文件

本文名稱:Nginx怎么改靜態(tài)文件的訪問路徑?
標題鏈接:http://muchs.cn/article40/jpepeo.html

成都網站建設公司_創(chuàng)新互聯,為您提供微信小程序、外貿網站建設、網站設計、App開發(fā)企業(yè)網站制作、外貿建站

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯

微信小程序開發(fā)