banner



How To Install Lamp In Ubuntu 14.04 Lts

Introduction

A "LAMP" stack is a group of open source software that is typically installed together to enable a server to host dynamic websites and spider web apps. This term is actually an acronym which represents the Linux operating system, with the Apache web server. The site data is stored in a MySQL database, and dynamic content is processed by PHP.

In this guide, we'll get a LAMP stack installed on an Ubuntu 14.04 Droplet. Ubuntu will fulfill our first requirement: a Linux operating system.

Notation: The LAMP stack tin can be installed automatically on your Droplet by adding this script to its User Information when launching it. Check out this tutorial to learn more than nearly Droplet User Data.

Prerequisites

Before you begin with this guide, you should accept a dissever, non-root user account fix on your server. You lot can acquire how to practise this by completing steps ane-4 in the initial server setup for Ubuntu fourteen.04.

Step 1: Install Apache

The Apache web server is currently the near popular spider web server in the world, which makes it a cracking default pick for hosting a website.

Nosotros can install Apache easily using Ubuntu'south package manager, apt. A parcel manager allows u.s.a. to install most software pain-free from a repository maintained by Ubuntu. You can learn more most how to use apt here.

For our purposes, we tin become started by typing these commands:

          sudo apt-get update sudo apt-get install apache2                  

Since we are using a sudo command, these operations go executed with root privileges. It volition ask you for your regular user's password to verify your intentions.

Afterwards, your web server is installed.

You lot can practise a spot check correct away to verify that everything went as planned by visiting your server's public IP address in your web browser (see the note nether the next heading to find out what your public IP address is if you practise not have this data already):

<pre> http://<span form="highlight">your_server_IP_address</span> </pre>

You will come across the default Ubuntu 14.04 Apache web page, which is there for informational and testing purposes. Information technology should look something like this:

Ubuntu 14.04 Apache default

If you run across this page, then your web server is now correctly installed.

How To Find your Server'south Public IP Accost

If y'all do not know what your server's public IP address is, there are a number of means you can find it. Usually, this is the address yous use to connect to your server through SSH.

From the command line, you can notice this a few ways. First, you tin can use the iproute2 tools to get your accost by typing this:

          ip addr show eth0 | grep inet | awk '{ impress $2; }' | sed 's/\/.*$//'                  

This will give you one or ii lines back. They are both right addresses, but your calculator may only be able to use one of them, so experience free to attempt each one.

An alternative method is to use an outside party to tell you how it sees your server. Yous can practice this by request a specific server what your IP address is:

          curl http://icanhazip.com                  

Regardless of the method you use to become your IP address, you can type information technology into your spider web browser'southward address bar to get to your server.

Stride two: Install MySQL

Now that we accept our web server up and running, it is time to install MySQL. MySQL is a database management organisation. Basically, it will organize and provide admission to databases where our site tin can store information.

Again, we can employ apt to larn and install our software. This time, we'll too install some other "helper" packages that will assist us in getting our components to communicate with each other:

          sudo apt-go install mysql-server php5-mysql                  

Note: In this example, you lot do not have to run sudo apt-get update prior to the command. This is because nosotros recently ran it in the commands above to install Apache. The parcel alphabetize on our computer should already be up-to-appointment.

During the installation, your server will inquire you to select and confirm a password for the MySQL "root" user. This is an administrative account in MySQL that has increased privileges. Call back of it equally being like to the root business relationship for the server itself (the 1 you lot are configuring now is a MySQL-specific business relationship however).

When the installation is consummate, we need to run some additional commands to get our MySQL environment set upwards deeply.

First, we demand to tell MySQL to create its database directory structure where it will store its data. You lot can do this by typing:

          sudo mysql_install_db                  

Later, we want to run a simple security script that will remove some dangerous defaults and lock down admission to our database system a little bit. Start the interactive script by running:

          sudo mysql_secure_installation                  

You lot volition be asked to enter the password you set up for the MySQL root business relationship. Next, it volition ask y'all if you desire to change that password. If you lot are happy with your current countersign, blazon "n" for "no" at the prompt.

For the rest of the questions, you should but hitting the "ENTER" key through each prompt to accept the default values. This will remove some sample users and databases, disable remote root logins, and load these new rules and then that MySQL immediately respects the changes nosotros have fabricated.

At this bespeak, your database system is now fix and we can move on.

Step 3: Install PHP

PHP is the component of our setup that volition process code to display dynamic content. It tin run scripts, connect to our MySQL databases to get information, and mitt the processed content over to our web server to display.

We can once once more leverage the apt system to install our components. Nosotros're going to include some helper packages as well:

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

This should install PHP without any problems. We'll exam this in a moment.

In most cases, nosotros'll desire to change the fashion that Apache serves files when a directory is requested. Currently, if a user requests a directory from the server, Apache will first expect for a file called index.html. Nosotros want to tell our web server to adopt PHP files, so we'll brand Apache look for an index.php file start.

To do this, blazon this control to open the dir.conf file in a text editor with root privileges:

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

It will look similar this:

<pre> <IfModule mod_dir.c> DirectoryIndex alphabetize.html alphabetize.cgi index.pl <span class="highlight">index.php</span> index.xhtml index.htm </IfModule> </pre>

We want to move the PHP index file highlighted to a higher place to the first position after the DirectoryIndex specification, like this:

<pre> <IfModule mod_dir.c> DirectoryIndex <bridge class="highlight">index.php</span> index.html alphabetize.cgi index.pl alphabetize.xhtml index.htm </IfModule> </pre>

When you are finished, relieve and close the file by pressing "CTRL-X". You lot'll accept to confirm the save by typing "Y" so hitting "ENTER" to confirm the file save location.

Afterward this, we need to restart the Apache web server in order for our changes to exist recognized. You can do this by typing this:

          sudo service apache2 restart                  

Install PHP Modules

To enhance the functionality of PHP, we can optionally install some boosted modules.

To come across the bachelor options for PHP modules and libraries, you tin can blazon this into your system:

          apt-cache search php5-                  

The results are all optional components that you can install. It will requite yous a short description for each:

          php5-cgi - server-side, HTML-embedded scripting language (CGI binary) php5-cli - command-line interpreter for the php5 scripting language php5-common - Common files for packages built from the php5 source php5-curl - Scroll module for php5 php5-dbg - Debug symbols for PHP5 php5-dev - Files for PHP5 module evolution php5-gd - GD module for php5 . . .                  

To become more information near what each module does, you tin either search the cyberspace, or you can look at the long description in the package by typing:

<pre> apt-cache show <span grade="highlight">package_name</span> </pre>

There volition be a lot of output, with one field chosen Description-en which will have a longer explanation of the functionality that the module provides.

For example, to detect out what the php5-cli module does, we could type this:

          apt-cache testify php5-cli                  

Along with a large amount of other information, y'all'll observe something that looks like this:

          . . . SHA256: 91cfdbda65df65c9a4a5bd3478d6e7d3e92c53efcddf3436bbe9bbe27eca409d Description-en: command-line interpreter for the php5 scripting language  This packet provides the /usr/bin/php5 command interpreter, useful for  testing PHP scripts from a shell or performing general shell scripting tasks.  .  The following extensions are built in: bcmath bz2 calendar Core ctype appointment  dba dom ereg exif fileinfo filter ftp gettext hash iconv libxml mbstring  mhash openssl pcntl pcre Phar posix Reflection session shmop SimpleXML soap  sockets SPL standard sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader  xmlwriter zippo zlib.  .  PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used  open source full general-purpose scripting language that is peculiarly suited  for web development and can be embedded into HTML. Description-md5: f8450d3b28653dcf1a4615f3b1d4e347 Homepage: http://www.php.net/ . . .                  

If, after researching, yous decide yous would like to install a bundle, you tin do so by using the apt-get install command like we accept been doing for our other software.

If we decided that php5-cli is something that we demand, we could type:

          sudo apt-go install php5-cli                  

If yous want to install more than ane module, you tin can do that past listing each one, separated by a space, post-obit the apt-get install command, similar this:

<pre> sudo apt-get install <span class="highlight">package1</span> <bridge class="highlight">package2</span> <span class="highlight">…</bridge> </pre>

At this bespeak, your LAMP stack is installed and configured. We should still exam out our PHP though.

Step 4: Examination PHP Processing on your Web Server

In order to test that our system is configured properly for PHP, we tin create a very bones PHP script.

We will call this script info.php. In social club for Apache to notice the file and serve it correctly, it must be saved to a very specific directory, which is called the "web root".

In Ubuntu 14.04, this directory is located at /var/world wide web/html/. We can create the file at that location by typing:

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

This volition open a bare file. We desire to put the post-obit text, which is valid PHP code, inside the file:

          <?php phpinfo(); ?>                  

When you are finished, save and shut the file.

Now we can test whether our spider web server can correctly display content generated by a PHP script. To try this out, we just accept to visit this page in our web browser. You lot'll need your server's public IP address again.

The accost yous want to visit will be:

<pre> http://<span class="highlight">your_server_IP_address</bridge>/info.php </pre>

The page that you come to should expect something like this:

Ubuntu 14.04 default PHP info

This folio basically gives you data about your server from the perspective of PHP. It is useful for debugging and to ensure that your settings are existence applied correctly.

If this was successful, then your PHP is working as expected.

You lot probably want to remove this file afterwards this test considering information technology could actually give data about your server to unauthorized users. To practise this, y'all tin type this:

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

You can always recreate this page if y'all need to access the data again later on.

Conclusion

Now that y'all have a LAMP stack installed, you have many choices for what to exercise side by side. Basically, you've installed a platform that will let you to install most kinds of websites and web software on your server.

Some popular options are:

  • Install Wordpress the most pop content direction arrangement on the internet
  • Set Up PHPMyAdmin to help manage your MySQL databases from web browser.
  • Acquire more about MySQL to manage your databases.
  • Learn how to create an SSL Certificate to secure traffic to your web server.
  • Learn how to utilize SFTP to transfer files to and from your server.

Annotation: We will be updating the links above to our 14.04 documentation equally it is written.

<div form="author">Past Justin Ellingwood</div>

Source: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-14-04

Posted by: brouwerjuseenoth.blogspot.com

0 Response to "How To Install Lamp In Ubuntu 14.04 Lts"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel