Archive for October, 2009

Limit number of connections for MySQL user

Posted on October 19, 2009 with No Comments

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

Posted on October 11, 2009 with No Comments

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

Posted on October 9, 2009 with No Comments

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

Posted on October 8, 2009 with No Comments

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

Posted on October 4, 2009 with No Comments

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.

Posted on October 2, 2009 with No Comments

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

Posted on October 1, 2009 with No Comments

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