Ubuntu 安装 StartBBS 出错和解决办法

1.系统说明

ubuntu 12.04
php-5.3.27
mysql-5.1.68
nginx-1.4.2

2.问题及其解决方案

安装之前需要做以下配置(app/config/config.php):

$config['base_url']	= 'http://www.startbbstest.com/';
$config['index_page'] = 'index.php';

2.1 安装出现 404 错误

在 nginx 的 nginx.conf 文件中添加
if (!-e $request_filename) {
    rewrite ^(.*)$ /index.php?$1 last;
    # rewrite "^/(.*)$" /index.php last;
    # break;
}
如下:
# www.startbbstest.com
server {
    listen	80;
    server_name	www.startbbstest.com;

    location / {
        root	/home/wzw/workstation/www/startbbstest.com;
        index	index.php index.htm index.html;
        autoindex	on;		    
    }

    #location = /50x.html {
    #	root	/home/wzw/workstation/www/startbbstest.com;
    #}
	
    location ~ \.php.*$ {
        root	/home/wzw/workstation/www/startbbstest.com;
        fastcgi_pass	127.0.0.1:9000;
        fastcgi_index	index.php;
        fastcgi_param	SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include	fastcgi_params;
			
        if (!-e $request_filename) {
            rewrite ^(.*)$ /index.php?$1 last;
            # rewrite "^/(.*)$" /index.php last;
            # break;
        }
    }
}

2.2 js 和 css 文件不能加载,报404 错误,页面的数据是正常的,即php部分是正常的

这个问题让我抓狂了差不多一天,主要也是我自己对nginx还不熟吧。
之所以出现这个问题,是因为2.1中添加的那段配置的位置很关键,我之前将其放在 location / {...} 中,后来也尝试了放在  location / {...} 外,都导致同样问题的发生。最后我移到 location ~ \.php.*$ {...} 就好了。


转载于:https://my.oschina.net/wzwitblog/blog/167040

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值