How do I configure nginx rewrite rules to get CakePHP working on CentOS?

前端 未结 6 2084
清歌不尽
清歌不尽 2021-01-31 12:42

Hi somebody please help me out, I’m trying to setup a cakephp environment on a Centos server running Nginx with Fact CGI. I already have a wordpress site running on the server a

6条回答
  •  生来不讨喜
    2021-01-31 13:05

    There's now official documentation on this issue, which I used and confirmed works.

    The documentation states:

    server {
      listen   80;
      server_name www.example.com;
      rewrite ^(.*) http://example.com$1 permanent;
    }
    
    server {
      listen   80;
      server_name example.com;
    
      # root directive should be global
      root   /var/www/example.com/public/app/webroot/;
      index  index.php;
    
      access_log /var/www/example.com/log/access.log;
      error_log /var/www/example.com/log/error.log;
    
      location / {
        try_files $uri $uri/ /index.php?$args;
      }
    
      location ~ \.php$ {
        try_files $uri =404;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index   index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      }
    }
    

提交回复
热议问题