Tuesday, November 23, 2010

Install Setup PHP cURL

Assume you have already setup LAMP. To install or setup cURL on your Linux machine like Ubuntu, run the following line of shell command in your terminal:

sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

Now you have PHP cURL installed, the next thing you need to do is to restart apache2, run the following command in your terminal:

sudo /etc/init.d/apache2 restart

source

Monday, November 8, 2010

Wednesday, November 3, 2010

How to create virtual host on linux

sudo gedit /etc/apache2/apache2.conf

A search for the word virtual bring us to the following line:
# Include the virtual host configurations:
Include sites-enabled/

Change it like this:
# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/[^.#]*

This mean that when starting apache, it will look for files in /etc/apache2/sites-enabled/.
Lets go there and see what is in.

$cd /etc/apache2/sites-enabled/
$ls -l
total 1
lrwxrwxrwx 1 root root 36 2005-12-27 01:42 000-default -> /etc/apache2/sites-available/default

Well, this only links to the file in directory /etc/apache2/sites-available/ . You might wonder what is the point in doing such. Well, this simply allows you, mainly when you are using your box as a web server, to:

1. Have a simple main configuration file

2. Do be able to edit or create a new host by creating/editing a file from /etc/apache2/sites-available/

3. In case your web server doesn't restart because of misconfiguration, you can simply remove the link from the file in /etc/apache2/sites-enabled/ pointing to the malformed file in /etc/apache2/sites-available/

Now let say you want to be able to map the domain name dev.example.com to you local machine, using the code file in /home/myuser/public_html/example.com/.
While in /etc/apache2/sites-available, create a new file (let say example.com.conf)

$sudo gedit example.com.conf

NameVirtualHost 127.0.0.1:80

ServerName dev.example.com
ServerAlias www.dev.example.com
ServerAdmin emaildev.example.com
DocumentRoot /var/www/dev.example.com/html


Order Deny,Allow
Allow from all
# Don't show indexes for directories
Options -Indexes




Note:People who don't want to bother knowing how the site enabling system works might just jump to the end of the article to find debian built-in command syntax. If you want to know how it works, or do not use a debian based distro, carry on.

Now, we specified a new host to apache but it is not yet linked to the repertory where apache actually look for virtual hosts. Let go to:

$cd /etc/apache2/sites-enabled/

and create a link to the file we just created:

$sudo ln -s /etc/apache2/sites-available/example.com.conf example.com.conf

Now apache is almost ready to restart, but before doing so, we must inform our linux system that dev.example.com and www.dev.example.com are not to be looked for on the net, but on the local machine instead.
To do so, simply edit /etc/hosts and add the new host names at the end of the line beginning by 127.0.0.1, which is localhost.
In the end, your file should look like:

127.0.0.1 localhost.localdomain localhost dev.example.com www.dev.example.com

And now we are done, simply reload apache:

sudo /etc/init.d/apache2 reload
or
sudo /etc/init.d/apache2 restart

Open your web browser and enter the following address dev.example.com. Magic, it runs the same as when you were using http://localhost/~myuser/example.com but it is far more usefull when devellopping a web service and want to be able to develop applications on your machine just like it is where the real web site.

Edit: As you can see from the comments, many people pointed out that you can use a debian specific command (so if you are not using a debian based system, don't expect to find that command :) ).
to enable a new virtual host simply type:

sudo a2ensite mysiteavailable-site

to disable a virtual host:

sudo a2dissite mysiteavailable-site

where mysiteavailable-site is the name of the virtual hos you want to enable/disable, so in out example: example.com.conf

More info : read here

http://www.debuntu.org/2006/02/22/7-virtual-hosting-using-apache-2

Tuesday, November 2, 2010

Working easy on Linux with Webmin

Official Webmin website
http://www.webmin.com/

If you are using the DEB version of webmin, first download the file and then run the command :

dpkg --install webmin_1.530_all.deb

The install will be done automatically to /usr/share/webmin, the administration username set to root and the password to your current root password. You should now be able to login to Webmin at the URL http://localhost:10000/. Or if accessing it remotely, replace localhost with your system's IP address.

If Debian complains about missing dependencies, you can install them with the command :

apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions

If you are installing on Ubuntu and the apt-get command reports that some of the packages cannot be found, edit /etc/apt/sources.list and make sure the lines ending with universe are not commented out.

Some Debian-based distributions (Ubuntu in particular) don't allow logins by the root user by default. However, the user created at system installation time can use sudo to switch to root. Webmin will allow any user who has this sudo capability to login with full root privileges.

If you want to connect from a remote server and your system has a firewall installed, see this page for instructions on how to open up port 10000.

How to change webmin default port

# Stop webmin with the command /etc/webmin/stop
# Edit the line port in /etc/webmin/miniserv.conf
# Start webmin with the command /etc/webmin/start

How to kill a process on Linux

Here's a couple of commands that may come in useful:
sudo fuser -n tcp 10001
This should output something like:
10000/tcp: 5543
(List which process is using tcp port 10000)
From here you can just do
sudo kill 5543
netstat -l | less
(display listening server sockets)
(hit the "space key" to move down a page and hit the "q" key to quit)

How do I install .deb packages?

Type the following command:
$ sudo dpkg -i package.deb

Reset GNOME Keyring Password on Ubuntu

Method 1:

It is possible to clobber your keyring passphrase and settings from the Terminal. Open a terminal (Applications > Accessories > Terminal), and run the command:

rm ~/.gnome2/keyrings/login.keyring

On older systems you may need to try:

rm ~/.gnome2/keyrings/default.keyring

Method 2:

The second method bypasses the Terminal and uses the graphical interface strictly. To delete your current keyring, follow the steps below:

1. Navigate to Applications > Accessories > Passwords and Encryption Keys
2. Select the far-right tab “Passwords”
3. Select your keyring
4. Right-click and attempt “Change Password” or, if that doesn’t work, select “Delete”