Answers.Body: <p>With <code>$craftPath</code> you set the path to the <code>craft/</code> directory (containing the <code>app/</code> folder etc.) whereby your <code>index.php</code> is the starting point if you set this as a relative path:</p>
  
  <pre class="lang-php prettyprint-override"><code>// Path to your craft/ folder
  $craftPath = '../relative/path/to/craft_dir/';
  </code></pre>
  
  <p>As narration_sd pointed out, the <code>craft/</code> directory should be above the web root for security reasons. But this doesn't mean that you cannot have your <code>index.php</code> at <code>http://example.com/corp/index.php</code>. Just configure <code>$craftPath</code> accordingly. For example:</p>
  
  <p>Laravel at web root:<br>
  <code>/var/www/laravel-site/public/index.php</code></p>
  
  <p>Craft in a subdir:<br>
  <code>/var/www/laravel-site/public/corp/index.php</code></p>
  
  <p>Craft app above web root:<br>
  <code>/var/www/craftsite/craft/app/index.php</code></p>
  
  <p>Craft's path config:<br>
  <code>$craftPath = '../../../craftsite/craft';</code></p>
  
  <p>Remember to also update the paths to your assets in the Control Panel and the paths to your files linked to in your templates.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-29T12:58:28.053Z
Answers.Text: I guess I should have been more specific. My craft app is located at /var/www/craftsite/craft/app which is not publicly accessible.  
  
  I then have craft public folder located at /var/www/laravel-site/public/corp
  
  Inside this folder is where I have my craft front controller where I set $craftPath = '../../../craftsite/craft';
  
  I can pull up my craft homepage just fine. I can even work in my CP now. What craft cannot seem to do is find my template files.  Thanks for the assist.
Answers.UserDisplayName: David A McInnis
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-29T13:04:33.010Z
Answers.Text: @David edited the answer for you :)
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-29T13:20:52.597Z
Answers.Text: Update > Oddly only a single section of my craft site was affected. I changed the Entry URL Format to just {slug} instead of section_name/{slug} and kept my Entry Template as section_name/_entry and everything seems to work. I just lose my section name so my urls look like http://example.com/corp/about instead of http://example.com/corp/section_name/about. I would still like to understand what is happening.
Answers.UserDisplayName: David A McInnis
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-29T13:38:51.697Z
Answers.Text: Not sure if I still follow you (are you talking about a single "single section" that causes/caused problems?). But an idea I have is, that you now get your template by "URI to Template Path matching", read more about routing [here](http://buildwithcraft.com/docs/routing) (Pt.4 and Pt.6) in the docs.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-30T20:25:49.940Z
Answers.Text: Looks like that is just what I needed. Thanks.
Answers.UserDisplayName: David A McInnis
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-29T06:35:49.203Z
Answers.LastActivityDate: 2014-07-29T13:04:01.430Z
Answers.LastEditDate: 2014-07-29T13:04:01.430Z
Answers.UserDisplayName: carlcs
Body: <p>I need to install Craft under a laravel sub-directory <code>http://example.com/corp/</code> where <code>example.com</code> is a laravel site. </p>
  
  <p>Does anyone have a clean way to install craft in a directory below an existing app?</p>
  
  <p>Here is my config from <code>/corp/public/index.php</code></p>
  
  <pre class="lang-php prettyprint-override"><code>// Path to your craft/ folder
  $craftPath = '../../../craftsite/craft';
  
  // Do not edit below this line
  $path = rtrim($craftPath, '/').'/app/index.php';
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-29T06:40:33.007Z
Comments.Text: But do you really want to do this? You are asking for security trouble if you cannot assure very careful maintainenance over time of an .htaccess which refuses any web access to the craft directory. Hard to do. This is why the general advice is to put any app somewhere above web root, so that it never can be accessed. Maybe you need to talk to your corp IT guys to choose such a place?
Comments.UserDisplayName: narration_sd
Tags: <url><install><security>
Title: Installing Craft in sub directory
ThreadText: # Installing Craft in sub directory
  
  (Asked by: username_0 on 2014-07-29)
  
  I need to install Craft under a laravel sub-directory `http://example.com/corp/` where `example.com` is a laravel site.
  
  Does anyone have a clean way to install craft in a directory below an existing app?
  
  Here is my config from `/corp/public/index.php`
  
  ```php
  // Path to your craft/ folder
  $craftPath = '../../../craftsite/craft';
  
  // Do not edit below this line
  $path = rtrim($craftPath, '/').'/app/index.php';
  
  ```
  
  **Tags:** url, install, security
  
  > **Comments:**
  > **username_1**: But do you really want to do this? You are asking for security trouble if you cannot assure very careful maintainenance over time of an .htaccess which refuses any web access to the craft directory. Hard to do. This is why the general advice is to put any app somewhere above web root, so that it never can be accessed. Maybe you need to talk to your corp IT guys to choose such a place?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2014-07-29. Score: 1
  
  With `$craftPath` you set the path to the `craft/` directory (containing the `app/` folder etc.) whereby your `index.php` is the starting point if you set this as a relative path:
  
  ```php
  // Path to your craft/ folder
  $craftPath = '../relative/path/to/craft_dir/';
  
  ```
  
  As narration\_sd pointed out, the `craft/` directory should be above the web root for security reasons. But this doesn't mean that you cannot have your `index.php` at `http://example.com/corp/index.php`. Just configure `$craftPath` accordingly. For example:
  
  Laravel at web root:  
  `/var/www/laravel-site/public/index.php`
  
  Craft in a subdir:  
  `/var/www/laravel-site/public/corp/index.php`
  
  Craft app above web root:  
  `/var/www/craftsite/craft/app/index.php`
  
  Craft's path config:  
  `$craftPath = '../../../craftsite/craft';`
  
  Remember to also update the paths to your assets in the Control Panel and the paths to your files linked to in your templates.
  
  > **Comments:**
  > **username_0**: I guess I should have been more specific. My craft app is located at /var/www/craftsite/craft/app which is not publicly accessible.    I then have craft public folder located at /var/www/laravel-site/public/corp  Inside this folder is where I have my craft front controller where I set $craftPath = '../../../craftsite/craft';  I can pull up my craft homepage just fine. I can even work in my CP now. What craft cannot seem to do is find my template files.  Thanks for the assist.  
  > **username_2**: @username_0 edited the answer for you :)  
  > **username_0**: Update > Oddly only a single section of my craft site was affected. I changed the Entry URL Format to just {slug} instead of section_name/{slug} and kept my Entry Template as section_name/_entry and everything seems to work. I just lose my section name so my urls look like http://example.com/corp/about instead of http://example.com/corp/section_name/about. I would still like to understand what is happening.  
  > **username_2**: Not sure if I still follow you (are you talking about a single "single section" that causes/caused problems?). But an idea I have is, that you now get your template by "URI to Template Path matching", read more about routing [here](http://buildwithcraft.com/docs/routing) (Pt.4 and Pt.6) in the docs.  
  > **username_0**: Looks like that is just what I needed. Thanks.  
  
  ---
  
  