In this tutorial I will install and configure LAMP Server in Ubunut 16.10 operating system. As you know LAMP server made from four open source component.
L – Linux (Ubuntu Operating system)
A - Apache ( Web Server )
M- MySQL or MariaDB ( Database )
P – PHP/Perl/Python ( PHP is scripting language, Perl/Python can also be use as per requirement)
Server details
Server IP Address: 192.168.0.70
Network Allowed: 192.168.0.0/24
Hostname: lamp.example.com
Apache Config file: /etc/apache2/apache2.conf
Apache Document root: /var/ww/html/
MySQL config file: /etc/mysql/mysql.cnf
PHP config file: /etc/php/7.0/apache2/php.ini
Apache service: apache2
MySQL service: mysql
Windows Client Details
IP address: 192.168.0.66
Operating System: Windows 7
Install LAMP server in Ubunut 16.10 /16.XX
Up to date your server before installing LAMP
$ sudo apt-get update
Once server updated , install required packages to install LAMP Stack
Install apache package
shahzad@lamp:~$ sudo apt-get install apache2
Check apache installed package
shahzad@lamp:~$ dpkg -l | grep apache2
Start apache service
shahzad@lamp:~$ sudo systemctl start apache2
sudo: unable to resolve host lamp.example.com: Resource temporarily unavailable
To resolve above error, make hostname entry in /etc/hosts file to resolve the hostname.
shahzad@lamp:~$ sudo vim.tiny /etc/hosts
192.168.0.70 lamp.example.com
Again restart service
shahzad@lamp:~$ sudo systemctl restart apache2
or,
shahzad@lamp:~$ sudo systemctl restart apache2.service
Permanently enable server on system boot
shahzad@lamp:~$ sudo systemctl enable apache2
Check service is enable or not
shahzad@lamp:~$ service --status-all | grep apache2
[ + ] apache2
Install MySQL package
shahzad@lamp:~$ sudo apt-get install mysql-server mysql-client
During the installation of MySQL package you will require to set MySQL root password .
Confirm password
Once the MySQL package is install , run mysql_secure_installation command for secure installation
shahzad@lamp:~$ sudo mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root: ******
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin? no
... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Success.
All done!
Enable MySQL service on boot
shahzad@lamp:~$ sudo systemctl enable mysql
or,
shahzad@lamp:~$ sudo systemctl enable mysql.service
Restart MySQL service
shahzad@lamp:~$ sudo systemctl restart mysql
or,
shahzad@lamp:~$ sudo systemctl restart mysql.service
Install PHP package
shahzad@lamp:~$ sudo apt-get install php
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libapache2-mod-php7.0 php-common php7.0 php7.0-cli php7.0-common php7.0-json php7.0-opcache php7.0-readline
Suggested packages:
php-pear
The following NEW packages will be installed:
libapache2-mod-php7.0 php php-common php7.0 php7.0-cli php7.0-common php7.0-json php7.0-opcache php7.0-readline
0 upgraded, 9 newly installed, 0 to remove and 174 not upgraded.
Need to get 3,485 kB of archives.
After this operation, 14.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Check PHP version
shahzad@lamp:~$ php -v
PHP 7.0.15-0ubuntu0.16.10.4 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.15-0ubuntu0.16.10.4, Copyright (c) 1999-2017, by Zend Technologies
Check php installed package
shahzad@lamp:~$ dpkg -l | grep php
Check/search PHP available package for further installation
shahzad@lamp:~$ apt-cache search php | less
Create PHP Test page
Create file name as info.php in /var/www/html/ and add below syntax
shahzad@lamp:/var/www/html$ sudo vim.tiny info.php
<?php
phpinfo();
?>
Now browser PHP info file by accessing with http://192.168.0.70/info.php
LAMP server installed successfully. In my next tutorial I will be posting some more new tutorial related to LAMP. Please stay connect…..!