doannam28
By:
doannam28

Help me cakephp and nginx

June 16, 2014 3k views
Dear! I'm using nginx VPS. Source cakephp code But now I can not get vhost configuration. My site is http://phimcucnhanh.com have successfully configured. But I add configuration for website mobile http://m.phimcucnhanh.com not run. I want to run in fodel http://m.phimcucnhanh.com domain name www / sites / m.phimcucnhanh.com / but I do not. It took me 2 days to do this without success. We wish your help. # Vhost.conf
server {
   listen   80;
   server_name www.phimcucnhanh.net phimcucnhanh.net www.phimcucnhanh.com;
   rewrite ^(.*) http://phimcucnhanh.com$1 permanent;
}

server {
    listen   80;
    server_name phimcucnhanh.com;

    # root directive should be global
    root   /www/website/phimcucnhanh.com/app/webroot/;
    index  index.php;

    access_log /www/website/phimcucnhanh.com/log/access.log;
    error_log /www/website/phimcucnhanh.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    127.0.0.1:9000;
        fastcgi_index   index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		#fastcgi_param SCRIPT_FILENAME /www/website/phimcucnhanh.com/app/webroot/index.php;
    }
}
#WEb mobile
server {
    listen   80;
    server_name m.phimcucnhanh.com;

    # root directive should be global
    root   /www/website/m.phimcucnhanh.com/app/webroot/;
    index  index.php;

    access_log /www/website/m.phimcucnhanh.com/log/m.access.log;
    error_log /www/website/m.phimcucnhanh.com/log/m.error.log;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        try_files $uri =404;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_index   index.php;
        #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		fastcgi_param SCRIPT_FILENAME /www/website/m.phimcucnhanh.com/app/webroot/index.php;
    }
}
Thank you very much!
2 Answers
Looks like you've got it up and running! I see the mobile site when I visit http://m.phimcucnhanh.com Would you mind sharing what you needed to fix to help the next person who comes along? I don't see anything particularly wrong with those configurations. Were you seeing errors in the logs? What happened when you tried visiting the mobile site, was there an error message?
  • Hi Astarr! Thank you for your interest in my question. Http://m.phimcucnhanh.com it now at the link following error
    Notice (8): Undefined variable: theloai [APP / View / Home / index.ctp, line 6]
    Code Context
    
    include - APP / View / Home / index.ctp, line 6
    View :: _evaluate () - / www / sites / phimcucnhanh.com / lib / Cake / View / view.php, line 920
    View :: _render () - / www / sites / phimcucnhanh.com / lib / Cake / View / view.php, line 883
    View :: render () - / www / sites / phimcucnhanh.com / lib / Cake / View / view.php, line 475
    Controller :: render () - / www / sites / phimcucnhanh.com / lib / Cake / Controller / Controller.php, line 957
    _invoke :: Dispatcher () - / www / sites / phimcucnhanh.com / lib / Cake / Routing / Dispatcher.php, line 193
    Dispatcher :: dispatch () - / www / sites / phimcucnhanh.com / lib / Cake / Routing / Dispatcher.php, line 161
    [Main] - APP / webroot / index.php, line 93
    
    demonstrate that link http://m.phimcucnhanh.com still run into fodel /www/website/phimcucnhanh.com rather than run in fodel /www /website/m.phimcucnhanh.com. We wish Astarr help her because I took 3 days are yet to config it. Thank!
  • When I goto http://m.phimcucnhanh.com, this is what I see: http://i.imgur.com/iNTjAYl.png Is that correct? Are you seeing error messages in /www/website/m.phimcucnhanh.com/log/m.error.log ?
Have another answer? Share your knowledge.