Install the LAMP stack with 3 commands!
Posted by James House on August 8th, 2007
Email This Post
Now, let’s get to it.
Open a terminal window and run the following commands:
sudo apt-get install apache2 mysql-server php5 libapache2-mod-php5 php5-xsl php5-gd php-pear libapache2-mod-auth-mysql php5-mysql
sudo sed -i ’s/; extension=mysql.so/extension=mysql\.so/g’ /etc/php5/apache2/php.ini
#That’s a series of 3 spaces after ’s/;
sudo /etc/init.d/apache2 restart
Reboot and you’re done!
What do those commands do? Well, the first one installs all of the packages needed. The second one uses sed to remove the semicolon (which denotes a comment) from the php config file, thus allowing php to work with mysql. The third one simply restarts apache.
In the above commands, there should only be 3 lines. Your display settings may cause the commands to span more than 3 lines. If so, just copy and paste line by line. Each command begins with sudo.
If you want to be notified the next time we write something please subscribe to our RSS feed.Thanks for Visiting!


August 9th, 2007 at 4:44 pm
James:
Why don’t the three (3) spaces show in the line on this page?
sudo sed -i ’s/; extension=mysql.so/extension=mysql\.so/g’ /etc/php5/apache2/php.ini
using my cursor, I can move only ONE space between -i ’s/; extension . . .
Please clariy.
August 11th, 2007 at 7:56 am
Non-breaking Space
The most common character entity in HTML is the non-breaking space.
Normally HTML will truncate spaces in your text. If you write 10 spaces in your text HTML will remove 9 of them. To add spaces to your text, use the character entity.
the text below will give you an example (paste it in a test.html file and try it out):
these are 4 spaces by using ‘ ’
August 11th, 2007 at 7:58 am
@Mark,
Non-breaking Space
The most common character entity in HTML is the non-breaking space.
Normally HTML will truncate spaces in your text. If you write 10 spaces in your text HTML will remove 9 of them. To add spaces to your text, use the character entity.
the text below will give you an example (paste it in a test.html file and try it out):
these are 4 spaces by using ‘ ’
Z:-)
August 12th, 2007 at 2:20 pm
‘\.’ should be used into regular expresion on sed.
Better:
sudo sed -i ’s/; extension=mysql\.so/extension=mysql.so/g’ /etc/php5/apache2/php.ini
August 14th, 2007 at 12:46 am
smoovb@s3rv3r:~$ sudo sed -i ’s/; extension=mysql\.so/extension=mysql.so/g’ /etc/php5/apache2/php.ini
sed: -e expression #1, char 1: unknown command: `
bash: /etc/php5/apache2/php.ini: Permission denied
I get this error when I try to use the second command. In addition, I tried the command with 3 spaces after “’s/;” and receive the same results.
Any suggestions?
August 14th, 2007 at 2:30 am
I don’t know why the sed command isn’t working for you.
Try this instead… it’s just a few more steps.
sudo nano /etc/php5/apache2/php.ini
Type CTRL-W to search. Search for extension=mysql.so
Remove the leading semicolon.
CTRL-X to exit, save the changes.
Then, sudo /etc/init.d/apache2 restart
to restart Apache.
August 14th, 2007 at 8:44 pm
Why does the user have to reboot? If the services are up, there’s no point in doing this…you must be too used to Windows.
August 14th, 2007 at 8:50 pm
Yeah, you caught me. That must be it.
August 24th, 2007 at 9:01 am
You can use tasksel for that. If you’ve ever done an installation from the server cd or dvd, then you’ll have noticed it. It’s the part that lets for choose LAMP, DNS, etc. Install and run it, and you’ll get some choices, like LAMP, DNS, Edubuntu server, etc.
February 17th, 2008 at 8:57 pm
I think in Apache 2 you don’t need the second command, it seems to work without that substitution.