<p>If you want to just adjust the folder for the webroot set the root to</p>

<p>/srv/www/webroot/articles/</p>

<p>And in the index.php file make sure the path to the craft folder is</p>

<p>'../../app/craft'</p>

<p>UPDATE:</p>

<p>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</p>

<p>and in the nginx file add this</p>

<pre><code>location /articles/ {
  try_files $uri $uri/ @rewrites;  
}

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

<p>put that directly above this line, everything else can be the same</p>

<pre><code>location ~ \.php$ {
</code></pre>

CC BY-SA 3.0
2014-11-12T04:01:50.750Z
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.
CC BY-SA 3.0
2014-11-12T04:06:46.297Z
ok let me update my answer then
Keith Mancuso
CC BY-SA 3.0
2014-11-12T04:57:29.857Z
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.
CC BY-SA 3.0
2014-11-12T06:32:28.097Z
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.
CC BY-SA 3.0
2014-11-12T07:10:47.767Z
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
CC BY-SA 3.0
2014-11-12T03:57:24.380Z
2014-11-12T04:10:15.367Z
2014-11-12T04:10:15.367Z
Keith Mancuso
<p>I'm starting with a clean install, empty database.  </p>

<p>What would be the changes needed to this <a href="https://craftcms.stackexchange.com/questions/961/what-is-the-recommended-nginx-configuration-for-craft">Nginx configuration</a> to serve craft from /articles/ instead of "/"?</p>

<p>Any specific configurations that needs to be done to the Craft configs?</p>

<p>I've tried many combinations that all ended in 404.</p>

<p>Current layout:</p>

<p>/srv/www/app/craft &lt;- "craft files"</p>

<p>/srv/www/webroot &lt;- "public webroot"</p>

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

<p>Thanks.</p>

<install><nginx>
Serving Craft from a sub-directory on Nginx
# Serving Craft from a sub-directory on Nginx

(Asked by: username_0 on 2014-11-12)

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

What would be the changes needed to this [Nginx configuration](https://craftcms.stackexchange.com/questions/961/what-is-the-recommended-nginx-configuration-for-craft) 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.

**Tags:** install, nginx

---

## 1 answers

### Answer by username_1 on 2014-11-12. Score: 1 | Accepted answer

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$ {

> **Comments:**
> **username_0**: 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.  
> **username_1**: ok let me update my answer then  
> **username_0**: 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.  
> **username_0**: 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?  
> **username_1**: 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  

---

