I'm trying to install a CakePHP app on a subdomain in my server. I want to make an advanced installation and separate the core and app libs from the webroot directory.
I put the entire project in a folder on home directory and move the content of webroot directory to subdomain's httpdocs directory.
Then, it looks like:
subdomains-httpdocs:
drwxrwxrwx 2 root root 4096 Mar 21 08:34 css
-rwxrwxrwx 1 root root 2760 Mar 21 08:34 css.php
-rwxrwxrwx 1 root root 374 Mar 21 08:34 favicon.ico
drwxrwxrwx 2 root root 4096 Mar 21 08:34 files
drwxrwxrwx 2 root root 4096 Mar 21 08:34 img
-rwxrwxrwx 1 root root 2731 Mar 21 08:43 index.php
drwxrwxrwx 2 root root 4096 Mar 21 08:34 js
-rwxrwxrwx 1 root root 3086 Mar 21 08:34 test.php
I edited the index.php file and change ROOT and APPDIR constants to point cake holder and app 开发者_开发技巧folders (at home directory), respectively. Finally, I modified the .htaccess files (3 files) adding RewriteBase parameter pointing to app directory (as cook book says http://book.cakephp.org/view/917/Apache-and-mod_rewrite-and-htaccess).
I checked that mod_rewrite is loaded in apache and AllowOverride All is active, but it doesn't work. It responses HTTP 500 everytime.
If I put the entire project in httpdocs directory (including webroot directory), it works perfectly.
Can you help me with this?
UPDATE
I checked again and it works if all directories are in httpdocs folder (core and app directories). However, they don't work in another location.
It returns
Warning: include(cake/bootstrap.php) [function.include]: failed to open stream: No such file or directory in /var/www/vhosts/mydomain.com/subdomains/subscribers/httpdocs/apptest/webroot/index.php on line 83
Warning: include(cake/bootstrap.php) [function.include]: failed to open stream: No such file or directory in /var/www/vhosts/mydomain.com/subdomains/subscribers/httpdocs/apptest/webroot/index.php on line 83
Warning: include() [function.include]: Failed opening 'cake/bootstrap.php' for inclusion (include_path='/home/systemtest:/home/systemtest/app/:.:') in /var/www/vhosts/mydomain.com/subdomains/subscribers/httpdocs/apptest/webroot/index.php on line 83
Thanks in advance
I found a solution:
After trying different things, I figured out that the problem was with webserver permissions. When the app and cake folder was in httpdocs directory, the application worked perfectly but after moving them to another directory, index.php was returning a HTTP 500 indicating that failed opening files in cake core directory.
The solution was to add a VirtualHost in httpd.include file of the subdomain:
<VirtualHost xx.xx.xx.xxx.xx:80>
ServerName subdomain.mydomain.com
Alias /myapp /home/myapp/app/webroot
DocumentRoot /home/myapp/app/webroot
<Directory /home/myapp/app/webroot>
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
I thought that I could separate app, cake and webroot directories and manage installation with .htaccess with no apache specific virtual host.
Thanks to Amy and Leo for their help
This could be done in a different way. There are some restrictions on which directory-paths can be opened in php. PHP defines the open_basedir directive which in turn limits the files that can be included.
On virtual hosting (such as your case) the default directory-tree includes
only your $_SERVER['DOCUMENT_ROOT']
and /tmp
directories so there is no way
for you to include the cake core if it located elsewhere.
A clean and simple solution is to append the absolute path of the directory
in which you will store the cake core, in your php.ini
After that you simply define your CAKE_CORE_INCLUDE_PATH
to point
at the directory in which cake core is installed.
This way you avoid adding a VirtualHost directive in httpd.conf
for every application you create, that runs on a subdomain or even the domain itself.
Hope that was helpful.
Jose
Leave the ROOT and APPDIR alone ( in your /app/index.php ) and just change the CAKE_CORE_INCLUDE_PATH in /app/webroot/index.php
/**
* The absolute path to the "cake" directory, WITHOUT a trailing DS.
*
*/
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
define(
'CAKE_CORE_INCLUDE_PATH',
DS . 'usr' . DS .'share' . DS . 'cakephp' . DS . '1.3.6'
);
}
That will read the core libs from a shared source. Add the cake core source path into the php include path if cake can't set it.
精彩评论