Sponsored Link
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.
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.
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 ‘ ’
@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:-)
‘\.’ 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
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?
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.
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.
Yeah, you caught me. That must be it. 🙂
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.
I think in Apache 2 you don’t need the second command, it seems to work without that substitution.
Hey, nice easy work. Thanks heaps.
It might not have worked for @Smoovb if he did a copy/paste – ie if your browser converted the regular single quote (‘) to an angled one, then the shell won’t like it.
Got this error for some reason:
sudo /etc/init.d/apache2 restart
* Restarting web server apache2 apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
Can someone explain what went wrong?
* Restarting web server apache2 apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
@Hemanth
open /etc/apache2/apache2.conf
sudo gedit /etc/apache2/apache2.conf
find the following line
ServerName
change
ServerName
save and exit the file
restart apache webserver
sudo /etc/init.d/apache2 restart
I did that but if i try to login to mysql , i am getting this
#2002 – The server is not responding (or the local MySQL server’s socket is not correctly configured)
@Hemanth
This is mysql server error
First you need to check mysql server is running or not
try to start using the following command
sudo /etc/init.d/mysql start
Check the log messages
cat /var/log/messages | grep mysql
guys, i am super nobie in ubuntu. i have no idea why it comes:
root@aminul-laptop:/home/aminul# sudo apt-get install apache2 mysql-server php5 libapache2-mod-php5 php5-xsl php5-gd php-pear libapache2-mod-auth-mysql php5-mysql
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Couldn’t find package apache2
root@aminul-laptop:/home/aminul#
please note that, i am not confident my ubuntu is installed properly. i don’t have much knowledge of ubuntu.
how to resolve the issue and enjoy lamp ?
For anyone who’s interested, this also works on the latest karmic. Note the second command should have regular quotes, as opposed to the backquotes listed
@Aminul
sudo gedit /etc/apt/sources.list
Make sure you have:
deb http://us.archive.ubuntu.com/ubuntu/ OS main restricted
deb http://us.archive.ubuntu.com/ubuntu/ OS universe
deb http://us.archive.ubuntu.com/ubuntu/ OS multiverse
#Sources – Optional
deb-src http://us.archive.ubuntu.com/ubuntu/ OS main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ OS universe
deb-src http://us.archive.ubuntu.com/ubuntu/ OS multiverse
Substitute OS with your version.
Eg: hardy, karmic, intrepid
I’ve tried many ways to get a working LAMP stack on my local Ubuntu box for a while. However, I don’t want Apache and MySQL running all the time. My home Ubuntu box isn’t that powerful. I found that XAMPP from ApacheFriends.org is a very easy way to have a local LAMP development environment.
http://www.apachefriends.org/en/xampp-linux.html
You can install it in your home directory so you don’t have to worry about global permissions. I don’t work for ApacheFriends.org, but am just an extremely satisified user. It works really well on Linux or Windows.