开发者社区> 问答> 正文

关于nginx前端,apache后端的问题 : 配置报错 

我这几天做了一个前端是nginx,后端是apache,页面是可以访问了,但是没有加载css和图片,页面显示

顺便也把弄的nginx配置发下,方便大虾帮忙一下哦:

[root@dsvps2012 ~]# vim /usr/local/nginx/conf/vhost/www.giantsjerseys2012.com.conf 

log_format  www.giantsjerseys2012.com  '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';
server
        {
                listen       80;
                server_name www.giantsjerseys2012.com giantsjerseys2012.com;
                index index.html index.htm index.php default.html default.htm default.php;
                root  /home/wwwroot/giantsj2012com;


                proxy_set_header  Host $host;
                proxy_set_header  X-Real-IP $remote_addr;
                proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;

                include .htaccess.conf;

                location / {
                                proxy_pass  http://50.115.42.143:80;
                        }
                location ~* \.(jpg|jpeg|gif|png)$
                        {
                                access_log  off;
                                expires  30d;
                        }
                location ~* \.(js|css)$
                        {
                                access_log  off;
                                expires  1d;
                        }

                location ~ .*\.(php|php5)?$
                        {
                                try_files $uri =404;
                                fastcgi_pass  unix:/tmp/php-cgi.sock;
                                fastcgi_index index.php;
                                include fcgi.conf;
                        }

                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                        {
                                expires      30d;
                        }

                location ~ .*\.(js|css)?$
                        {
                                expires      12h;
                        }


                access_log  /home/wwwlogs/www.giantsjerseys2012.com.log  www.giantsjerseys2012.com;


        }

这个是在/usr/local/nginx/conf/vhost/www.giantsjerseys2012.com.conf添加的。。
不是在/usr/local/nginx/conf/nginx.conf添加的,因为我的vps要弄多个网站。。
希望大神帮忙解决一下哦。。谢谢了。。

展开
收起
kun坤 2020-06-04 11:20:15 896 0
1 条回答
写回答
取消 提交回答
  • location  里面指定 root  目录就行了。######回复 @新世纪IT民工 : 不是 你的样式出不来 就在样式那个 location 里面 加上 root 你存放样式的路径;######你是说在root那边把/home/wwwroot/giantsjersey2012com/改成apache里面那边的存放文件的路径吗???######样式不显示无外乎就是样式 404了呗,看下你的路径咯。######嗯嗯。。是路径出问题了。。没找到,我加了路径就可以了。。######location ~* .(js|css)$

    { root  /home/wwwroot/giantsj2012com/css #这里设置css的路径 access_log  off; expires  1d; }
    其他的类似 ######@新世纪IT民工 在别的服务器上的路径,没试过。本地是这样配的。######是的。。你那个路径要是不同的服务器可以吗?

    2020-06-05 13:21:44
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Dataflow with Apache NiFi 立即下载
CentOS Nginx PHP JAVA 多语言镜像使用手 立即下载
CentOS Nginx PHP JAVA多语言镜像使用手册 立即下载

相关镜像