I'm new in server-side programming. I need lampp and mysql running on my computer. I have installed mysql using tasksel lamp-server, and then install php with apt-get install libapache2-mod-php5 phpmyadmin. And now I have now ideas how to use them. In xampp on Windows I needed only to copy my php files in htdocs directory. How to run php files in Linux and connect them to my MySQL?

3 Answers 3


Maybe you should install the following software first.

sudo apt-get install apache2
sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install php5
sudo apt-get install php5-gd
sudo apt-get install php5-mysql
sudo apt-get install phpmyadmin

and then, you should configure you server. 1, Test apache, open you browser, and enter, if "It Works!" appears, okay. 2, Test php, create a file under /var/www, and name is "index.php", the content is:

<!--?php phpinfo(); ?-->

save and open the url "", the php info should appear, if not, make sure you have proper permission.

3, Configure and test you phpmyadmin. first, run as root,

sudo -i               #run as root
cd /etc/apache2/conf.d

and then create a file named "phpmyadmin-web.conf" or other you like, and the content of the file is:

Alias /phpmyadmin /usr/share/phpmyadmin
<directory usr="" share="" phpmyadmin="">
   AllowOverride All

finally, you also should make a symbol link:

sudo ln -s /var/www/phpmyadmin /usr/share/phpmyadmin

then restart you apache server

sudo /etc/init.d/apache2 restart

Now, you can use your ubuntu as a lamp server.

  • I tried what was said and get Jun 21, 2012 at 6:34
  • Forbidden You don't have permission to access /1.php on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Jun 21, 2012 at 6:35

I'm not sure if I understood your question, but if you just installed the lamp-server, you should have implicit installed apache web server.

AFAK the default directory where you have to put your files into is /var/www/. Just go to http://localhost (or which host you're running on) and check if you see something.

Per default the apache server, and the mysql database should be started automatically after boot. So you don't have to start them as with xampp.

If you're seeing any output on http://localhost it should contain a description, how to change the content. But it should be placed under /var/www/.

The mysql connection is the same as on windows, as you write it in PHP. The mysql database should run on the port 3306.

Also you can check this site where getting PHP running with tasksel is described.


What I have understand is, you want to install xampp server just like you did using Windows.

If this is what you want, download and install xampp from here

This xampp suite contain apache server, mysql server, php, perl, and phpmyadmin.

Installation and configuration instructions of xampp can be found here

This way, you don't need to install mysql or php separately.

If you follow instructions correctly, you will find your htdocs directory at /opt/lampp/htdocs

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .