lamp-ubuntu-1504-feat

lamp-ubuntu-1504-feat

This is a fast and version that is clear of to build a working LAMP server to host your websites with it. As a refresh, LAMP stands for Linux, Apache, MySQL and PHP which in this guide we’ll replace it with MariaDB that is faster than traditional MySQL server. As what I can remember, I wrote about LAMP installation on CentOS 7 already but never write the thing that is same brand new Ubuntu variation that is now variation 15.04 codename Vivid Vervet. Therefore, continue reading!

Prerequisites

  1. A host / VPS operating Ubuntu 15.04 that this guide i personally use its x86_64 variation from DigitalOcean.
  2. SSH customer software like Putty and appropriate knowledge to utilize the app.
  3. Some fundamental understanding of typical unix demand.
  4. A cup coffee or tea as constantly.

How to put in Apache 2

Step 1 – very first thing first, login towards host as root (i suppose you knew utilizing SSH Putty that is/). Like me, you will be asked to change default root password:

Step 2 – Update Ubuntu’s packages to latest version using this command:

apt-get update -y
 apt-get upgrade -y

screenshot:

Step 3 – Now here’s the main command to install Apache 2 webserver on Ubuntu 15.04:

apt-get install apache2 -y

You’ll see something similar to this:

How to Install PHP 5

Step 1 – For the first step, you can start installing PHP5 and MySQL PHP modules using this command:

apt-get install php5 php5-mysql -y

the process will be done in few seconds if you are using a droplet from DO. Pic:

Step 2 – Install other PHP5 modules your software / script might need. There are many modules available and your app/script may need ones that are specific. But you’ll install many modules that are common apps usually need it. Here’s the command you can issue:

apt-get install php5-cgi php5-cli php5-common php5-curl php5-dev php5-gd php5-tidy php5-xmlrpc php5-xsl php5-mcrypt php5-imap php5-json that is php5-imagick php5-mcrypt libapache2-mod-php5 -y

screenshot:

install-php-common-modules

Step 3 – That’s it. Now you can always check which PHP variation is set up by using this command that is magic*******)

php -v

In my example it is PHP 5.6.4

php-version-check

How to Install MariaDB Server

Step 1 – The command to install MariaDB is still the same which is:

apt-get install mariadb-server -y

screenshot:

mariadb-installation-ubuntu

Step 2 – Once the install process is finished, you have to firstly setup new root password to your MariaDB install (standard is blank). Problem this demand:

/usr/bin/mysql_secure_installation

Simply strike Enter in your keyboard then answer next questions accordingly if asked with current password. Do not forget to create password that is new keep in mind it (it’s your database password for individual root).

Step 3 – Now login to MariaDB to check your newly produced root password:

mysql -u root -p

enter your MySQL root password

mariadb-login-root

(it is MariaDB v10.0.17 which is equivalent to MySQL 5.6 & 5.7

Finally, do not forget to restart Apache 2 webserver:

service apache2 restart

that’s it*****)As you can see from the pic above. You can now start hosting your websites / blogs in it(web directory):

mkdir -p /var/www/example.com
 on it which shortly can be done this way:

How to Host A Website on Ubuntu LAMP Server

Step 1 – Create the directory where you put all your site’s files; mkdir /var/www/example.com/logs

the production just appears like this:

create-directory

Step 2 – you can store all files including scripts and medias of your website so you have now a directory where. What’s next to do is to make sure Apache will know where to access when a domain name is called. Hence, you have to create a new hosts that are virtual, a configuration block of Apache for every single of one’s domain / sub-domain.

nano /etc/apache2/sites-available/example.com.conf

The demand informs nano editor generate a file that is new example.com.conf. Do not forget to change every example.com in this tutorial with your domain that is own title. Additionally, you can install it easily with this command:

apt-get install nano -y

Step 3 – Now a blank editor page will show up if you have no Nano installed yet. Next, copy paste configuration below and adjust few lines accordingly:

<VirtualHost *:80> 
      ServerAdmin [email protected]
      ServerName example.com
      ServerAlias www.example.com
      DocumentRoot /var/www/example.com
      ErrorLog /var/www/example.com/logs/error.log 
      CustomLog /var/www/example.com/logs/access.log combined
      <Directory /var/www/example.com>
         Options Indexes FollowSymLinks
         AllowOverride All
         Order allow,deny
         allow from all
      </Directory>
 </VirtualHost>

here’s an example:

apache-domain-conf-file

Save it and exit Nano editor (Control+O then Control+X).

Step 4 – Reload Apache to be able to read a configuration that is new.

service apache2 reload

Step 5 – after that you can allow the digital Hosts (setup) file by using this demand:

a2ensite instance.com

a2ensite-command

You may then test that by producing a phpinfo file:

nano /var/www/example.com/info.php

and place this line within:

<?php phpinfo(); ?>

phpinfo-ubuntu-1504

Save it and leave Nano editor (Control+O then Control+X).

Open your web browser and kind:

http://example.com/info.php

then you certainly will now see a number of setup information on your set up PHP.

Step 6 – this is certainly optional you might need it if you use WordPress:

chown www-data:www-data -R /var/www/example.com
 chmod 755 /var/www/example.com

That’s all. Don’t neglect to follow me personally on twitter to obtain faster notification of the latest change.

About The Author

LEAVE A REPLY

Please enter your comment!
Please enter your name here