Saturday, February 21, 2009

LAMP and Java installation in Ubuntu

I installed some more application on my Ubuntu server today. Really makes me appreciate how easy it is to install things using apt-get. First I installed JRE with "sudo apt-get install sun-java6-jre". Next was JDK using "sudo apt-get install sun-java6-jdk". I installed these because at some point I may want to work with Java on that machine, but then again, maybe not. I have options though.

Next I wanted to install my LAMP stack. Apache gets installed by "sudo apt-get install apache2". A quick test to make sure it works by going to "http://192.168.x.x/" and it was onto the next item. PHP is installed by "sudo apt-get install php5 libapache2-mod-php5". Before being able to test this Apache needs to be restarted with "sudo /etc/init.d/apache2 restart". To test it I sent over the PHP files I've been playing around with on my laptop using scp to the Apache server's root directory, located at "/var/www/". This was a two step process since my user account on the Ubuntu server doesn't have write permissions to the "/var/www" directory. So I first sent my folder of php files over using "scp ~/php/*.* myusername@ubuntu:~/Documents/php". Then I moved them using "sudo mv ~/Documents/php /var/www". Then I created a symbolic link to this directory from my home directory for easy access. PHP does, indeed, work on my Ubuntu machine now.

Next I installed MySQL using "sudo apt-get install mysql-server". Mid-install, I was prompted to enter a password for the MySQL root user. Next was a tricky part. I needed to edit the php.ini file so that MySQL will play with PHP5. Doing all of this over SSH, this meant command line text editing, something new to me. So I learned some thing about Vim today.

In Vim, rather than using the arrow keys to move around, letter keys can be used instead: h (left), j (down), k (up), and l (right). There are several ways to enter insert mode, a common way is using the i key. This inserts text to the left of the cursor. I used o, which will start a new line and then insert text to the left of cursor. The esc key will exit insert mode. Vim is case sensitive when it comes to keyboard shortcuts, and so makes use the shift key. Typing shift+; will make a colon appear at the bottom of the window with the cursor next to it. From there, a number a commands can be issued by typing specific characters and then hitting enter. Saving is accomplished by :w and :q will quit. A nice long list of Vim commands is available here.

Back to what I was doing. I typed "sudo vi /etc/php5/apache2/php.ini" to open the php.ini file in Vim. The line to add reads "". I also inserted a comment above it to explain its purpose. Comments in this file are created by starting the line with "#". Apache needs to be restarted for the change to take effect: "sudo /etc/init.d/apache2 restart".

I'll play more with it later.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.