How to install LAMP stack on Ubuntu 14.04

Open terminal on Ubuntu and type code:

Step 1: Install Apache

sudo apt-get update
sudo apt-get install apache2

Check apache:

http://your_server_IP_address
Ex:
http://127.0.0.1
or
http://localhost

Step 2: Install MySQL

sudo apt-get install mysql-server php5-mysql
sudo mysql_install_db

Set password mysql for user:

sudo mysql_secure_installation

Check mysql:

sudo mysql -u root -p

Step 3: Install PHP 5 (ver 5.5.9)

sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

sudo nano /etc/apache2/mods-enabled/dir.conf

- Edit:

<IfModule mod_dir.c> 
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.html 
</IfModule>
 — — — — — — — — — — — — — — — — — — — — — — — — — 
<IfModule mod_dir.c> 
DirectoryIndex index.php index.html index.cgi index.pl index.php index.xhtml index.html 
</IfModule>

"Ctrl + X" next "Y" to save it.

- Restart Apache:

sudo service apache2 restart

- Install package php:

sudo apt-cache search php5-
apt-cache show package_name // View Info package

- Install all package:

sudo apt-get install php5-cgi php5-cli php5-common php5-curl php5-dbg php5-gd php5-gmp php5-json php5-ldap php5-mysql php5-odbc php5-pgsql php5-pspell php5-readline php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl libphp5-embed php5-adodb php5-apcu php5-enchant php5-exactimage php5-fpm php5-gdcm php5-gearman php5-geoip php5-gnupg php5-imagick php5-imap php5-interbase php5-intl php5-lasso php5-librdf php5-mapscript php5-mcrypt php5-memcache php5-memcached php5-midgard2 php5-ming php5-mongo php5-msgpack php5-mysqlnd php5-mysqlnd-ms php5-oauth php5-pinba php5-ps php5-radius php5-redis php5-remctl php5-rrd php5-sasl php5-stomp php5-svn php5-sybase php5-tokyo-tyrant php5-vtkgdcm php5-xcache php5-xdebug php5-xhprof

  • Create view php info

sudo nano /var/www/html/info.php

  • Type:

<?php phpinfo(); ?>

  • "Ctrl + X" next "Y" save it.

View result:

http://127.0.0.1/info.php

GOOD LUCK.

Like what you read? Give Nguyễn Mạnh Linh a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.