Ubuntu LAMP (Linux, Apache, MySQL, PHP) install tutorial
Publish date 03/12/2008
This is a tutorial to install LAMP: Linux, Apache, MySQL and PHP on Ubuntu.
This is written for Debian using apt-get as package-manager. But can be followed on any system that uses apt-get as a package manager. Like Ubuntu.
Before you install make sure you are logged in as root, and also that the packages are up to date.
su root
apt-get updateApache and PHP
Apache and PHP5 can be installed with the following command:
Apache configuration file is located at: /etc/apache2/apache2.conf and your web folder is /var/www.apt-get install apache2 php5 libapache2-mod-php5
A simple test to see if everything works.
Create a php-file in the www-dir and test it.Then redirect you browser to the server. ip-address/test.phpecho "<?php phpinfo(); ?>" > /var/www/test.php
You should see a list of php-setting.
If it doesn't you try restarting the apache server:/etc/init.d/apache2 restart
MySQL
To install MySQL enter the following command as root.
apt-get install mysql-server mysql-client php5-mysql
It will ask to set the mysql root-password.
This is not the same as the root user of the system.
You can also set it later with:You might want to create extra users for different task or databases. This can be done with GRANT in MySQL:mysqladmin -u root -h localhost password "newpassword"
(You replace "database" withe the name of the database, "username" with the name of the user and "password" with the secret password) This allows the user to connect from localhost only! Which is in most cases enough, and the most secure.
mysql -u root -p
GRANT select,insert,update,delete,create,drop ON database.* TO 'username'@'localhost' IDENTIFIED BY 'password'
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON * . * TO 'username'@'localhost';