Thursday, December 20, 2012

Apache subfolder setup

This tutorial is explain how to setup a subfolder but the location is not inside the html folder, instead, it can be located parallel to the html

Alias /subdirectory /path/to/real/subdirectory

Wednesday, December 19, 2012

How to setup cron for ELIS RLIP

This tutorial is to set cron to run every 5 minutes for the ELIS RLIP block

#crontab -e

then enter line below
5 * * * *  nice php /mnt/data/www/pathtomoodle/blocks/rlip/rlip_cron.php >/dev/null 2>&1

Tuesday, November 13, 2012

How to remove IP manually from cpanel

1 Bring down the ip first
for example ifconfig eth0:cp3 xxx.xx.xx.xx netmask down

2. Edit /etc/ips and remove the line with the corresponding ip

3. Run this command /etc/init.d/ipaliases restart

Thursday, October 11, 2012

Some example for httpd.conf

  DocumentRoot /path/to/domainname
  ServerName domainname
  redirect permanent / https://domainname/
 Alias /sandbox /path/to/domainname/sandbox

The above is just an example on how to setup the virtualhost on apache
The Alias is like a subfolder inside the public_html but you can put the folder in parallel to the public_html.

Thursday, September 6, 2012

Wednesday, August 22, 2012

Recover mysql root password

You can recover MySQL database server password with following five easy steps.

Step # 1: Stop the MySQL server process.

Step # 2: Start the MySQL (mysqld) server/daemon process with the --skip-grant-tables option so that it will not prompt for password.

mysqld_safe --skip-grant-tables

Step # 3: Connect to mysql server as the root user.

Step # 4: Setup new mysql root account password i.e. reset mysql password.

mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit

Step # 5: Exit and restart the MySQL server.

Thursday, August 2, 2012

