Moodle 2.5: Installation error moodle/user/editadvanced.php?id=2

Moodle 2.5: Installation error moodle/user/editadvanced.php?id=2

by Rashid Brown Shomari -
Number of replies: 2

Hello all;

I have a pretty strong .NET developper background, and this is my first time to try something else (php, mysql,...)

I have installed and configured Moodle 2.5 + PHP 5.4 + MYSQL 5.6 + IIS 7 on Win7

I keep on getting the following error message during the final installation steps (version 2.5), the page in browser is:../moodle/user/editadvanced.php?id=2

And the message displayed on the page is: 

Default exception handler: Sorry, but you do not currently have permissions to do that (Update user profiles) Debug: 
Error code: nopermissions
* line 730 of \lib\accesslib.php: required_capability_exception thrown
* line 69 of \user\editadvanced.php: call to require_capability()

Has anyone come accross this? I have a valid db user with all rights granted in mysql moodle database.

Your help will be much appreciated. I have checked the code files (accesslib.php and editadvanced.php) and it seems id=2 (admin) does not have some sort of persmission.

Thank you.
Zinczinc
Average of ratings: -
In reply to Rashid Brown Shomari

Re: Moodle 2.5: Installation error moodle/user/editadvanced.php?id=2

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

My guess would be that some part of the installation has failed and the permissions structure is not set up properly. 

What I would do is to start again (drop the database) - this time, create config.php by copying config-dist.php, edit is 'manually' and look for the lines that force debugging on. Enable debugging and run the install again. 

Watch out for errors and also check your web server logs. 

Average of ratings: Useful (1)
In reply to Howard Miller

Re: Moodle 2.5: Installation error moodle/user/editadvanced.php?id=2

by Rashid Brown Shomari -

Hi Howard,

Thank you very much for your suggestion. I dropped the MySQL database and ran a fresh install. Everything is fine now. In fact, I changed to MS SQL Server. So currently my recipe is: Moodle 2.5 + PHP 5.4 + MS SQL Server 2008 R2 Express Edition + IIS 7 on Windows 7 Professional 32 bit. Everything runs very well.

I can share my experience with those who might face problems with configurations similar to mine:

1. Ensure your IIS 7 is up and running without any problem;

2. Ensure SQL Server is TCP/IP protocol is enabled and that your SQL server IP address with port 1433 is active and enabled. For my case, Since I also run a couple of other ASP.NET apps on the same machine under IIS, and since I did not want to use the default port (1433), I did the following: among the many IP addresses (IP1, IP2, IP3, ....IPAll), I chose IP8 with loopback IP address=127.0.0.1, and ensured Active=yes, Enabled=yes. I also deleted the 0 value that was in TCP Dynamic Ports. In TCP Port, I entered 1434. (Later on, I had to enter this port value in the config.php file located in the moodle folder).

I also ensured SQL Server Native Client TCP/IP protocol was enabled that SQL Server Browser was up and running.

3. In SQL 2008 R2 Express, I created a database named "MyMoodleDb." (You can name it anything). Right after creating it, I changed it properties Options as follows: Collation=SQL_Latin1_General_CP1_CS_AS; ANSI NULLS Enabled=True; Quoted Identifiers Enabled=True

These options can be set when creating the database. Otherwise, change them right after creation, before any table is created in the DB (...to avoid trouble later, especially with collation change...).

Next, enable row versioning as suggested at http://docs.moodle.org/25/en/Installing_MSSQL_for_PHP (... Row Versioning Enabled (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)

  • This is not settable via the DB properties. To set READ_COMMITTED_SNAPSHOT, there must be no active connections to the database except for the connection executing the ALTER command. If you are viewing the DB in the Server Management Studio, disconnect from any servers in the "Object Explorer" (right-click > Disconnect), then create a "New Query" and run the ALTER command. See http://msdn.microsoft.com/en-us/library/bb522682.aspx for details.)

4. Finally, create a server user (SQL Server authentication), mapped to YourMoodleDataBaseCreatedAbove (with default database=YourMoodleDataBaseCreatedAbove). This is going to be the moodle admin. I created a user name in capital, but then moodle complained (I did not investigate why...), so I just made the story short by creating a user with a name in small letters.

5. Have PHP Manager installed on IIS 7 (I used "PHPManagerForIIS-1.2.0-x86.msi" downloaded from Codeplex. I installed it and a "PHP Manager" appeared in IIS that gave me access to a PHP configuration UI). I download mine (32 bit) from http://phpmanager.codeplex.com/releases/view/69115

6. Place your moodle folder in any location of your hard disc. Mine was placed in some location named "D:\My Applications\Some path name with space does not matter\Deeper Folder does not matter\".

Ensure IIS_IUSRS has read permission on the moodle folder.

