Making MeidaWiki urls seo friendly

Open LocalSettings.php

Find

$wgArticlePath      = "$wgScript/$1";

Replace with

$wgArticlePath = "/$1";

Now create .htaccess file with following content

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?title=$1 [L,QSA]

Thats all. Now your media wiki installation have seo friendly url.

Tags: , ,

Category: Web

Limit number of connections for MySQL user

To limit number of mysql connection per user, edit /etc/my.cnf

vi /etc/my.cnf

In [mysqld] section, set value for max_user_connections.

[mysqld]
max_user_connections=40

This will limit mysql connections at a time for any user to 40.

PHP Tutorial Day 1

To run PHP programs you need a web server installed on your computer.

For windows, it is better install Zend Server Community edition.

Once you installed, you can start creating php programs. You need to upload Programs to DocumentRoot of the web server.

C:/Program Files/Zend/Apache2/htdocs

We will start with very basic phpinfo script.

In DocumentRoot, create a file with extenson .php, example phpinfo.php

Put following content in the file

<?php
 
phpinfo();

Now access the file with url

http://localhost/phpinfo.php

You will get php info page, it look some thing like

http://hostonnet.com/phpinfo.php

For creating php files, i recommend using notepad++ (for beginners) or ZendStudio for advanced users.

You ca download notepad++ from

http://notepad-plus.sourceforge.net/uk/site.htm

Category: PHP Tutorial

Can’t connect to local MySQL server through socket

While running symfony jobeet tutorial, i got following error

fwh@pc11-desktop:~/web/jobeet$ php symfony doctrine:build-sql
>> doctrine  generating sql for models
 
 
  While exporting model class 'JobeetAffiliate' to SQL: PDO Connection Error: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)  
 
 
fwh@pc11-desktop:~/web/jobeet$

This is fixed by editing config/databases.yaml

Find line

dsn: 'mysql:host=localhost;dbname=jobeet'

Replace with

dsn: 'mysql:host=localhost;dbname=jobeet;unix_socket=/var/run/mysqld/mysqld.sock'

Changing computer name in ubuntu

To change computer name in ubuntu, run

sudo echo "computer-new-name" > /etc/hostname

Now you need to reboot to get the computer name changed.

Enable lighttpd status and config pages

To enable lighttpd status and config pages, you need to edit lighttpd.conf

vi /etc/lighttpd/lighttpd.conf

Find

#                                "mod_status",

Replace with

                                "mod_status",

Find

#### status module
#status.status-url          = "/server-status"
#status.config-url          = "/server-config"

Replace with

#### status module
status.status-url          = "/server-status"
status.config-url          = "/server-config"

Restart lighttpd

/etc/init.d/lighttpd restart

Now you can visit urls like

http://your-ip/server-config

and

http://your-ip/server-status

To view lighttpd status and configuration.

lighttpd_config

lighttpd_status

Tags:

Category: Lighttpd

Force saving passwords on firefox.

For some sites, when you login, forefox won’t prompt you to save passwords. This is because in the html form, input tag have autocomplete=”off”

I used to login to softlayer private network everyday. To get password saved by firefox, i go to the login page, then with firebug edited the page, removed

autocomplete="off"

Now on login, firefox prompted to save password. If password is saved, frefox won’t respect autocomplete.

Tags:

Category: Web

Installing Java on CentOs

Java is available in CentOS 5.

root@server70 [~]# yum list|grep openjdk
java-1.6.0-openjdk.x86_64                  1:1.6.0.0-1.2.b09.el5       installed
java-1.6.0-openjdk-demo.x86_64             1:1.6.0.0-1.2.b09.el5       updates
java-1.6.0-openjdk-devel.x86_64            1:1.6.0.0-1.2.b09.el5       updates
java-1.6.0-openjdk-javadoc.x86_64          1:1.6.0.0-1.2.b09.el5       updates
java-1.6.0-openjdk-src.x86_64              1:1.6.0.0-1.2.b09.el5       updates
root@server70 [~]#

To install java, run

yum install java-1.6.0-openjdk

Java will be installed on

/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/bin/java
root@server70 [/var/log]# rpm -q --filesbypkg java-1.6.0-openjdk  | grep "/bin/java"
java-1.6.0-openjdk        /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/bin/java
root@server70 [/var/log]# which java
/usr/bin/java
root@server70 [/var/log]# cd /usr/bin
root@server70 [/usr/bin]# ls -la |grep java
lrwxrwxrwx  1 root root          22 Aug 25 02:56 java -> /etc/alternatives/java*
root@server70 [/usr/bin]# ls -la /etc/alternatives/java
lrwxrwxrwx 1 root root 46 Aug 25 02:56 /etc/alternatives/java -> /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java*
root@server70 [/usr/bin]#

Tags: , , ,

Category: Linux

How to extract RAR files in Ubuntu

To extract rar file, you need to install unrar with

sudo apt-get install unrar

To extract a rar file, go to command line, run

unrar x fileName.rar

For other command line options of unrar, run

man unrar

Tags: , , ,

Category: ubuntu

Zend Framework error MySQL server through socket /tmp/mysql.sock

On a new apache/mysql installation, i got following error when connecting to mysql database in zend framework.

An error occurred
Application error
Exception information:
 
Message: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

This is because no socket /tmp/mysql.sock exists. Can be fixed by symlink to actual socket.

To find mysql socket, in mysql command prompt run

mysql> SHOW VARIABLES LIKE '%socket%';
+---------------+-----------------------------+
| Variable_name | Value                       |
+---------------+-----------------------------+
| socket        | /var/run/mysqld/mysqld.sock | 
+---------------+-----------------------------+
1 row IN SET (0.00 sec)
 
mysql>

Now we got actual socket location. Now create a symlink with command

sudo ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock

This will make it work, but a reboot will lose the changes, so permanent solution is to edit /etc/mysql/my.cnf

vi /etc/mysql/my.cnf

Find

socket          = /var/run/mysqld/mysqld.sock

Replace with (all occurrence, 3 times)

socket          = /tmp/mysql.sock