Mysql grant

  mysql -B -N $@ -e "SELECT DISTINCT CONCAT(
    'SHOW GRANTS FOR ''', user, '''@''', host, ''';'
    ) AS query FROM mysql.user" | \
  mysql $@ | \
  sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}'

Put the above command to /root/.bashrc and when typing mygrants command, it will show the mysql privilege

Tuesday, July 24, 2012

htaccess redirect to www

To redirect a domain from a non www to a www domain, just add .htaccess

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

to reverse redirect a domain from a www to a non www

RewriteEngine On
RewriteCond %{HTTP_HOST} !^my-domain\.com$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

Another way using the conf

redirect permanent / https://insert-url-of-your-site/

Example of using multiple url to point to the same site

  DocumentRoot /opt/rlcache/www/moodle_prod
  Alias /sandbox /opt/rlcache/www/moodle_sand

  Redirect permanent /

Wednesday, July 18, 2012

Add column to existing table in mysql

ALTER TABLE contacts ADD email VARCHAR(60);

This first statement will add the email column to the end of the table. To insert the new column after a specific column, such as name, use this statement:

ALTER TABLE contacts ADD email VARCHAR(60) AFTER name;

If you want the new column to be first, use this statement:


To remove a column
ALTER TABLE table_name
DROP COLUMN column_name

Sunday, June 10, 2012

Create zip file in linux

zip -r foldertocompres/

Quick hint to use vi

vi Cheatsheet 
dd to delete line
/string Search forward for string
?string Search back for string
:s/pattern/string/flags Replace pattern with string according to flags.
g Flag - Replace all occurences of pattern
c Flag - Confirm replaces.
& Repeat last :s command

A to go to end of line and Insert mode
$ to go to end of line

I to go to first of line and Insert mode
0 to go to first of line

1G Move to the first line of the file
G Move to the last line of the file
nG Move to nth line of the file
:n Move to nth line of the file

Thursday, June 7, 2012

Redirect to https using .htaccess

Create .htaccess file to redirect site to https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Monday, June 4, 2012

Moodle 2 restore questionnaire

Backup from moodle 1.9 to moodle 2 will not include the questionnaire. However, now there is a fix already. Here is the information Simply download lib.php and place it to mod/questionnaire/backup/moodle1/lib.php

Wednesday, May 2, 2012

Moodle lang set default value in database

To set default value for user language in the table mdl_user, simply run this alter table mdl_user alter lang set default 'en_us';

Thursday, April 5, 2012

Upgrade to moodle 2 issue and fix

If upgrading from 1.9 to moodle 2 and you're running into issue like

!! Data too long for column 'questiontext' at row 1

Fix is

Running ALTER TABLE mdl_question MODIFY questiontext MEDIUMTEXT;

Sunday, April 1, 2012

Moodle 2 moodledata directory

Here is the info for moodledata directory in moodle 2

For example

Then connect to the Moodle 2 database and run a query

SELECT * FROM mdl_files WHERE contenthash = 'd2901f1f5f46134bd8cd767448c1da7daf9a41a2';

Thursday, March 29, 2012

Moodle Timezone add UTC+14

Edit the moodle/lib/moodlelib.php and do a search for get_list_of_timezones() and change 13 to 14

USB Mouse not working in XP SP3

If you plug in USB Mouse and getting hid class error complaining about some windows 95 incompatible INF, here is the fix

1. Open %windir%\inf folder (Must show hidden files)
2. Backup and delete these files:

- INFCache.1
- msmouse.pnf
- input.pnf

3. Open a command line and run
Net stop Cryptsvc
4. Backup and delete this folder “%windir%\system32\catroot2”
5. Reboot the computer to make sure the information was clean up.
6. Insert USB mouse to another port which hasn’t been used before.

Thursday, February 9, 2012

How to find orphaned modules in moodle

SELECT, AS modname FROM mdl_course_modules cm JOIN mdl_modules m ON = cm.module WHERE cm.course = 1398 AND cm.section = 1513;

then list will show up.
delete from mdl_course_modules where id = 1523; (replace the id that associate with book and chat)

Sunday, February 5, 2012

Error during installing Office 2007 about protected file

Extract file I386\FP40EXT.CAB on the windows xp CD and then look for fp4ault.dll

Copy this file to c:\program files\common files\microsoft
shared\web server extensions\40\bin

The install should work.

Thursday, February 2, 2012

easyapache with /

Custom Configure Flags

Custom configure flags (also known as “raw opts”) are lines of data that advanced users can add to a specific file on the server in order to customize the configuration of Apache or PHP builds.

To add custom configure flags, you must know the version of Apache and PHP to which you need to add the flag. EasyApache allows you to specify any configure option supported by Apache and/or PHP. Simply place the option in the appropriate file; the files are as follows:

For Apache 1.3.x — /var/cpanel/easy/apache/rawopts/Apache1
For Apache 2.0.x — /var/cpanel/easy/apache/rawopts/Apache2
For Apache 2.2.x — /var/cpanel/easy/apache/rawopts/Apache2_2
For all PHP 4.x versions — /var/cpanel/easy/apache/rawopts/all_php4
For all PHP 5.x versions — /var/cpanel/easy/apache/rawopts/all_php5
For Mod_suPHP — /var/cpanel/easy/apache/rawopts/all_suphp
For a specific PHP Version — /var/cpanel/easy/apache/rawopts/PHP-X.X.X

To add a custom flag:

Create the file that corresponds to the version of Apache or PHP for which you would like to add a custom configure flag.
In the file, enter the flag you wish to add.
The file will be parsed, and the options properly formatted before EasyApache adds them to the data structure.
See the example below for more information about formatting your custom flags.
Save the changes you have made to the file.

Remember: Enter only one item per line.




This will result in the following being added to the configuration file:

--with-flag --path-to-flag=/usr/bin/flag --my-option

*************************** For mssql ***************************************


1-. Download freetds ->
2-. tar -zxvf freetds-stable-tgz
3-. cd freetds-*
4-. ./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib --enable-dbmfix --with-gnu-ld

Note: tdsver=8.0 if you use SQL 2000, tdsver=7.0 if you use SQL 7.0

5-. make
6-. make install
7-. /usr/local/freetds/bin/tsql -S -U

Note: For default User SQL is sa and the it have not password
For example: /usr/local/freetds/bin/tsql -S -U sa

8-. Add the next text in freetds.conf ( /usr/local/freetds/etc )
host =
port = 1433
tds version = 8.0

Note: If you use SQL 2000 then tds version = 8.0
if you use SQL 7.0 then tds version = 7.0

9-. Add the following line in the file /etc/ and run ldconfig -v:

10- Recompile PHP with --with-mssql=/usr/local/freetds flag.

Wednesday, February 1, 2012

Apply patch in linux

Apply a Patch in Linux using "patch"

use something like: patch -p1 < patchfile.diff

Tuesday, January 17, 2012

Tuesday, January 10, 2012

How to compress folder/file and split into certain sizes

To compress folder/file and then split it automatically with certain sizes, the command is
tar -cvpj 'directory/name'/ | split -d -b 2000m - /name/of/archive.tar.bz2.

To combine them again, just use
cat *.bz2* | (cd path-to-destination; tar jxv)

Thursday, January 5, 2012

Linux moving or deleting large files getting Argument List Too Long

When you try to move or delete a lot of files in linux cli and getting Argument List Too Long, you can try to filter it by
find . -type f -name "*.xml" | xargs -i mv {}

Wednesday, January 4, 2012

Mysql Export and Import from select statement

To export into a csv file from a select statement in mysql, the command is

FROM table2;

To read the comma-delimited file back in, the correct statement would be: