ubuntu14.04 LNMP环境,安装成功后,注册时404,项目目录权限777,求助,怎么配置nginx,才能启动rewrite,现在nginx配置贴在下边了

By abnerxin at 2016-09-11 • 0人收藏 • 292人看过

server {

listen 80 default_server;

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


root /home/misaeng/Documents/;

index index.html index.htm index.php;


# Make site accessible from http://localhost/

server_name localhost;

error_page 404 /404.php;

#carbon forum 5.6.1 nginx configuration rewrite 重定向配置

if (!-e $request_filename){

                rewrite ^/(.*)/dashboard /$1/dashboard.php last;

                rewrite ^/(.*)/forgot /$1/forgot.php last;

                rewrite ^/(.*)/favorites(/page/([0-9]*))? /$1/favorites.php\?page=$3 last;

                rewrite ^/(.*)/goto/([0-9]+)-([0-9]+) /$1/goto.php\?topic_id=$2&post_id=$3 last;

                rewrite ^/(.*)/json/([0-9a-z_\-]+) /$1/json.php\?action=$2 last;

                rewrite ^/(.*)/login(.*) /$1/login.php$2 last;

                rewrite ^/(.*)/manage /$1/manage.php last;

                rewrite ^/(.*)/new /$1/new.php last;

                rewrite ^/(.*)/notifications /$1/notifications.php last;

                rewrite ^/(.*)/oauth-([0-9]+) /$1/oauth.php\?app_id=$2 last;

                rewrite ^/(.*)/page/([0-9]+) /$1/index.php\?page=$2 last;

                rewrite ^/(.*)/register(.*) /$1/register.php$2 last;

                rewrite ^/(.*)/reply /$1/reply.php last;

                rewrite ^/(.*)/reset_password/(.*) /$1/reset_password.php\?access_token=$2 last;

                rewrite ^/(.*)/robots.txt /$1/robots.php last;

                rewrite ^/(.*)/search.xml /$1/open_search.php last;

                rewrite ^/(.*)/search/([^/]*)(/page/([0-9]*))? /$1/search.php\?keyword=$2&page=$4 last;

                rewrite ^/(.*)/settings /$1/settings.php last;

                rewrite ^/(.*)/sitemap-(topics|pages|tags|users|index)(-([0-9]+))?.xml /$1/sitemap.php\?action=$2&page=$4 last;

                rewrite ^/(.*)/statistics /$1/statistics.php last;

                rewrite ^/(.*)/t/([0-9]+)(-([0-9]*))?(.*) /$1/topic.php\?id=$2&page=$4 last;

                rewrite ^/(.*)/tag/([^/]*)(/page/([0-9]*))? /$1/tag.php\?name=$2&page=$4 last;

                rewrite ^/(.*)/tags/following(/page/([0-9]*))? /$1/favorite_tags.php\?page=$3 last;

                rewrite ^/(.*)/tags(/page/([0-9]*))? /$1/tags.php\?page=$3 last;

                rewrite ^/(.*)/u/(.*) /$1/user.php\?username=$2 last;

                rewrite ^/(.*)/users/following(/page/([0-9]*))? /$1/favorite_users.php\?page=$3 last;

                rewrite ^/(.*)/upload_controller(.*) /$1/upload_controller.php$2 last;

                rewrite ^/(.*)/view-(desktop|mobile)\?(.*) /$1/view.php\?view=$2&$3 last;

}

location / {


# First attempt to serve request as file, then

# as directory, then fall back to displaying a 404.

#try_files $uri $uri/ =404;

try_files $uri $uri/ /index.php?$query_string;

# Uncomment to enable naxsi on this location

# include /etc/nginx/naxsi.rules

}


#try_files $uri $uri/ /index.php?$query_string;

# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests

#location /RequestDenied {

# proxy_pass http://127.0.0.1:8080;    

#}


#error_page 404 /404.php;

#/404.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;

#}


# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

location ~ \.php$ {

# fastcgi_split_path_info ^(.+\.php)(/.+)$;

# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

#

# # With php5-cgi alone:

# fastcgi_pass 127.0.0.1:9000;

# # With php5-fpm:

        try_files $uri =404;

        fastcgi_split_path_info ^(.+\.php)(/.+)$;

fastcgi_pass unix:/var/run/php5-fpm.sock;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$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;

#}


# Git folder vulnerability

location /.git {

        deny all;

}

}



2 个回复 | 最后更新于 2016-09-12
2016-09-11   #1

配置好了

2016-09-12   #2

回复#1 @abnerxin :

恭喜

登录后方可回帖

登 录
信息栏
购买PHP虚拟主机 / VPS

Carbon Forum是一个基于话题的高性能轻型PHP论坛

下载地址:Carbon Forum v5.0.1
QQ群:12607708(QQ我不常上)

donate

手机支付宝扫描上方二维码可向本项目捐款

Loading...