Techies Adsense

Tuesday, 16 August 2016

How to Install LAMP in Linux Ubuntu (Linux Apache MySQL and PHP)

How to Install LAMP in Linux Ubuntu (Linux Apache MySQL and PHP) 

"LAMP" known as a Linux, Apache, MySQL and PHP and the detailed steps below for the installations and configurations of Linux Web server for you WordPress or PHP websites. 

Login into your Server's Terminal

  $ sudo apt-get update

You can execute upgrade command if you have enough bandwidth to update defaut packages to latest version.

  $ sudo apt-get update && sudo apt-get upgrade

1. Apache Installations:

$ sudo apt-get install apache2
...... upgraded, 8 newly installed, 0 to remove and 0 not upgraded.Need to get 1,284 kB of archives.After this operation, 5,348 kB of additional disk space will be used.Do you want to continue? [Y/n] Y
$ sudo service apache2 restart
techiescrowd@AzureUbuntu:~$ sudo service apache2 restart * Restarting web server apache2  AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 12 Set the 'ServerName' directive globally to suppress this message                                                     [ OK ]

To resolve above warning :

$ sudo vi /etc/hosts127.0.0.1 localhost127.0.0.1 AzureUbuntu
sudo vi /etc/apache2/httpd.confServerName localhost:wq!

2. MySQL Installations: 

The below command will install mysql automatically and also start the services. You can verify by executing

$ sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
$ service mysql status(mysql start/running, process 4566)

$ sudo service mysql restartmysql stop/waiting(mysql start/running, process 4566)

To Login into mysql type 

$sudo mysql
mysql> show databases;
| Database           |
| information_schema |
| mysql              |
| performance_schema |
3 rows in set (0.00 sec)
To create mysql database type login into the mysql server by executing: 

$ sudo mysql -h localhost -u root -p...*******$ mysql> create database myweb_db;Query OK, 0 rows affected (0.00 sec)
mysql> CREATE USER 'testdb'@'localhost' IDENTIFIED BY 'test_pass1';Query OK, 0 rows affected (0.00 sec)

Now Give Access to the User with Database:

mysql> user myweb_db;
mysql>GRANT ALL PRIVILEGES ON mydatabase.* TO 'mydbuser'@'my-host-ip' IDENTIFIED BY 'mydbuserpass';

3. Install And Configure PHP:  
Below command will install php and required php modules and automatically restart Apache web server. : 

$ sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

To verify your php instllations create a phpinfo.php page and enter the below code in the file. :

$ cd /var/www/html
$ touch phpinfo.php <?phpphpinfo();?>

Now access the server through the IP or host address example. http://your-host-ip-address/phpinfo.php

Default Web Server Directory Path: /var/www/html

$ sudo vi /etc/apache2/sites-enabled/000-default.conf
<Directory /var/www/html>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
To Set Up mod_rewrite for Apache and Restart the Service. 
$ sudo a2enmod rewrite
Enabling module rewrite.
To activate the new configuration, you need to run:
$sudo  service apache2 restart
For Yii Framework you need to install following packages:

Intl extension            ==>     $ sudo apt-get install php5-intl ICU version             ==>          $ sudo apt-get install php5-intl ICU Data version     ==>          $ sudo apt-get install php5-intl PDO SQLite extension ==>      $ sudo apt-get install php5-sqlite Memcache extension : ==>       $ sudo apt-get install php5-memcached memcached APC extension            ==>       $ sudo apt-get install php-apc PDO PostgreSQL extension: ==> $sudo apt-get install php5-pgsql GD PHP extension with FreeType support ==> sudo apt-get install php5-gd Expose PHP  "expose_php = Off" $ sudo vi /etc/php5/apache2/php.ini ImageMagick PHP extension with PNG support == > sudo apt-get install php5-common gcc php5-imagick imagemagick

Setup Permission Examples: 
$ sudo chmod -R 777 /var/www/html/backend/web/assets$ sudo chmod -R 777 /var/www/html/frontend/runtime/logs$ sudo chmod -R 777 /var/www/html/frontend/runtime/cache
If you are still facing any issue with php on ubuntu Server you can enable "display_errors = On"

$ sudo vi /etc/php5/apache2/php.ini
display_errors = on:wq!

Thanks for the kind visit here. If you having any issue related to Apache Web server please share your Errors.

No comments: