Script to install LEMP stack in Ubuntu 16

Share this post to your friends !

WriteBash - In this article, I will introduce to you the script to install LEMP stack in Ubuntu 16.

Using this script can save you some time.

My lab environment

I use a virtual machine Ubuntu 16.04 with the following configuration.

  1. OS: Ubuntu 16.04.5 LTS 64bit.
  2. IP: Example i use You can change the information in the script to your server IP. Simply Ctrl + F in the script with my IP and replace it with your IP address.
  3. RAM: 1 GB.
  4. HDD: 10 GB.
  5. CPU: 1 vCPU.
  6. User: root

Packages in the LEMP stack

In this script, I will install the some packages as follows.

  1. Nginx: version 1.14.2.
  2. MariaDB: version 10.3.13.
  3. PHP: version

Use this script to install LEMP stack in Ubuntu 16

Below are the steps you will take to use this script.

script-to-install-lemp-stack-in-ubuntu-16 Script to install LEMP stack in Ubuntu 16
Install LEMP stack in Ubuntu 16.04.

Step 1: Download the script with the following command.

# wget -O

Step 2: Give the script permission to execute.

# chmod 700

And step 3: Execute the script.

# ./

During the installation process, you will see the following message.

Configuring mariadb-server-10.3

While not mandatory, it is highly recommended that you set a password for the MariaDB administrative "root" user.

If this field is left blank, the password will not be changed.

New password for the MariaDB "root" user:

This is the message when installing MariaDB, it requires you to set the root password. You can leave it blank and type Enter.

WARNING: add-apt-repository is broken with non-UTF-8 locales, see for workaround:

# LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
 More info:
Press [ENTER] to continue or ctrl-c to cancel adding it

This is the notice when adding PHP 7.3 repository, you just need to press Enter to agree to add the repository to the server.

Configuring tzdata

Please select the geographic area in which you live. Subsequent configuration questions will narrow this down by presenting a list of cities, representing the time zones in which they are located.

  1. Africa  2. America  3. Antarctica  4. Australia  5. Arctic  6. Asia  7. Atlantic  8. Europe  9. Indian  10. Pacific  11. SystemV  12. US  13. Etc
Geographic area: 6

Please select the city or region corresponding to your time zone.

  1. Aden      8. Atyrau    15. Bishkek     22. Dhaka      29. Hebron       36. Jayapura   43. Khandyga      50. Magadan       57. Omsk        64. Qyzylorda  71. Singapore      78. Thimphu        85. Vientiane
  2. Almaty    9. Baghdad   16. Brunei      23. Dili       30. Ho_Chi_Minh  37. Jerusalem  44. Kolkata       51. Makassar      58. Oral        65. Rangoon    72. Srednekolymsk  79. Tokyo          86. Vladivostok
  3. Amman     10. Bahrain  17. Chita       24. Dubai      31. Hong_Kong    38. Kabul      45. Krasnoyarsk   52. Manila        59. Phnom_Penh  66. Riyadh     73. Taipei         80. Tomsk          87. Yakutsk
  4. Anadyr    11. Baku     18. Choibalsan  25. Dushanbe   32. Hovd         39. Kamchatka  46. Kuala_Lumpur  53. Muscat        60. Pontianak   67. Sakhalin   74. Tashkent       81. Ujung_Pandang  88. Yangon
  5. Aqtau     12. Bangkok  19. Chongqing   26. Famagusta  33. Irkutsk      40. Karachi    47. Kuching       54. Nicosia       61. Pyongyang   68. Samarkand  75. Tbilisi        82. Ulaanbaatar    89. Yekaterinburg
  6. Aqtobe    13. Barnaul  20. Colombo     27. Gaza       34. Istanbul     41. Kashgar    48. Kuwait        55. Novokuznetsk  62. Qatar       69. Seoul      76. Tehran         83. Urumqi         90. Yerevan
  7. Ashgabat  14. Beirut   21. Damascus    28. Harbin     35. Jakarta      42. Kathmandu  49. Macau         56. Novosibirsk   63. Qostanay    70. Shanghai   77. Tel_Aviv       84. Ust-Nera
Time zone: 30

This is the message during the installation of PHP 7.3, it will ask about the time zone to set up for your server.

You just need to select the number corresponding to your geographic area.


Installing LEMP stack will last for about 10 minutes, you just need to wait for a while.

With this script, you don’t need to remember every command, everything is fast and simple.

If you liked this article, then please subscribe to our YouTube Channel for more video tutorials. You can also find us on Twitter and Facebook.

Share this post to your friends !
If you appreciate what we share in this blog, you can support us by:
  1. Stay connected to: Facebook | Twitter | Google Plus | YouTube
  2. Subscribe email to recieve new posts from us: Sign up now.
  3. Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
  4. Become a Supporter - Make a contribution via PayPal.
  5. Support us by purchasing Ribbon Lite Child theme being using on this website.

We are thankful for your support.

single post bottom banner
«« »»

Got something to say? Join the discussion

Please keep in mind that all comments are subject to our Comment Policy. Your email address will not be published.
This site uses Akismet to reduce spam. Learn how your comment data is processed.