I have been developing PHP for many years now and just recently started learning Yii.
I have installed Yii to a remote server following instructions in The Definitive Guide. Then I checked requirements using the built-in checker and everything seemed to be ok although i got warnings about these:
Then i tried to run /demos/blog/ and it gave me Error 500 in the home, contact and about -pages:
copy(/path/to/yii-1.1.2.r2086/demos/blog/assets/8734a6e2/gridview/view.png) [<a href='function.copy'>function.copy</a>]: failed to open stream: No such file or directory
I think Yii is trying to use some jQuery component when this error occures…? So I checked /framework/vendors/ and found out that CGridView and CListView widgets uses jQuery BBQ Plugin 1.1.1. But /framework/vendors/bbq/ contains only LICENSE.TXT. Should there also be those .js files? Or do I have to upload & install those .js libraries manually?
The error says, it can’t find the copy function of PHP, which is really strange as it’s a built in function. Do you maybe have safe mode enabled in PHP and restricted the available functions?
I’m sorry, i was wrong about the meaning of the error. It rather means, that the path couldn’t be found. Do you have the demos/blog/assets folder and is it writable for your webserver process?
Hmm, strange. You say, you have PHP experience, so maybe you can debug a little on your own. You should not really alter any framework files, but for debugging this might sometimes be necessary . Just be sure, to revert your changes afterwards again:
Check out, what’s going on in /framework/utils/CFileHelper.php and why it can’t copy to that path in line 123. It seems like @mkdir in line 111 is already failing, if your assets folder stays empty.
To make this clear: Things like these are very uncommon. So if you have another server available around, maybe try it there first.
I tried to install & run the blog demo in another server (debian) and it works ok there. So the problem is definitely now in the first test server (fedora). I’ll dive into CFileHelper.php later today and try to debug it more as you said.
Okay, I have now found out that the servers SELinux feature is preventing the use of mkdir() function. I noticed than when I tried to run the blog demo, it inserts some error logs to SELinux log file in /var/log/audit/audit.log.
Then I ran Blog demo again and now it populates the /assets/ folder but crashes in the YiiBase.php:
PHP Error
Description
include(DOMDocument.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory
00326: * @param string class name
00327: * @return boolean whether the class has been loaded successfully
00328: */
00329: public static function autoload($className)
00330: {
00331: // use include so that the error PHP file may appear
00332: if(isset(self::$_coreClasses[$className]))
00333: include(YII_PATH.self::$_coreClasses[$className]);
00334: else if(isset(self::$_classes[$className]))
00335: include(self::$_classes[$className]);
00336: else
00337: {
00338: include($className.'.php');
00339: return class_exists($className,false) || interface_exists($className,false);
00340: }
00341: return true;
00342: }
00343:
00344: /**
00345: * Writes a trace message.
00346: * This method will only log a message when the application is in debug mode.
00347: * @param string message to be logged
00348: * @param string category of the message
00349: * @see log
00350: */
stack trace:
#0 /var/www/path/to/yii/framework/YiiBase.php(338): autoload()
#1 unknown(0): autoload()
#2 unknown(0): spl_autoload_call()
#3 /var/www/path/to/yii/framework/vendors/htmlpurifier/HTMLPurifier.standalone.php(5849): class_exists()
#4 /var/www/path/to/yii/framework/vendors/htmlpurifier/HTMLPurifier.standalone.php(142): create()
if (
class_exists('DOMDocument') &&
method_exists('DOMDocument', 'loadHTML') &&
!extension_loaded('domxml')
) {
// check for DOM support, because while it's part of the
// core, it can be disabled compile time. Also, the PECL
// domxml extension overrides the default DOM, and is evil
// and nasty and we shan't bother to support it
$lexer = 'DOMLex';
} else {
$lexer = 'DirectLex';
}
So blog demo is obviously using HTMLPurifier (?) and trys to load the xml dom extension which is not installed on your server.
// If you can’t install the dom extension or there is no other solution, simply modify the line like this:
if (
false
) {
That should make it I guess. File is in /framework/vendors/htmlpurifier/HTMLPurifier.standalone.php
I’m not sure if this is related… I hope this is a good place to post this.
I’m running Fedora, which uses SELinux. When I tried the “Web Service Stock Demo” - it didn’t work - giving a Permission Denied error. So I did a “setenforce 0” and tried again. It worked.
However, I want to be able to have SELinux enabled. So, I did some digging. To get SOAP to work correctly I found that I needed to do a "setsebool -P httpd_can_network_connect 1" command. Now, everything is working how it should and SELinux is still enforcing.
I hope someone will find this post useful, because it took me a long time to find the answer to this. Hence this post.