LEMP Stack Or Linux, Nginx, MySQL, PHP Ko Ubuntu 16.04 Par Install Kaise Kare

LEMP stack

Doston aaj ke is post me main apko LEMP install karne ka sabse easy method bataunga. Jisme aap Ubuntu linux server, Nginx, MySQL aur PHP apne Digital Ocean ke droplet ke andar install karna sikhenge. Agar aap is method ko ache se follow karenge to aap bina kisi pareshani ke ek baar me ye setup successfully complete kar lenge.

Software Stack LEMP Kya Hai?

LEMP software stack me sirf ek software nahi hota balki isme ek se jyada software hote hain jo dynamic web pages aur web applications ko serve karne ka kaam karte hain. LEMP ka naam sunkar aapko confuse hone ki jarurat nahi hai ye bs short form hai jo alag alag softwares hain unke naam se hi milkar  bana hai. Isme Linux, Nginx, MySQL aur PHP ke naam ka letter use karne se LEMP bana hai.

LEMP Digital Ocean ke Droplet server ke andar hamare website ko run karne ke lie base taiyar karta hai. Jiske baad hum wordpress install kar ke apne website ko chala sakte hain.

Is method ko shuru karne se pehle aap ye confirm kar le ki aapke paas ek Non-root user account hona chahiye jisme sudo previliges yani authorisation bhi hona chahiye. Aap Digital Ocean ke is tutorial  Ubunti 16.04 initial server setup kar ke naya Non-root user account create kar sakte hain.

Fir bhi agar aap ko isme pareshani ho rahi hai to aap ‘root’ defualt username ke sath sare kaam kar sakte hain. Aap non-root username na banaye to bhi chalega. Non-root user ap apni security ke lie bana sakte hain.

Ubuntu 16.04 Me LEMP ( Linux, Nginx, MySQL & PHP) install kaise kare

Friends Digital Ocean me Hosting server create karne se website ko run karane tak ke sare kaam khud hi karne hote hain. Lekin aap ko tension lene ki bilkul bhi jarurat nahi hai ye bahut hi aasan process hai. Sunne me aur dekhne me bhale hi apko thodi tough lage lekin hai bahut aasan.

Main ye process bahut hi aasan shabdon me bata raha hu bas apko pura process ko properly follow karna hai. Agar aap ek bhi step miss karoge to problem hogi otherwise aap successfully sara setup complete kar lenge.

LEMP softwares ko install karne se pehle aapko step by step 4 kaam pure karne honge tabhi aap is method ko complete kar sakoge.

1. Buy Digital Ocean Hosting Server

Ji han friends apko sabse pehle to Digital Ocean se hosting server kharidna hoga. Waise apko iske lie pay karne ki jarurat nahi hai kyu ki isme 2 month ki hosting free hai. Aap is method se Digital Ocean ki 2 Month ki free hosting kaise buy kare  jaan sakte hain.

2. Create Droplets Servers

Digital ocean ek VPS ki tarah kaam karta hai. Matlab ki isme apko khud se Virtual private server banana padta hai. Jahan aap apni sari website ko run kara sakte hain.

3. Install PUTTY and Generate SSH key  

Ye hamara step 3 hai jisme hume ek open source emulator PUTTY ko install karte hain. PUTTY serial console aur network file transfer application hai. Iska use SSH key generate kar ke Digital ocean ke Droplet VPS server me login karne ke lie karte hain.

Login karne se pehle most important apko SSH key PUTTY se generate karna hota hai aur us SSH key ko Digital ocean ke security setting me jakar add karna hota hai.

4. Login to the Server with PUTTY

SSH key generate karne ke baad server me aap PUTTY ke help easily access kar sakte hain. Ab aap LEMP ko server ke andar easily install kar sakte hain.

Ubuntu 16.04 Me LEMP  install karne ka Complete Method

Aaj ka ye tutorial LEMP install karne ke lie hai jo ek platform create karta server ke andar jisme wordpress install kar ke aap website ko run karate hain. To chaliye step by step LEMP ko install karte hain.

Step 1. Install the Nginx Web Server

Is installation process me jtne bhi software install honge (lemp) wo sare Ubuntu ke default package se aayenge. Iske lie hum apt package management suite ka use karenge sari installation process ke lie.

Since hum pehli bar apt ka use kar rahe hain, islie hume sabse pehle  local package index ko update karna padega. Fir uske bad hum server ko install kar sakenge.

♦ sudo apt-get update
♦ sudo apt-get install nginx

 

Ubuntu 16.04 par ab Nginx properly configured ho chuka hai aur baki ka installation work kiya ja sakta hai. Jab Nginx ka installation process pura ho jaye to fir aap apne server ip address ko browser me daal kar check kare.

Agar aapko apna ip address nahi malum hai to aap Digital ocean ke droplets me jakar server ip address nikal sakte hain. Ya fir niche die command se apko ip address mil jaaega.

♦ curl -4 icanhazip.com

 

Iske baad aap apne id ko browser me open kare. Open karne ke simply niche die gae index ke jaisa hi follow kare.

http://server_ip_address_or_domain 

 

Agar apko apne ip address par jane ke baad niche ke screenshot jaisa page dekhne ko mil jaaye to samajhle ki Nginx successfully install ho chuka hai.

1 LEMP

Step 2. Install MySQL to Manage Site Data

Ab humare paas khud ka web server hai to hume ek database management system chahiye jisse hum apne website ke data ko store aur manage kar sake. Iske lie hume MySQL install karne ki jarurat hai.

Aap is command ka use kar ke aasani se MySQL install kar sakte hain.

♦ sudo apt-get install mysql-server

 

Apko MySQL system install karne ke bich me root or administrative password set karne ke lie puchha jaaega. Aap apni marzi se password type kare aur fir enter kar le, iske baad aap dubara password ko daal ke verify bhi kar le.

MySQL database software server me install ho chuka hai. iske baad aap chaho to installation ko aur secure ka sakte ho MySQL secure installation ke use se. Lekin meri maane to iska use na hi kare to achha hai.

Step 3. Install PHP for Processing 

Ab aapne web pages ko serve karne ke lie Nginx install kar liya hai aur data ko store aur manage karne ke lie MySQL bhi install kar liya hai. lekin fir bhi hum abhi dynamic content generate nahi kar sakte. Iske lie hum PHP ka use karenge.

Dusre web servers ki tarah Nginx ke paas apna native PHP processing nahi hota to hume php-fm install karne ki jarurat hai, Jise fastCGI process manager bolte hain.  Ab hum php-fm ko process karne ke lie Nginx ko PHP request pass karwaenge.

Is module ko hum install kar sakte hain jisse ek additional helper package bhi sath me install hoga  jo PHP ko hamare database backend se communicate karne ke lie allow karega. 

Installation process PHP core files ko bhi copy karega. Ise shuru karne ke lie niche wale command ka use kare.

♦ sudo apt-get install php-fpm php-mysql

 

Configure the PHP processor

Ab hamare paas PHP components install ho chuke hain, lekin apni setup ko aur secure karne ke lie hume is ke configuration me thodi change karni padegi.

Ab hum configuration ko change karne ke lie php-fm ko root access ke sath open karenge.

♦ sudo nano /etc/php/7.0/fpm/php.ini

 

Is file ke andar hume jis parameter ko change karna hai wo ye hai cgi.fix_pathinfo to sabse pehle aapko ise search karna padega. Yahan apko console me kuch bhi work karne ke lie niche command diye gae hain jaise:

Search – Ctrl+W   

Paste karne ke lie – Mouse ka right button click

Delete –  Backspace & delete button

Exit – Ctrl+X

Aap unhe dekh ke use kar sakte hain upar maine bas kuchh command hi likhe hain. 

Bas hume sirf ye parameter search karna hai abhi  cgi.fix_pathinfo . Ye hume search karne ke baad jo milega usme is parameter ke pehle semi colon (;) hoga aur last me “1” default  hoga. Ab hume semi colon ko delete kar dena hai aur “1” ki jagah “0” se replace kar lena hai.

Change hone ke baad ye parameter kuch is tarah dikhai dega.

cgi.fix_pathinfo=0

 

Jab ye change ho jaye to aap Ctrl+W press kare aur Yes select kar ke enter press kar le.

Ab bas hume PHP ko restart kar lena hai is command ko type karke.

♦ sudo systemctl restart php7.0-fpm

 

Ye hamare dwara kiye gae change ko implement karega.

Step 4. Configure Nginx to Use the PHP Processor

Ab hamne apni jarurat ke sare components install kar lie hain. Hume sirf ek configuration ko change karna baki rah gaya hai. Jisse hum Nginx ko batayenge ki dyanmic content ke lie processor ko use karna hai.

Is hum server block lever par karenge. Ab simply is command se hum Server block level ki configuration file ko open kar lenge.

♦ sudo nano /etc/nginx/sites-available/default

 

Default me bina change ke Nginx server block kuch is tarah se dikhai deta hai.

