Install LAMP in Ubuntu Natty Narwhal

Linux, Apache, Mysql, and PHP server is my favorite web server environment that I like. This article shows how to set it up properly. First note your IP server of Ubuntu PC.

Setup MySQL

You have to run the steps as root, so be careful.

sudo su

apt-get install mysql-server mysql-client

During the setup you will be asked to change SA admin password. Please do so to make sure your database is secured.

Install Apache

apt-get install apache

After installation completed, open the browser and go to the server, enter your server IP at the browser address. You should see “It works!”, then your apache setup is working.

Apache’s default document root is /var/www on Ubuntu, and the configuration file is /etc/apache2/apache2.conf. Additional configurations are stored in subdirectories of the /etc/apache2 directory such as /etc/apache2/mods-enabled (for Apache modules), /etc/apache2/sites-enabled (for virtual hosts), and /etc/apache2/conf.d.

Install PHP

Go to terminal again and type this command.

apt-get install php5 libapache2-mod-php5

Restart apache to run the PHP engine.

/etc/init.d/apache2 restart

To test if the PHP installation is ok we create new php file.

nano /var/www/info.php

Enter this code then save the file and exit from the editor.

Test it in your browser add /info.php after your IP server. You should see PHP configuration and information. You can check if all settings are as you expected and you may add or activate service, libraries, etc. if you like.

Setup MySQL Modules In PHP5

To get MySQL support in PHP, we can install the php5-mysql package. It’s a good idea to install some other PHP5 modules as well as you might need them for your applications. You can search for available PHP5 modules like this:

apt-cache search php5

Pick the ones you need and install them like this:

apt-get install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

Now restart Apache2:

/etc/init.d/apache2 restart

Now reload info.php in your browser and scroll down to the modules section again. You should now find lots of new modules there, including the MySQL module.

And install phpmyadmin a nice database tool to manage Mysql database so easier for you to access the database from any PC or Mac in the network.

apt-get install phpmyadmin

Finished! All you need to setup LAMP in your Ubuntu are done.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: