2013-02-13 63 views
0

我目前正試圖讓我的Nginx + Mysql + WordPress的工作在Fedora 18 x64上。Nginx的WordPress的

做了以下手冊http://www.tecmint.com/install-wordpress-using-lamp-or-lemp-on-rhel-centos-fedora/但似乎沒有任何工作。

默認的Nginx問候語仍顯示在localhost:80。

我應該提供一些配置文件作爲例子嗎?

請幫助我真的迷路了。谷歌的一切,閱讀正式的Nginx手冊atm。

# For more information on configuration, see: 
# * Official English Documentation: http://nginx.org/en/docs/ 
# * Official Russian Documentation: http://nginx.org/ru/docs/ 

user nginx; 
worker_processes 1; 

error_log /var/log/nginx/error.log; 
#error_log /var/log/nginx/error.log notice; 
#error_log /var/log/nginx/error.log info; 

pid  /run/nginx.pid; 


events { 
worker_connections 1024; 
} 


http { 
include  /usr/local/etc/nginx/sites-enabled/*; 
include  mime.types; 

default_type application/octet-stream; 

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; 

#keepalive_timeout 0; 
keepalive_timeout 65; 

#gzip on; 

server { 
    listen  80; 
    server_name localhost; 

    #charset koi8-r; 

    #access_log /var/log/nginx/host.access.log main; 

    location/{ 
     root /srv/www/wordpress/public_html; 
     index index.php index.html; 
    } 

    # redirect server error pages to the static page /40x.html 
    # 
    error_page 404    /404.html; 
    location = /40x.html { 
     root /usr/share/nginx/html; 
    } 

    # redirect server error pages to the static page /50x.html 
    # 
    error_page 500 502 503 504 /50x.html; 
    location = /50x.html { 
     root /usr/share/nginx/html; 
    } 

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80 
    # 
    #location ~ \.php$ { 
    # proxy_pass http://127.0.0.1; 
    #} 

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 
    # 
    #location ~ \.php$ { 
    # root   html; 
    # fastcgi_pass 127.0.0.1:9000; 
    # fastcgi_index index.php; 
    # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 
    # include  fastcgi_params; 
    #} 

    # deny access to .htaccess files, if Apache's document root 
    # concurs with nginx's one 
    # 
    #location ~ /\.ht { 
    # deny all; 
    #} 
} 


# another virtual host using mix of IP-, name-, and port-based configuration 
# 
#server { 
# listen  8000; 
# listen  somename:8080; 
# server_name somename alias another.alias; 

# location/{ 
#  root html; 
#  index index.html index.htm; 
# } 
#} 


# HTTPS server 
# 
#server { 
# listen  443; 
# server_name localhost; 

# ssl     on; 
# ssl_certificate  cert.pem; 
# ssl_certificate_key cert.key; 

# ssl_session_timeout 5m; 

# ssl_protocols SSLv2 SSLv3 TLSv1; 
# ssl_ciphers HIGH:!aNULL:!MD5; 
# ssl_prefer_server_ciphers on; 

# location/{ 
#  root html; 
#  index index.html index.htm; 
# } 
#} 

} 
+0

你可以用你的wordpress網站的nginx配置來編輯你的文章嗎? – CDub 2013-02-13 19:03:49

+0

因爲在手冊中沒有提到nginx.conf文件,所以我沒有真正觸及nginx.conf文件。 – 2013-02-13 19:07:46

+0

我剛剛意識到,我應該先做這個http://www.tecmint.com/install-lemp-linux-nginx-mysql-php-on-rhel-centos-5-6-fedora-12-17/指南和然後跳到我在主帖中鏈接的那個。 – 2013-02-13 19:08:26

回答

4

下面是我爲我的WordPress網站一個nginx的配置,除去域名和IP地址,當然...我建立這個網上使用多次提到,它似乎工作得很好。

server { 
    listen <ip-address>; 
    server_name domain.com; 
    rewrite ^(.*) $scheme://www.domain.com$request_uri? permanent; 
} 

server { 
    listen <ip-address>; 
    server_name www.domain.com; 
    root /www/domain.com/public_html; 

    access_log /www/domain.com/logs/access.log; 
    error_log /www/domain.com/logs/error.log; 

    location = /favicon.ico { 
    log_not_found off; 
    access_log off; 
    } 

    location = /robots.txt { 
    allow all; 
    log_not_found off; 
    access_log off; 
    } 

    location/{ 
    index index.html index.htm index.php; 
    try_files $uri $uri/ /index.php; 
    } 

    location ~ \.php$ { 
    include /etc/nginx/fastcgi_params; 
    if ($uri !~ "^/images/") { 
     fastcgi_pass unix:/var/run/php-fastcgi/php-fastcgi.socket; 
    } 
    fastcgi_index index.php; 
    fastcgi_param SCRIPT_FILENAME /www/domain.com/public_html$fastcgi_script_name; 
    } 

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { 
    expires max; 
    log_not_found off; 
    } 
} 
+0

感謝您的時間明天嘗試。乾杯。 – 2013-02-13 20:31:15

+0

太棒了!如果它不起作用,請隨時給我發消息或發回給我們,我們會繼續努力。 :) – CDub 2013-02-13 21:53:53