2017-05-25 153 views
1

我在配置我的wordpress nginx設置時遇到問題。 這是我nginx的configuraton作爲文件夾的127.0.0.1 wordpress.project什麼是編寫wordpress的nginx配置的正確方法?

權限設置

sudo chmod -R a+rw /var/www/wordpress.project 
sudo chown -R www-data:www-data /var/www/wordpress.project 

和符號鏈接設置

sudo ln -s /etc/nginx/sites-available/wordpess.project /etc/nginx/sites-enabled/wordpess.project 

而且有

server { 
     listen     80; 
     server_name    wordpress.project; 
     access_log    /var/log/nginx/wordpress.project/access.log; 
     error_log    /var/log/nginx/wordpress.project/error.log; 
     root     /var/www/wordpress.project; 

     location/{ 
       index app_dev.php; 
       if (-f $request_filename) { 
       break; 
       } 
       rewrite ^(.*)$ /app_dev.php last; 
     } 

     location ~ \.php$ { 
       fastcgi_split_path_info   ^(.+\.php)(.*)$; 
       fastcgi_pass     unix:/var/run/php5-fpm.sock; 
       #fastcgi_pass     127.0.0.1:9000; 
       fastcgi_index     index.php; 
       fastcgi_param     SCRIPT_FILENAME $request_filename; 
       include       fastcgi_params; 

     } 

} 

Hosts文件設置仍然錯誤,當我嘗試訪問wordpre沒有找到ss.project說

文件

項目有一個文件經典WordPress的結構 enter image description here 是在nginx的WordPress的這個正確的配置,如果它不是什麼是最好的方法是什麼?

回答

1

試試這個

server 
{ 
     listen 80 default_server; 
     listen [::]:80 default_server ipv6only=on; 

     root /var/www/wordpress.project; 
     index index.php index.html index.htm; 

     server_name your_domain.com; 

     location/{ 
       # try_files $uri $uri/ =404; 
       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; 
     } 
} 

請更改配置(須藤服務nginx的重新啓動)

+0

它仍然無法正常工作後重新啓動Nginx的。錯誤是404找不到 – Strahinja90bg

+0

您可以請分享您的項目的目錄和文件結構嗎? –

+0

你現在在描述的問題 – Strahinja90bg

相關問題