Installing LAMP on Ubuntu 14.04.2
LAMP (Linux, Apache, MySQL, PHP) Stack
A "LAMP" stack consists of four components;
- Linux,
- Apache,
- MySQL,
- Php,
These are the components that comprise the LAMP stack. As this is the standard stack that enables the use of advance web applications including the one that I am currently using mediawiki to create my own wikipedia for the server that I am currently working on and developing on.
I would eventually like this hobby to eventually pay itself and to do that I will begin hosting websites and developing websites for companies using stacks of software. I believe adding the right components to each website I build and host will generate me with some form of revenue.
To begin my elaboration on the subject of each component that comprises this stack I will be writing a page on each of them to get a both a better understanding of the components that comprise each of the following items.
Installation
I believe that it is critical to write articles for each of the server operating systems that I develop upon. Eventually expanding this knowledge to all other main server operating systems that are in the workplace today from small business needs to enterprise. I wanna see if I can expand the user base of Linux users here in Spokane. I believe to start this project it would require me to not only create online user-generated content communities for each of the niches that follow using Linux in the daily.
Apache2 Installation
On with the installation instructions. To begin our installation of the LAMP stack we first must install the Apache2 web server for our web hosting needs.
First update the system that is being worked on:
sudo apt-get update
Once the update is finished install the apache2 web server:
sudo apt-get install apache2
I will be brief about the above commands that are being run from the command line. Firstly sudo simply allows the user to execute the command with root privileges. Next is the apt-get portion in which this is the package manager for most Debian-based distros. For Ubuntu it comes right out of the box though if you prefer using apititude nothing is stopping you from doing so. The install portion is the install option for the package manager apt-get. Finally the package name that we are installing is apache2 which is the web server we need to get installed on the system to enable us to web host.
Testing out Apache2
Testing out the Apache2 web server requires minimal effort. Simply type into any web browser either the Local IP Address of the machine that Apache has been installed upon or localhost if you are working from the machine itself.
This should be the picture you see when you finish installing and testing the Apache2 server on your Linux machine.
MySQL Installation
MySQL is a free database management system. This makes installing and accessing databases much easier on me at least to develop web applications. This server enables our websites to access databases where the information for the websites will be held inside.
I will be primarily using MySQL for the time being until I get more complicated with my web application options. I believe to be a good web developer I will have to learn many languages and database scripting to make my life easier.
To install MySQL onto the machine it will require the following snippet of code:
sudo apt-get install mysql-server php5-mysql
This will simply install MySQL server onto the Ubuntu 14.04.2 server machine that one is working on. The next step will be to set up the MySQL server for use within the stack itself. To do this one simply has to run the following commands:
First, we need to tell MySQL to create its database directory structure where it will store its information. sudo mysql_install_db
Next we want to run a simple security script that will remove some of the dangerous defaults. To start the script simply run the following command.
sudo mysql_secure_installation
PHP Installation
PHP is a scripting programming language that primarily will be used in this stack to communicate between MySQL databases to retrieve information. I believe that I will eventually begin learning the basics of this language to develop websites even faster and at a faster rate than most individuals. Learning the core languages of the web will come in handy for future projects and possible contracts.
To begin our installation of PHP we simply have to use the apt
system to install the necessary components. By simply using the following system commands:
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
The following command should install PHP without any issue. I believe that I will be posting this content in my development blog since this will make writing posts for that blog much easier if I simply catalog all my knowledge.
Be sure to restart the Apache web server by running the following command:
sudo service apache2 restart
Installation of PHP Modules
To enhance our functionality of PHP, we can add some modules to boost it's abilities.
For this example we will be installing the following packages:
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 - CURL module for php5
php5-dbg - Debug symbols for php5
php5-dev - Files for PHP5 module development
php5-gd - GD module for php5
For more modules of php5 simply use the following command:
apt-cache search php5-
For a longer description simply use the following command:
apt-cache show package_name
To figure out what each module does use the following command:
apt-cache show php5-cli
To install all the packages stated above we will be running the following command:
sudo apt-get install php5-cgi php5-cli php5-comon php5-curl php5-dbg php5-dev php5-gd
Testing PHP on the Web Server
To test that our system has PHP correctly setup and installed on our current system. All one must simply do is create a script to be run from the web server itself. By doing the following.
In this version of the LAMP install tutorial, the file directory that we will be using is called /var/www/html/
. Which simply states that the directory we will be using from this point forward will be in the var folder -> www folder -> html folder in which we hold our website information in.
We can either navigate to the directory itself by running the following command:
sudo cd /var/www/html
Or we can simply write the file into the folder itself by running the following command:
sudo nano /var/www/html/info.php
We will be writing the following code into that file:
<?php
phpinfo();
?>
Once we are finished writing that small snippet of code into our php file. We can simply save and close the file and test out php5 by simply typing the following into the web browser.
http://server_IP_address/info.php
The page that is brought up right afterwards should look like this:
Comments
Post a Comment