Wednesday, March 9, 2011

Raymond: Install moodle under linux plesk

Raymond: Install moodle under linux plesk: "I have had so many issues installing Moodle and in searching the forums have found that many people had similar issues, though mine perssist..."

Install moodle under linux plesk

I have had so many issues installing Moodle and in searching the forums have found that many people had similar issues, though mine perssisted. So I figured I'd write a little guide with my experiences in it to help others in their search.

I'm running moodle with mediatemple.net on a dedicated virtual server. Specs are:

* CentOS release 5 (Final)
* Apache (version 2.2.3)
* Perl (version 5.8.8)
* PHP (version 5.2.5)
* MySQL (version 5.0.22)

This should help with pretty much any Linux/Unix OS on a Vhosts/Plesk setup.

First skip the install.php process and edited the config.php file directly. In order to do this you need to make the folder moodledata outside of your httpdocs directory.

Unfortunately you likely can't do that without root access. So SSH into the server with root and mkdir moodledata in your vhosts/domain.com/ directory.

chmod the directory to 777 (try different permissions once you get it to work). chown the directory with -apache -apache

Now you need to turn off php safe_mode in your php.ini file likely located in your /etc/ folder. Just change safe_mode on to safe_mode off. Then restart your appache server, but if you follow the rest of the instructions you'll need to do that later anyway.

Funny thing is - this will get you past the installation phase. Unfortunately, won't let you do anything inside Moodle. You won't be able to create courses or add users. If you follow your error log it will say open_basedir restrictions in effect, is outside the specified path(s). Or something similar.

There are many posts in the forum for ways to deal with open_basedir restrictions and only one of them worked for my vhosts setup...

in /var/www/vhosts/domain.com/conf create a file called vhost.conf

Inside put:



php_admin_flag engine on

php_admin_value open_basedir "/var/www/vhosts/domain.com/httpdocs/:/var/www/vhosts/domain.com/moodledata:/tmp"



If you do this you'll be able add users and even upload users from a csv file with the right plugin. You'll need to enter this command in your SSH console:

/usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=domain.com

And restart your server.

Unfortunately, if your setup is like mine, this will still leave you with one more problem. If you try to upload files to sitefiles or to courses it will say "the site administrator needs to fix file permissions". And if you check your server logs it will give you the same open_basedir restrictions error as before.

You also need to create another entry in your vhost.conf file:



php_admin_flag engine on

php_admin_value open_basedir "/var/www/vhosts/domain.com/httpdocs/moodledata/:/var/www/vhosts/domain.com:/tmp"



The first entry ensures that httpdocs can write to moodledata but this second one ensures moodledata can write back to httpdocs. Don't forget to:

/usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=domain.com

and restart your apache server.

As an alternative, if you want, you MIGHT be able to turn off open_basedir restrictions inside your php.ini file. I didn't get to trying this but have a feeling that it won't work.

The reason it won't work on a vhost setup is that the open_basedir command is located in A LOT OF PLACES, not just php.ini. In some places it's turned on, in others it's turned off. You essentially need to specify whether it's on or off on a PER DOMAIN but also PER DIRECTORY basis.

Hope this helps someone,





Me, again. Just encountered and resolved a strange behavior involving the "php_admin_value open_basedir is in effect" error message.

I spent much of today struggling with installing Moodle on a different domain also hosted on my new VPS Plesk account. I went through exactly the same procedures described above by Tarik as I did yesterday, but instead of sweet success, I encountered the "open_basedir in effect" error message from hell on the second page of the Moodle installation process. Arghhh!!!

Looking carefully at the error message, I noticed an inconsistency in the message-- the first part of the error message mentions the directory "moodledata" is not in the permitted directory "moodledata1"-- which is true since I had named the moodle data directory placed above the web root "moodledata1". But here was the Moodle install.php file apparently looking for the directory moodledata, seemingly before it had asked me for the name of the data directory. Odd. I've never seen that script behavior before.

So I decided to try feeding install.php what it seemed to be asking for. I renamed moodledata1 to moodledata, changed the references in my vhost.conf file, reconfigured vhost, restarted Apache2, and then pointed my browser to install.php-- and this time Moodle sailed through the installation without a hiccup!

This is very strange, I think, because I have installed Moodle several other times on non-VPS hosts (shared hosting with Cpanel access) using various custom names for the Moodle data directory without Moodle ever complaining.

Has anyone else run into this problem?

I was hoping to install a second Moodle on the same domain to serve as an archive, but if I can only name and use ONE Moodle data directory... then that's a problem.

Puzzled for now. But at least my single Moodle installation is working. thoughtful




http://download1.parallels.com/Plesk/PPP9/Doc/en-US/plesk-9.0-administrators-guide.pdf

让 CodeIgniter 支持 $_GET

方法一:
CI默认过滤了$_GET

需要传递get参数时一般直接 /参数一/参数二
详见手册说明:http://codeigniter.org.cn/user_guide/general/controllers.html#passinguri

但是有时候需要传递很长的复杂的url,比如常用的 http://www.nicewords.cn/index.php/controller/method/?backURL=http://baidu.com/blog/hi

这时 这种模式就行不通了。参数中本身的/会与默认的分隔符冲突

解决方案:

1) 在config.php 中,将‘uri_protocol’ 设置为 ‘PATH_INFO’.
PHP
$config['uri_protocol'] = "PATH_INFO";
复制代码


2) 在需要使用$_GET的之前加:
PHP
parse_str($_SERVER['QUERY_STRING'], $_GET);
复制代码


这样,形如 index.php/blog/list?parm=hello&page=52 就可以运行了。

官网说明:
http://codeigniter.com/wiki/QUERY_STRING_GET/
也许您还可能感兴趣:

* • PHP搭建基于CI框架的REST服务架构


方法二:
我在官網討論區看到一篇很不錯的解法 http://codeigniter.com/forums/viewthread/68698/#389281
他只有二個步驟

1.config.php的設定
$config['uri_protocol'] = "REQUEST_URI";
$config['enable_query_strings'] = TRUE;


2.將以下程式存檔,檔名叫MY_URI.php
存檔路徑 自己的system/application/libraries/ folder

PHP

class MY_URI extends CI_URI {

function MY_URI() {
parent::CI_URI();
}

// --------------------------------------------------------------------

/**
* Override the _parse_request_uri method so it allows query strings through
*
* @access private
* @return string
*/
function _parse_request_uri()
{
if ( ! isset($_SERVER['REQUEST_URI']) OR $_SERVER['REQUEST_URI'] == '')
{
return '';
}

$uri = explode("?",$_SERVER['REQUEST_URI']); // This line is added to the original
$request_uri = preg_replace("|/(.*)|", "\\1", str_replace("\\", "/", $uri[0])); // This line changed
// Everything else is just the same

if ($request_uri == '' OR $request_uri == SELF)
{
return '';
}

$fc_path = FCPATH;
if (strpos($request_uri, '?') !== FALSE)
{
$fc_path .= '?';
}

$parsed_uri = explode("/", $request_uri);

$i = 0;
foreach(explode("/", $fc_path) as $segment)
{
if (isset($parsed_uri[$i]) AND $segment == $parsed_uri[$i])
{
$i++;
}
}

$parsed_uri = implode("/", array_slice($parsed_uri, $i));

if ($parsed_uri != '')
{
$parsed_uri = '/'.$parsed_uri;
}

return $parsed_uri;
}

}

?>
复制代码