Categories: Snippets

How To Install LAMP on Ubuntu 14.04 [Quickstart]

Step 1: Update apt-get package lists

sudo apt-get update

Step 2: Install Apache, MySQL, and PHP packages

sudo apt-get -y install apache2 mysql-server php5-mysql php5 libapache2-mod-php5 php5-mcrypt

When prompted, set and confirm a new password for the MySQL “root” user:

Step 3: Create MySQL database directory structure

sudo mysql_install_db

Step 4: Run basic MySQL security script

sudo mysql_secure_installation

At the prompt, enter the password you set for the MySQL root account:

MySQL root password prompt:

Enter current password for root (enter for none): OK, successfully used password, moving on…

At the next prompt, if you are happy with your current MySQL root password, type “n” for “no”:

MySQL root password prompt:

Change the root password? [Y/n] n

For the remaining prompts, simply hit the “ENTER” key to accept the default values.

Step 5: Configure Apache to prioritize PHP files (optional)

Open Apache’s dir.conf file in a text editor:

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

Edit the DirectoryIndex directive by moving index.php to the first item in the list, so it looks like this:

DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm

Save and exit.

Restart Apache to put the change into place:

sudo service apache2 restart

Open the PHP script in a web browser. Replace your_server_IP_address with your server’s public IP address:

http://your_server_IP_address/info.php

Recent Posts

How To Troubleshoot Socket Errors in MySQL – Ubuntu

MySQL manages connections to the database server through the use of a socket file, a special…

5 years ago

How to remove .html, .php, etc (extension) from URL?

To remove the .html extension from your urls, you can use the following code in…

5 years ago

Ubuntu with Apache2: Installing and Configuring Your SSL Certificate

Use free/paid SSL certificates https://www.sslforfree.com Enable SSL Module Replace 'default-ssl' with the real site name…

5 years ago

Create zip archive excluding specific Files & Directories

Create archive of all files under public_html directory ignoring all files and folders including text…

6 years ago

how to use sudo command to install .tar.gz?

To install some file *.tar.gz, you basically would do: Open a console, and go to…

6 years ago

Change ownership of the directory in ubuntu

The chown command has the following syntax: [crayon-662edccd06d94129415948/] So in your example command it is your primary…

6 years ago