### Fatal error: require_once() - lib/setup.php

Fatal error: require_once() - lib/setup.php

Last Juli Paul van Allsburg posted a problem, I got now too. When I try to install Moodle on my local Computer (Windows XP Professional SP2), installation process failed after starting http://localhost/install.php with the following error

Warning: require_once(/lib/setuplib.php) [function.require-once]: failed to open stream: No such file or directory in C:\moodle\moodle\install.php on line 133

Fatal error: require_once() [function.require]: Failed opening required '/lib/setuplib.php' (include_path='.;C:\moodle\php\pear\') in C:\moodle\moodle\install.php on line 133

http://moodle.org/mod/forum/discuss.php?d=75947

Paul himself fixed it:

I found my problem in httpd-vhosts.conf I had specified a FQDN and changing it to:

<VirtualHost *:80>
DocumentRoot "h:/public_html"
ServerName localhost
AcceptPathInfo on
</VirtualHost>

was the solution.

Unfortunately his solution does not work for me respectively I don't understand it completely.
Apache and MySQL seems to run well. I tried several Download Packages and installing methods, all with the same error and result.

Do you have any suggestions?
Many thanks!
Dirk

Average of ratings: Useful (1)
Re: Fatal error: require_once() - lib/setup.php

DP,

When you say you tried his solution, if you mean you literally copied that entire block of Apache directives (lines), then it won't work because your document root is not h:/public_html (I don't even know if you have a drive h). You need to change that to c:/moodle/moodle. Also, it won't do any good unless
1. your main Apache configuration file (usually called httpd.conf) contains an Include directive that references httpd-vhosts.conf, and
2. your main Apache configuration file doesn't mention your FQDN, e.g., in the Listen directive.
Also, this won't solve this particular problem, but it could cause problems in the future: I believe you need to edit your active php.ini file and change your include_path from '.;C:\moodle\php\pear\' to '.;C:\moodle\moodle\php\pear\'.

RLE

Average of ratings: Useful (1)
Re: Fatal error: require_once() - lib/setup.php

Thank you very much for youre answer!

First I removed and installed the complete package again and changed the main directory name to c:\xampplite before running setup_xampp.bat.

<VirtualHost *:80>
DocumentRoot "c:/xampplite/moodle"
ServerName localhost
AcceptPathInfo on
</VirtualHost>

Reference to httpd-vhosts.conf in httpd.conf is true.
Also I changed the include_path in php.ini in 3 steps:
1. no change
2. to C:\xampplite\moodle\php\pear\,
3. to C:\xampplite\moodle\ (cause the file setuplib.php is in c:\xampplite\moodle\lib).
Unfortunately the problem persists, and the error message after step 3 is:

Warning: require_once(/lib/setuplib.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampplite\moodle\install.php on line 144

Fatal error: require_once() [function.require]: Failed opening required '/lib/setuplib.php' (include_path='.;C:\xampplite\moodle\') in C:\xampplite\moodle\install.php on line 144

btw: I can't see a function require_once() in setup.lib, but I'm not familiar with php

So for my understandig, nothing really changes.
I still wonder why it should be necessary to change pathes after just unzip a package and follow precisely the installation guide.

I just started xampp-control.exe and got this message:
Current directory: c:\xampplite
Install directory: ***Warning: Directory Missmatch***

Average of ratings: -
Re: Fatal error: require_once() - lib/setup.php

DP,

I don't have a complete answer at this point because I need to go back to sleep, but I can answer some of your questions.

1. When you say you don't see a require_once function in setuplib.php, I presume you mean that it is not used there, and you are right. The error msg. is saying that it is used in C:\xampplite\moodle\install.php on line 144, and the target (argument) of it is lib/setuplib.php.
2. I think you should have stopped at step 2 in your php.ini changes: include_path should be '.;C:\xampplite\moodle\php\pear'. The '.' represents the current directory, which is normally C:\xampplite\moodle, so making include_path '.;C:\xampplite\moodle' is redundant. The '.' covers most cases; the C:\xampplite\moodle\php\pear covers cases where Moodle uses pear functions.
3. I also have Windows XP Pro SP2, and I have installed several versions of Moodle with the Windows package download without running into the problems you describe. As you said, you don't know php, among other things, so when you change things willy nilly and copy code from forum posts that don't apply to your situation, like PVA's, you are not following the installation guide precisely, and you end up with weird errors like Install directory: ***Warning: Directory Missmatch***. That is undoubtedly related to your other errors, but right now I don't have the time to research it. I'll see what I can do later. Or maybe someone else knows what is going on.
RLE

Average of ratings: -
Re: Fatal error: require_once() - lib/setup.php

DP,

OK. As promised, I Googled your XAMPP error msg. (after correcting the spelling error) and this forum thread contains a post (near the bottom of the page) that looks promising: http://www.apachefriends.org/f/viewtopic.php?p=108259 (it's the one about the registry). I think literally following its advice would be dangerous; in any case, ALWAYS, ALWAYS, ALWAYS BACK UP THE REGISTRY BEFORE EDITING IT. Instead, it would probably be safer to just uninstall XAMPPlite and then re-installing it.

RLE

Average of ratings: -
Re: Fatal error: require_once() - lib/setup.php

RE,

thank you very much again!

I completly deinstalled the package and installed it once more.
Editing the Windows Registry as described in the posting you figured out indeed corrects the warning in xampp-control.exe. Here seems to be anything fine now.

Unfortunately the initial problem persists, independent of all further changes in php.ini and httpd-vhosts.conf as suggested before.

My original purpose was to familiarize myself with moodle and work out my courses on my local computer before loading it up on a webserver (and also to use the time I have to wait until this server is available and configured by my collegues). But it's not really dramatic to wait for the server and try to install Moodle there (with not those strange problems, I hope).
So if you or anybody else here don't have any further idea on my problem, I just thank you again very much for youre kind help!

DP

Average of ratings: -
Re: Fatal error: require_once() - lib/setup.php

DP,
1. Could you verify that c:\xampplite\moodle\lib\setuplib.php is there, in the right folder (directory)?
2. What does your c:\xampplite\moodle\config.php say for $CFG->dirroot and$CFG->wwwroot? What values are assigned to them?
3. Could you attach to your post your main Apache configuration file, which I presume is c:\xampplite\apache\conf\httpd.conf?
RLE

Average of ratings: -
Re: Fatal error: require_once() - lib/setup.php

RLE,

after reinstallation I kept the default foldername "server", so my mainpath now is C:\server.

1. c:\server\moodle\lib\setuplib.php is present
2. there is only c:\server\moodle\config-dist.php, it says $CFG->dirroot = '/home/example/public_html/moodle'; and$CFG->wwwroot = 'http://example.com/moodle';
3. httpd.conf is attached
Best regards

DP

Average of ratings: -
Re: Fatal error: require_once() - lib/setup.php

DP,

OK. Your httpd.conf file confirms what I suspected: the stuff you put in httpd-vhosts.conf is irrelevant. Apache will ignore it because the main server configuration will be used instead. This is because the Listen directive is

Listen 80

as it is in mine, which means anything that comes in from a browser on port 80 (the standard port for webserving) will be processed under the main server settings.

However, that's okay because those settings are okay, namely:

ServerName localhost:80
DocumentRoot "C:/server/moodle"
<Directory />
AcceptPathInfo On
AllowOverride None
Order deny,allow
Deny from all
</Directory>
<Directory "C:/server/moodle">
AllowOverride All
Order allow,deny
Allow from all
</Directory>

which is completely consistent (except for a couple of minor differences in the values of ServerAdmin and ServerName) with what you put into httpd-vhosts.conf.

I would recommend that you not use xampp-control.exe. If you just use the bat files (setup_xampp, apache_start, apache_stop, mysql_start, mysql_stop), according to the Moodle docs that I use (and my own experience), you shouldn't have problems with the registry because they don't use it.

The only questions now are
1. Is setuplib.php in the right place (c:\server\moodle\lib)? and
2. Are you using safe_mode or open_basedir, which are security features in PHP that can interfere with its ability to open files in different folders?
RLE

Average of ratings: -
Re: Fatal error: require_once() - lib/setup.php

RLE,

1. setuplib.php is in c:\server\moodle\lib
2. I wrote and opened a php-info-file as described here.
Open_basedir has "no value".
Safe_mode is monitored as
 safe_mode Off Off safe_mode_exec_dir no value no value safe_mode_gid Off Off safe_mode_include_dir no value no value
 safe_mode_allowed_env_vars PHP_ PHP_ safe_mode_protected_env_vars LD_LIBRARY_PATH LD_LIBRARY_PATH
 sql.safe_mode Off Off

Are the pathes in c:\server\moodle\config-dist.php important?
$CFG->dirroot = '/home/example/public_html/moodle'$CFG->wwwroot = 'http://example.com/moodle'

DP

Average of ratings: -
Re: Fatal error: require_once() - lib/setup.php

DP,
1. OK
2. Looks like safe_mode and open_basedir are off. That's good.
3. No, the paths in config-dist.php are not important. That file is just a sample of config.php that is there for people who want to create config.php manually by copying config-dist.php to config.php and modifying it by hand, instead of by running the installation script install.php.
4. What is the value of include_path in php.ini? It gives you this value in the error msg. that says

Fatal error: require_once() [function.require]: Failed opening required '/lib/setuplib.php'

5. You don't have a config.php file because install.php has not created it yet. The paths I asked you about come from the answers you supply when the installation script asks you for the pathname to your main Moodle folder (directory), and your URL. What answers did you give for these questions the last time you tried to install Moodle?
RLE

Average of ratings: -
Re: Fatal error: require_once() - lib/setup.php

RLE,

4. include_path = ".;C:\server\moodle\php\pear\" in c:\server\php\php.ini
5. Sorry, but the problem is that after starting apache, mysql and http://localhost, install.php stops with the posted error message immediately after choosing the language. I don't reach any questions for directories.

DP

Average of ratings: -
Re: Fatal error: require_once() - lib/setup.php

DP,

4. That may be the value in c:\server\php\php.ini, but I don't know at this point if that is your active php.ini file. There is a way to find out, but there is a quicker way to get the value of include_path, and that is to look in the error msg. as I specified in question #4 in my previous post.
5. Okay. This is very strange. There is a fairly common problem that happens at that point, but this isn't it. The only explanation I can think of is that c:\server\php\php.ini is not, in fact, your active php.ini file, and that in the one that is active, include_path does not include the ".;". Because that dot means the current directory, which in this case is C:\server\moodle, so that it should find setuplib.php, since you said it was in the right place.

I just thought of another reason. Maybe the permissions for C:\server\moodle\lib are such that Apache (which runs PHP) is being denied access to it.

RLE

Average of ratings: -