/etc/nginx/sites-available/default
server {
listen 80 default_server;
listen [::]:80 default_server;

root /var/www/html;
index index.html index.htm index.nginx-debian.html;

server_name _;

location / {
try_files $uri $uri/ =404;
}
}

 

Apni site ke lie hume is file me kuch changes karne hote hain
  • First of all hume apne index directive me index.php first value ke roop me sabse aage add karna hai.
  • Apne Server_name ko change kar ke hum use apne server ke domainname ya fir Server ip address ko point kar sakte hain.
  • Actual PHP processing ke lie hume kuch comments ke aage se (#) hata ke use uncomment  me change kar dena hai jo PHP request ko handle karta hai. Iske lie bataye gae har lines se (#) ko remove kar de. Ye hain  location ~\.php$ location block, fastcgi-php.conf snippet, jo socket php-fpm se associated hota hai.
  • Nginx .htaccess spport nahi karta hai isilie hum uske sath jude hue location block ko bhi uncomment kar denge. 

Ab sari configuration me change hone ke baad is tarah ka file dikhai dega. Jo changes humne kiye use hum red color se pehchan sakte hain.

/etc/nginx/sites-available/default
  server {
      listen 80 default_server;
      listen [::]:80 default_server;

      root /var/www/html;
      index index.php index.html index.htm index.nginx-debian.html;

      server_name server_domain_or_IP;

      location / {
             try_files $uri $uri/ =404;
      }

       location ~ \.php$ {
              include snippets/fastcgi-php.conf;
              fastcgi_pass unix:/run/php/php7.0-fpm.sock;
      }

      location ~ /\.ht {
            deny all;
      }

  }

 

Ye sari change agar apne sahi se kar liya hai to Ctrl+X press kare aur Yes press kar ke enter button pe click kar le. 

Ab apne kiye configuration file me kiye gae changes ke errors check karne ke lie ye command type kar ke enter kare.

♦ sudo nginx -t

 

Agar apko koi bhi error show hota hai iska matlab ki configuration karne me koi galti hui hai. Aap dubara is file ko open kar ke sahi kar le.

Jab ye koi error na show kare to aap ise reload kar ke changes ko implement karne ke lie Nginx ko reload kar le.

♦ sudo systemctl reload nginx

Step 5. Create a PHP file to Test Configuration

Ab jab humne LEMP stack ko puri tarah se set up kar liya hai to ise hum test kar ke dekhenge ki Nginx correctly kaam kar raha hai ya nahi.

Check karne ke lie hum ek PHP page bana kar browser me test karenge. Hum ab ek naya file open karenge jise info.php bolte hain.

♦ sudo nano /var/www/html/info.php

 

Ye file open hone ke baad isme type ya fir Paste karke in 2 lines ke codes ko add kar le. Ye valid PHP codes hain jo hamare server ke bare me information ko return karta hai. 

/var/www/html/info.php
<?php
phpinfo();

 

File ke andar 2 lines ke codes ko  copy kar ke mouse ke right click se paste kar lena hai. Iske baad Ctrl+X press kar ke Yes kar ke save kar lena hai aur file ko close kar le.

Ab aap is page ko apne browser me open kar ke dekh sakte hain. Iske lie apko browser ke address bar me jakar server ip address ke baad /php.info add kar ke enter karna hai. 

http://server_domain_or_IP/info.php

 

Aa yahan par PHP file ki is tarah ki page dekhoge jisme apke server ke bare me information hogi.

phpinfo

Agar browser me is tarah ka page open hua hai to fir apne PHP Processing ko Nginx ke sath successfully configure kar liya hai.

Ab Nginx page ko correctly render kar le raha hai. Ye verify karne ke baad hum is file ko delete kar denge. Kyu ki ye file hamari bahut si information rakhta hai jisse koi bhi unauthorized user access kar ke andar aa sakta hai. Isilie behtar hai is file ko delete hi kar de. jab bhi kabhi apko jarurat ho is file ko dubara create kar ke aap use kar sakte hain.

Abhi ke lie is file ko delete karne ke lie ye command type kare.
♦ sudo rm /var/www/html/info.php

 

Ab aapne successfully Ubuntu 16.04 par LEMP Stack Nginx, MySQL, PHP install kar liya hai. Ab aap is par CMS platform yani ki wordpress install kar sakte hain.

LEMP ke baad wordpress install karne ke bare me agle post me padhen.

Friends agar apko ye post achi lagi ho to ise jyada se jyada facebook, twitter, instagram aur google plus me share kare.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

CommentLuv badge

%d bloggers like this: