1

I'm starting with a clean install, empty database.

What would be the changes needed to this Nginx configuration to serve craft from /articles/ instead of "/"?

Any specific configurations that needs to be done to the Craft configs?

I've tried many combinations that all ended in 404.

Current layout:

/srv/www/app/craft <- "craft files"

/srv/www/webroot <- "public webroot"

/srv/www/webroot/articles/ <- "craft index.php here (with path set correctly to craft)".

Thanks.

| improve this question | | | | |
1

If you want to just adjust the folder for the webroot set the root to

/srv/www/webroot/articles/

And in the index.php file make sure the path to the craft folder is

'../../app/craft'

UPDATE:

If you instead want to leave the webroot as is and just have craft run from yourdomain.com/articles you would need to also update the index.php to make sure the craft path is set correct

and in the nginx file add this

location /articles/ {
  try_files $uri $uri/ @rewrites;  
}

location @rewrites {
   rewrite ^/articles/(.*)$ /articles/index.php?p=$1 last;
}

put that directly above this line, everything else can be the same

location ~ \.php$ {
| improve this answer | | | | |
  • Actually, the purpose of this sub-directory is that I have another app running from the webroot/, I can't point the server root to articles/. (index.php is set to point to ../../app/craft, and I do get 404 pages from Craft, but not much more. – Mathieu P. Nov 12 '14 at 4:01
  • ok let me update my answer then – Keith Mancuso Nov 12 '14 at 4:06
  • 1
    Keith, I think it worked. Initially I still got the 404, but calling /articles/admin/install fired the install process. It ended with a Oops page, but nothing alarming in the craft.log, and all looks operational so far. I will do more testing. – Mathieu P. Nov 12 '14 at 4:57
  • Once inside the CP, I had to add /articles to the end of the site URL under the General Settings, is this normal or should that have been set automatically during install? – Mathieu P. Nov 12 '14 at 6:32
  • Yea that's normal. You can also just site the siteurl in the general.config but craft expects that to be the root of any craft urls it will build – Keith Mancuso Nov 12 '14 at 7:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.