7. Create an empty folder for your data (this is often referred to as moodle data folder). I, for instance, created my folder in the same directory as the moodle folder ("D:\My Applications\Some path name with space does not matter\Deeper Folder does not matter\") and named it "moodledatagoeshere."

Ensure IIS_IUSRS has read + write permissions to it (meaning to the moodledatagoeshere folder).

8. Have your PHP folder placed in any location on your HDD (I placed mine in the same location as the moodle folder);

9. Download and install the Microsoft Drivers 3.0 for PHP for SQL Server to provide connectivity to Microsoft SQL Server from PHP applications. I downloaded mine from http://www.microsoft.com/en-us/download/details.aspx?id=20098. During the installation, a "File Open Dialog" will prompt you to point to the location where the PHP extensions should be unpacked. So you should, at the dialog prompt, navigate to the "ext" folder. For my case, I navigated to: "D:\My Applications\Some path name with space does not matter\Deeper Folder does not matter\php\ext".

I did not use FreeTDS. Therefore, I advise not to use it either, and to skip or disregard any step related to its use.

10. Go to Control Panel>System>System Protection> click Advanced tab, then click Evironment Variables..., then under System Variables, scroll down and find the "Path" variable, click Edit... and at the end of the entry, append the location to your PHP folder. I appended mine like this: "D:\My Applications\Some path name with space does not matter\Deeper Folder does not matter\php\;"

I read somewhere that it was necessary to create a registry key HKEY_LOCAL_MACHINE\SOFTWARE\PHP, then under it, create a name=IniFilePath with data=full path to your php.ini file. This was not necessary for my case. In fact, I had to delete the IniFilePath entry that I had created earlier because it would otherwise not be possible to change the location of php.ini file when configuring PHP in IIS 7, by using "PHP Manager" (installed in step 5 above).

11. Using PHP Manager in IIS, configure PHP: In PHP Manager, under PHP Setup, click the link "Register a new PHP version" and navigate to your php-cgi.exe. If you do not see it, make sure the "File Open" Dialog filter is set to "*.*" (All files).

Under PHP Settings, click the "manage all settings" link and change the settings as recommended (error_log="C:\Windows\Temp\My_Php_Via_FastCGI_errors.log" -you can choose a different location; extension_dir=D:\My Applications\Some path name with space does not matter\Deeper Folder does not matter\php\ext; fastcgi.impersonate=1; fastcgi.logging=1; max_execution_time=600 (I put a bigger value to ensure installation goes well later); date_timezone="europe/belgrade" (include the quotes. Of course, your zone could be different); max_textlimit=20971520; max_textsize=20971520; mssql_timeout=1200 (just to ensure install goes well. Afterwards, I took it down to 60).

Note: As I changed the PHP ini settings values though IIS PHP Manager, I did not need to change the same values again manually in the php.ini file. If you change the value manually again, you have double entries for all those values in your IIS PHP Manager Settings.

12. Ensure FastCGI is properly configured in IIS 7. Under FastCGI settings, the php exe file must be your php-cgi.exe (Fully-Qualified file name), (the file is located in your php folder). Also, the value of the "Monitor Changes to file" property value must be your php.ini name(Fully-qualified file name).

13. Configure PHP Extensions in PHP Manager: Under PHP Extensions in PHP Manager, click the "Enable or disable an extension" link. ensure the following extensions are enabled: php_curl.dll; php_gd2.dll; php_intl.dll; php_mbstring.dll; php_openssl.dll; php_soap.dll; php_sqlsrv_54_nts.dll (non thread-safe sql driver for php 5.4); php_xmlrpc.dll; php5.dll (must be used if php_sqlsrv_XX_nts.dll is enabled).

14. Restart IIS to ensure the new configuration takes effect.

15. Configure the config.php file located in your moodle folder (you might need to make a copy of the config-dist.php file and rename it to config.php). Since we are using SQL 2008 R2 Express (Instance name), at port 1434 (remember, we changed our port to 1434 instead of keeping the standard 1433), then we configured the file as follows:

1. DATABASE SETUP

$CFG->dbtype='sqlsrv'

$CFG->dblibrary='native';

$CFG->dbhost='localhost\sqlexpress';

$CFG->dbname='YourMoodleSqlExpressDatabaseName';

$CFG->dbuser='your sql user name created in step 4';

$CFG->dbuser='your sql user password';

$CFG->prefix='mdl_';

$CFG->dboptions=array('dbpersist'=>true, dbsocket=>false, dbport=>1434,);

2. WEB SITE LOCATION

$CFG->wwwroot='http://localhost/moodle'; //(of course your location might be different from mine!)

$CFG->dataroot='D:\My Applications\Some path name with space does not matter\Deeper
Folder does not matter\moodledatagoeshere
'; //(see step 7 above)

16. In IIS, under Default Web Site (or Some Other Web Site as In My Case"), I created a new virtual directory named "Moodle", pointing the contents of my moodle folder. Then I simply turned the virtual directory into an IIS Application. Remember to add index.php in IIS Default Documents. You can move index.php at the top of the documents list to improve performance.

17. I restarted IIS, then started moodle installation by typing in the browser http://localhost/moodle (or http://localhost/moodle/admin), and everything ran like a charm!

Conclusion:

Based on my experience and trials, many ASP.NET sites and many moodle (or php) sites can peacefully coexist and amicably run on the same IIS Server, without conflict. Each moodle site can use its own configuration and even its own version of PHP, on the same IIS.

The sequence of the steps might not be as listed above, but I strove to remember.

Also, I had a feeling (just a feeling) that some minor steps taken above might not have been necessary. But I did not investigate further to confirm it.

Best regards,

Average of ratings: Useful (1)