dongshao1873 2018-12-04 16:41
浏览 82

NGINX + Apache2 + codeigniter - 子路径无法正常工作

I currently have 2 PHP applications up and running on my DigitalOcean's Ubuntu server. There is a third one as well, but it's not working. All three PHP projects are configured to run on different ports. Meanwhile, using NGINX server I have configured a reverse proxy. The configuration is as given below.

/etc/nginx/nginix.conf

server {
        listen          80;
        server_name     IP;
        location / {
              #Assinged to a python project
        }
        location /php_project_1 {
            proxy_pass http://IP:5002;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header HOST $http_host;
        }

        location /php_project_2 {
            proxy_pass http://IP:5003;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header HOST $http_host;
        }
        location /php_project_3 {
            proxy_pass http://IP:5004;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header HOST $http_host;

        }
    }

I have also created 3 configuration files in /etc/apache2/sites-available.

PROBLEM

php_project_1 and php_project_2 are developed using core PHP and they work fine.

php_project_3 is developed using codeigniter. and that is the project which is causing me problems. Inside this project, under /application/config/config.php I have modified $config['base_url'] and entered the values as http://IP/php_project_3.

However, when I hit the URL http://IP/php_project_3, I get a blank page. I also checked /var/logs/apache2 and /var/logs/nginx, however, the error.log file does not show any messages corresponding to my request.

Meanwhile, I can successfully run the other 2 applications using http://IP/php_project_1 and http://IP/php_project_2

I don't know how to troubleshoot this issue.

  • 写回答

1条回答 默认 最新

  • doukesou4452 2018-12-04 21:43
    关注

    The value for $config['base_url'] should end in a slash, so try

    $config['base_url'] = 'http://IP/php_project_3/';
    

    If the above still produces a blank and there are no errors to be found in any log files at /application/logs/ then you might have a BOM on one of your script files. I've run into them at the very beginning of the script before the opening <?php. Start with the controller. Delete that opening line, then retype it - test, repeat on any "view" files the controller uses until you find the offender.

    You can see if the proxy is being delivered to the correct directory by temporarily replacing CodeIgniter's index.php with another file of the same name but with a simple text output, i.e.

    <?php
    echo "Hello World"; 
    

    Obviously, if you see the text the problem lies outside of a server config issue.

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?