hi Tim,<br><br>Mate you posted in your setup of Moodle:<br><br>"<span><span></span></span>looks like the package already created /var/www/moodle/data with
appropriate permissions so above was not necessary"<br><br>It's really important for security that the moodledata directory NOT be in the webroot like this, otherwise Moodle's roles & permissions system doesn't control access to any course files & materials - they all become public.<br>
Make sure you're using something like that folder you created earlier in your procedure (/var/moodledata).<br><br>Myles C.<br><br>Myles S Carrick<br>Software Services<br>Sydney Centre for Innovation in Learning (SCIL)<br>
<br><br><div class="gmail_quote">2008/6/25 Tim Moody <<a href="mailto:timmoody@sympatico.ca">timmoody@sympatico.ca</a>>:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff">
<div><font size="2" face="Arial">Hi Tony,</font></div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial">Here are my notes minus a lot of wrong turns.
The part that probably needs Martin's help is PAM SOTP. I made postgresql
trusted because the default ident setting did not work.</font></div>
<div><font size="2" face="Arial"></font> </div>
<div>
<h3 style="margin: 12pt 0in 3pt;"><font face="Arial">Postgre</font></h3>
<p style="margin: 0in 0in 0pt 0.5in;"><span style="font-family: Symbol;">·<span>
</span></span>Find and run PostgreSQL</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>psql (default install) is not postgresql-server; it's just the
client</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>Yum install postgresql-server (8.2.5-1.fc7)</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>service postgresql initdb OK</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>service postgresql start OK</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>psql not work as root</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>su postgres</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>psql connects</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>\l shows postgres, template0, template1 databases</p>
<h3 style="margin: 12pt 0in 3pt;"><font face="Arial">PHP & Libs</font></h3>
<p style="margin: 0in 0in 0pt 0.5in;"><span style="font-family: Symbol;">·<span>
</span></span>yum install php installed: php.i386 0:5.2.4-1.fc7 (surprised it
is not in default install)</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>Make sure php.conf added to /etc/httpd/conf.d</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>/etc/php.ini now found</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>service httpd restart</p>
<p style="margin: 0in 0in 0pt 0.5in;"><span style="font-family: Symbol;">·<span>
</span></span>Test PHP</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>Create php script as follows and execute; it should dump a lot
about your php environment</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span><?php</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>phpinfo();</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>?></p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>In my environment this is in /var/www/html/timtest/ =<span> </span><a href="http://192.168.0.160/timtest/info.php" target="_blank">http://192.168.0.160/timtest/info.php</a></p>
<p style="margin: 0in 0in 0pt 0.5in;"><span style="font-family: Symbol;">·<span>
</span></span>yum install postgresql-python</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>Installed: postgresql-python.i386 0:8.2.5-1.fc7</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>Dependency Installed: mx.i386 0:2.0.6-3 </p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>Don't know what this is for</p>
<p style="margin: 0in 0in 0pt 0.5in;"><span style="font-family: Symbol;">·<span>
</span></span>yum install php-pgsql</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>Installed: php-pgsql.i386 0:5.2.4-1.fc7</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>Service httpd restart</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>Phpinfo now shows pgsql</p>
<p style="margin: 0in 0in 0pt 0.5in;"><span style="font-family: Symbol;">·<span>
</span></span>Test php access to postgre</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>create database timdb;</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>\c timdb</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>create table test (text varchar(10), num decimal);</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>insert into test values ('abc', 123);</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>select * from test;</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>run testpg.php:</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span><?php</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>// Connecting, selecting database</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>$dbconn = pg_connect("host=localhost port = 5432 dbname=timdb
user=postgres password=xxx")</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span><span> </span>or
die('Could not connect: ' . pg_last_error());</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span> </p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>// Performing SQL query</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>$query = 'SELECT * FROM test';</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>$result = pg_query($query) or die('Query failed: ' .
pg_last_error());</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span> </p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>// Printing results in HTML</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>echo "<table>\n";</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span><span> </span>echo
"\t<tr>\n";</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span><span> </span>foreach ($line as
$col_value) {</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span><span> </span>echo
"\t\t<td>$col_value</td>\n";</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span><span> </span>}</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span><span> </span>echo
"\t</tr>\n";</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>}</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>echo "</table>\n";</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span> </p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>// Free resultset</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>pg_free_result($result);</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span> </p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>// Closing connection</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>pg_close($dbconn);</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>?></p>
<p style="margin: 0in 0in 0pt 0.5in;"><span style="font-family: Symbol;">·<span>
</span></span>Figure out why php won't connect to postgresql</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>can not connect and no error (so php not working)</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>log is in /var/lib/pgsql/data/pg_log</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>LOG:<span> </span>could not
connect to Ident server at address "<a href="http://127.0.0.1" target="_blank">127.0.0.1</a>", port 113: Connection refused</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>FATAL:<span> </span>Ident
authentication failed for user "postgres"</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>pg_hba.conf has sameuser which is supposed to mean that the linux
and db user names are the same</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>Steve <ksobrien AT <a href="http://pcisys.net" target="_blank">pcisys.net</a>>04 Jan 2006 0:50:43</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>Even though you add wide-open access permission in the pg_hba.conf
file like this:<span> </span>host all all
<a href="http://127.0.0.1/32" target="_blank">127.0.0.1/32</a><span> </span>trust</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>You will still be unable to connect to the database with a PHP (or
whatever language) program and an Apache httpd server unless you add an "apache"
(or whatever user your httpd daemon is running as) user to PostgreSQL thus:</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>su - postgres</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>createuser apache</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>Of course, be sure you GRANT SELECT ON table TO APACHE; to give
the apache user permission to actually read data.</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>I assigned pw postgres to user postgres</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>Modified /var/lib/pgsql/data/ pg_hba.conf to change host<span> </span>all<span>
</span>all<span>
</span><a href="http://127.0.0.1/32" target="_blank">127.0.0.1/32</a><span>
</span>ident sameuser to </p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>host<span>
</span>all<span>
</span>all<span>
</span><a href="http://127.0.0.1/32" target="_blank">127.0.0.1/32</a><span>
</span>trust</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>run testpg.php works</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>BOTTOM LINE I could only get this to work if I used trusted
mode.<span> </span>I know Martin specified PAM
SOTP, but I don't know how this works</p>
<h3 style="margin: 12pt 0in 3pt;"><font face="Arial">Moodle</font></h3>
<p style="margin: 0in 0in 0pt 0.5in;"><span style="font-family: Symbol;">·<span>
</span></span>Install Moodle</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span><a href="http://docs.moodle.org/en/Step-by-step_Install_Guide_for_Ubuntu#Install_Postgresql_.28skip_MySQL.29" target="_blank">http://docs.moodle.org/en/Step-by-step_Install_Guide_for_Ubuntu#Install_Postgresql_.28skip_MySQL.29</a></p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span><a href="http://docs.moodle.org/en/Installing_Moodle#Creating_an_empty_database" target="_blank">http://docs.moodle.org/en/Installing_Moodle#Creating_an_empty_database</a></p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span># su - postgres</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span><span> </span>> psql -c
"create user moodleuser createdb;" template1 worked</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span><span> </span>> psql -c
"create database moodle with encoding 'unicode';" -U moodleuser template1
failed on authentication (Ident authentication failed for user "moodleuser")</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>createdb -E utf8 -O moodleuser moodle worked</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span><span> </span>> psql -c
"alter user moodleuser nocreatedb;" template1 (alter user moodleuser
nocreatedb;) worked</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span><span> </span>> psql -c
"alter user moodleuser with encrypted password 'moodle';" template1 (alter user
moodleuser with encrypted password 'moodle';) worked</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span><span> </span>> su -
root</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span><span> </span>#
/etc/init.d/postgresql reload</p>
<p style="margin: 0in 0in 0pt 0.5in;"><span style="font-family: Symbol;">·<span>
</span></span>Finish moodle install</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>Modified /etc/php.ini according to <a href="http://docs.moodle.org/en/Installing_Moodle" target="_blank">http://docs.moodle.org/en/Installing_Moodle</a>
(docs seem to have 0 and 1 where file has off and on; I mostly followed the
docs, which worked.)</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>Created /var/moodledata (NOT NECESSARY)</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>chown -R nobody:apache moodledata</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>chmod -R 0770 moodledata</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>looks like the package already created /var/www/moodle/data with
appropriate permissions so above was not necessary</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>/var/www/moodle/web/config.php has mysql as db I changed to
postgres</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span><a href="http://192.168.0.160/moodle/web/install.php" target="_blank"><span> </span>http://192.168.0.160/moodle/</a> - Error:
Database connection failed</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>modified host, dbname, user, and password in config.php</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>now does redirect to <a href="http://localhost/moodle/admin/index.php" target="_blank">http://localhost/moodle/admin/index.php</a>
)because wwwroot<span> </span>=
'<a href="http://localhost/moodle%27June" target="_blank">http://localhost/moodle'June</a> 20, 2008</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>now <a href="http://192.168.0.160/moodle/web/install.php" target="_blank"><span> </span>http://192.168.0.160/moodle/</a>
redirects to <a href="http://192.168.0.160/moodle/admin/index.php" target="_blank">http://192.168.0.160/moodle/admin/index.php</a>
- gives error DB Type: postgres not supported by XMLDDB</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>click continue repeats error</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>N.B> changed dbtype to 'postgres7' (!?) now gets past error
(didn't read fine print)</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>Database was successfully upgraded</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>(should have taken unattended installation)</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>workshop tables have been set up correctly</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>truefalse tables have been set up correctly</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>Database was successfully upgraded (x2)</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>Various tables</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>Create admin (admin/moodle)</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>Seems to be installed and running.</p>
<p style="margin: 0in 0in 0pt 0.5in;"><span style="font-family: Symbol;">·<span>
</span></span>Set up cron</p>
<p style="margin: 0in 0in 0pt 0.75in;"><span>o<span>
</span></span>This still needs to be done</p>
<p style="margin: 0in 0in 0pt 0.75in;"> </p></div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial">Tim</font></div>
<div><font size="2" face="Arial"></font> </div>
<blockquote style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">----- Original Message ----- </div>
<div style="background: rgb(228, 228, 228) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">
<b>From:</b>
<a title="tpearson@us.ibm.com" href="mailto:tpearson@us.ibm.com" target="_blank">Tony
Pearson</a> </div>
<div style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>To:</b> <a title="timmoody@sympatico.ca" href="mailto:timmoody@sympatico.ca" target="_blank">Tim Moody</a> </div>
<div style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Sent:</b> Tuesday, June 24, 2008 1:08
PM</div>
<div style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Subject:</b> PostgreSQL + Moodle</div>
<div><br></div><br><tt><font size="2">Tim,</font></tt> <br><tt><font size="2">Please share me your procedures. If you have written down any
notes, or have any "gotcha's" I should try to avoid, please provide me.
I will be doing this week to send the computer off this
Monday.</font></tt> <br><br><br><tt><font size="2">From: "Tim Moody" <<a href="mailto:timmoody@sympatico.ca" target="_blank">timmoody@sympatico.ca</a>><br>Subject:
Re: [Server-devel] XS SW<br>To: <<a href="mailto:server-devel@lists.laptop.org" target="_blank">server-devel@lists.laptop.org</a>><br>Message-ID:
<000701c8d58e$4f981b60$0b00a8c0@saturn><br>Content-Type: text/plain;
format=flowed; charset="iso-8859-1";<br>
reply-type=original<br><br>Got throught the moodle +
postgre install. I'll now play with setting up <br>some courses and
users.<br><br>I cheated on the authentication as I don't know how PAM SOTP
works; I just <br>set the authentication to trusted.<br></font></tt><font size="2" face="sans-serif"><br></font>
<table>
<tbody>
<tr>
<td bgcolor="#006699">
</td><td bgcolor="#006699">
</td></tr><tr>
<td><img src="cid:000d01c8d63d$b81f3060$0b00a8c0@saturn">
</td><td><font size="1" color="#0060a0" face="Microsoft Sans Serif"><b>Tony
Pearson</b></font><font size="1" face="Microsoft Sans Serif"><br>Senior
Storage Consultant, IBM System Storage<br>Telephone: +1 520-799-4309 |
tie 321-4309 | Cell: +1 520 990-8669<br>email:
<a href="mailto:tpearson@us.ibm.com" target="_blank">tpearson@us.ibm.com</a> | GSA:
<a href="http://tucgsa.ibm.com/%7Etpearson" target="_blank">http://tucgsa.ibm.com/~tpearson</a><br>Blog: </font><a href="http://www.ibm.com/developerworks/blogs/page/InsideSystemStorage" target="_blank"><font size="1" color="blue" face="Microsoft Sans Serif"><u>http://www.ibm.com/developerworks/blogs/page/InsideSystemStorage</u></font></a><font size="1" face="Microsoft Sans Serif"><br>
AKA: 990tony Paravane, eightbar
specialist </font>
</td></tr><tr>
<td bgcolor="#006699">
</td><td bgcolor="#006699"></td></tr></tbody></table><br></blockquote></div>
<br>_______________________________________________<br>
Server-devel mailing list<br>
<a href="mailto:Server-devel@lists.laptop.org">Server-devel@lists.laptop.org</a><br>
<a href="http://lists.laptop.org/listinfo/server-devel" target="_blank">http://lists.laptop.org/listinfo/server-devel</a><br>
<br></blockquote></div><br>