Skip to content

Install Server Environment on Linux

Erik Perin edited this page Oct 6, 2016 · 7 revisions

#What is LAMP? LAMP stack is a group of open source software used to get web servers up and running. The acronym stands for Linux, Apache, MySQL, and PHP. The data is stored in a MySQL database, and dynamic content is processed by PHP7. The steps requires the user to have root privileges on your VPS. In this case... on Ubuntu Server.


Step 1: Install Apache

Apache is a free open source software which runs over 50% of the world’s web servers.

To install apache, open terminal and type in these commands:

sudo apt update

so...

sudo apt install apache2

Ok... that's installed... Now let's test on your localhost address: Access Your Local Host


##Step 2: Install MySQL MySQL is a really great database management system used for organizing and retrieving data.

To install MySQL, back on terminal and type in these commands:

sudo apt install mysql-server libapache2-mod-auth-mysql php7.0-mysql

During the installation, MySQL will ask you to set a root password. If you miss the chance to set the password while the program is installing, it is very easy to set the password later from within the MySQL shell. Once you have installed MySQL, we should activate it with this command:

sudo mysql_install_db


Step 3: Install PHP

PHP is an open source web scripting language that is widely use to build dynamic webpages. To install PHP, open terminal and type in this command.

sudo apt -y install php7.0 libapache2-mod-php7.0

and

sudo service apache2 restart to restart the webserver

PHP Modules

PHP also has a variety of useful libraries and modules that you can add onto your virtual server. You can see the libraries that are available.

sudo apt-cache search php7*

Terminal will then display the list of possible modules. The beginning looks like this:

  • 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
  • php5-gmp - GMP module for php5
  • php5-ldap - LDAP module for php5
  • php5-mysql - MySQL module for php5
  • php5-odbc - ODBC module for php5
  • php5-pgsql - PostgreSQL module for php5
  • php5-pspell - pspell module for php5
  • php5-recode - recode module for php5
  • php5-snmp - SNMP module for php5
  • php5-sqlite - SQLite module for php5
  • php5-tidy - tidy module for php5
  • php5-xmlrpc - XML-RPC module for php5
  • php5-xsl - XSL module for php5
  • php5-adodb - Extension optimising the ADOdb database abstraction library
  • php5-auth-pam - A PHP5 extension for PAM authentication

Once you decide to install the module, type:

sudo apt install name of the module

You can install multiple libraries at once by separating the name of each module with a space... like...

sudo apt -y install php7.0-mysql php7.0-curl php7.0-gd php7.0-intl php-pear php-imagick php7.0-imap php7.0-mcrypt php-memcache php7.0-pspell php7.0-recode php7.0-sqlite3 php7.0-tidy php7.0-xmlrpc php7.0-xsl php7.0-mbstring php-gettext

Step 4: It's Work?

Although LAMP is installed, we can still take a look and see the components online by creating a quick php info page. To set this up, first create a new file:

sudo nano /var/www/info.php

Add in the following line:

<?php phpinfo(); ?>

Then Save and Exit.

Restart apache again... so that all of the changes take effect. Finish up by visiting your php info page (make sure you replace the example ip address with your correct one):

http://localhost/info.php

Congratulations! You now have a LAMP stack!

Clone this wiki locally