簡體   English   中英

在Nginx的子目錄中安裝wordpress

[英]Installing wordpress in a subdirectory in Nginx

我有一個在tomcat上運行的網站,我想將我的博客設置在與example.com/blog相同的網站的子目錄下

我嘗試使用多個設置,但沒有一個工作。 一些給出了502錯誤,一些404和以下配置給出了沒有輸入文件指定的錯誤。

server {
    listen 80;
    server_name www.example.com;
    gzip on;

    location / {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-Ip $remote_addr;
        proxy_pass http://localhost:8080;
    }

    location ^~ /blog{
        root /home/myubuntu/www/blog;
        index index.php index.html index.htm;
        try_files $uri $uri/ /blog/index.php?q=$uri&$args;

        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

我在子域上運行同一個博客,並成功完成以下配置:

server {
    listen 80;
    root /home/myubuntu/www/blog;
    index index.php index.html index.htm;

    server_name blog.example.com;
    gzip on;

    location / {
        try_files $uri $uri/ /index.php?q=$uri&$args;
    }

    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx.html;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

}

有人可以告訴我,我做錯了什么

我有同樣的問題,經過2天的搜索,結合設置和搜索...我做了一些對我有用的東西。 我正在運行nginx 1.8 Wordpress ......老實說不知道......

這是我的配置

server {
    listen 80;
    server_name www.example.com example.com;

    gzip on;
    gzip_disable "msie6";
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    location / {
            root       /http;
            index      index.php index.html index.htm;
            try_files  $uri $uri/ @wordpress;
    }

    location ~ \.php$ {
            root           /http/wordpress;
            fastcgi_pass   unix:/var/run/php5-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;
    }

    location @wordpress {
            try_files $uri /index.php;
            fastcgi_intercept_errors on;
    }

    location /wordpress {
            try_files $uri $uri/ @wordpress;
    }

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
            root /usr/share/nginx/www;
    }
}

我希望這可以幫助你...


這是設置路徑:

etc/nginx/sites-availability/default
您需要使用wordpress遵循nginx中的最小設置。
  server { listen 80; 

\n\n root / var / www / html;\n index index.php;\n\n server_name 182.71.214.253;\n\n 位置/博客{\n\n try_files $ uri $ uri / /blogs/index.php?$args;\n }\n\n\n\n error_page 500 502 503 504 /50x.html;\n location = /50x.html {\n root / var / www / html;\n #root / usr / share / nginx / html;\n }\n\n #將PHP腳本傳遞給在php-fpm套接字上偵聽的FastCGI服務器\n location~ \\ .php $ {\n fastcgi_split_path_info ^(。+ \\。php)(/。+)$;\n fastcgi_pass unix:/var/run/php5-fpm.sock;\n fastcgi_index index.php;\n fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;\n 包括fastcgi_params;\n\n } </ code> </ pre>完成此設置后,您需要重新啟動兩個服務。<pre> <code> 1:NGINX:sudo service nginx restart <br/> 2:php5-fpm:sudo service php5- fpm restart </ code> </ pre> <br/>之后你的網站工作正常。<br/>如果仍然需要問題,請與我們分享。\n

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM