首页 > 系统相关 >8_How to install LEMP stack on Ubuntu VPS_

8_How to install LEMP stack on Ubuntu VPS_

时间:2023-06-07 22:12:10浏览次数:54  
标签:VPS How sudo server Nginx install Copy LEMP

 

地址:https://www.codewithharry.com/blogpost/lemp-stack-on-ubuntu-20/

 

 

How to install LEMP stack (Linux, Nginx, MySQL, PHP) on Ubuntu 20.04

In this tutorial, we will install the LEMP stack on the ubuntu 20 based server. LEMP consists of Linux, Nginx(pronounced as Engine-x), MySQL for database, and PHP as a backend programming language. Together you can use this combination to host a set of high-performing sites on a single server. I will assume that you have finished the initial server setup as described here on your ubuntu server before installing the LEMP stack on Ubuntu 20.04.

 

 

 

If you are already using some other web server like apache2, it is recommended that you uninstall it or rebuild your server from scratch using the console provided by your hosting provider. DigitalOcean gives a convenient way to achieve this in its dashboard.

Let's install the LEMP stack now. Follow the steps below:

Step 1 - Update the server's package index

Update the server's package index by executing the command below:

sudo apt update

 

 

 

Step 2 - Install Nginx

Install Nginx using the command below:

sudo apt install nginx

Step 3 - Allow Nginx through the firewall

Allow Nginx through the firewall using the command below:

sudo ufw app list
sudo ufw allow 'Nginx Full'

You can now go to your server's IP address to check if Nginx is installed successfully. You should see a page like this:

 

 

 

Step 4 - Installing MySQL

Let's install MySQL using the command below:

sudo apt install mysql-server

This command will install MySQL, and you will be able to see the console by entering "sudo mysql" in the terminal.

sudo mysql

Step 5 - Installing PHP

The last component in the LEMP stack is PHP. Let's install it using the command below:

sudo apt install php-fpm php-mysql

If you want to host a PHP website, you will have to copy your files to '/var/www/html' and modify the file located at '/etc/nginx/sites-available/default' to look something like this:

 

 

 

these are the additional lines added inside the "location ~ \.php$ {" block

include fastcgi_params;
fastcgi_index index.php;
fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;

Here is a sample index.php site for you to try out:

<?php
phpinfo();
?>

Once you visit the IP of your droplet, you will see a page like this:

You will now be able to use PHP with Nginx. Happy coding!

 

 

 

 

标签:VPS,How,sudo,server,Nginx,install,Copy,LEMP
From: https://www.cnblogs.com/hechunfeng/p/17464718.html

相关文章

  • 9_How to install phpMyAdmin on Nginx (in 5 minutes)
     地址:https://www.codewithharry.com/blogpost/install-phpmyadmin-ubuntu-nginx/  HowtoinstallPhpMyAdminonUbunturunningNginx(LEMPstack)Inthispost,wewillseehowtoinstallphpMyAdminonserversrunningNginx.Followthestepsbelow:Step1-......
  • 10_How deploy a Django application using Nginx & Gunicorn in Production
     地址:https://www.codewithharry.com/blogpost/django-deploy-nginx-gunicorn/  HowtohostDjangoApplicationusinggunicorn&nginxinProductionInthispost,wewillseehowtousenginxwithgunicorntoservedjangoapplicationsinproduction. Dj......
  • 3_Installing Linux, Apache, MySQL, PHP (LAMP) Stack on Ubuntu 20.04
      地址:https://www.codewithharry.com/blogpost/lamp-stack-ubuntu-20-04/ InstallingLAMPstackonUbuntu20.04in5MinutesThispostwillexplainhowtoinstallLAMPstackonUbuntu20.04.LAMPstackconsistsofthefollowingcomponents:Linux-AnyLi......
  • 4_How to Host Multiple Websites on One Server
     地址:https://www.codewithharry.com/blogpost/host-multiple-websites-ubuntu-vps/  HowtoHostMultipleWebsitesonUbuntuVPS?Anapache2webserverprovidesrobustnessandscalabilityforhostingmultiplewebsitesonyourUbuntuVPS.Thismeansyoucan......
  • How do you display code snippets in MS Word preserving format and syntax highlig
    HowdoyoudisplaycodesnippetsinMSWordpreservingformatandsyntaxhighlighting?回答1Hereisthebestway,forme,toaddcodeinsideword:GotoInserttab,Textsection,clickObjectbutton(it'sontheright)ChooseOpenDocumentTextwhic......
  • PyInstaller 完美打包 Python 脚本,输出结构清晰、便于二次编辑的打包程序
    引入问题如果我要写一个Python项目,打包成exe运行(方便在没有Python的电脑上使用),我需要打包出的根目录结构美观,没有多余的、杂乱的依赖文件在那里碍眼,而且需要在发现bug时,我还需要能够修改里面的代码后,无需再次打包,就能正常运行,该怎么做呢?就以一个Hello项目为例,记一下我......
  • vue3 条件判断语句及v-if与v-show 区别
    <template> <divv-if="type==='a'">aaa</div> <divv-else-if="type==='b'">bbb</div> <divv-else>ccc</div>  <divv-show="flag">111</div> </template>......
  • Install Elasticsearch 2.x on CentOS 6 by rpm
     http://techieroop.com/install-elasticsearch-2-x-on-centos-6/ ThisarticlewillcoverinstallElasticsearch2.xversiononCentOS6.AlsoguidelinetochangetoDefaultClusterandIndexsettingsinElasticsearch2.x.SoLet’sstartwithprerequisitesPrer......
  • [刷题笔记] Luogu P2895 Meteor Shower S
    ProblemSolution显然bfs,只不过有了限定条件,有实时的流星雨这里提供两种做法:Solution1这也是我一开始的做法模拟实时流星,由于bfs是按层搜的,是严格按照时间递增搜的,故可以模拟实时放流星。需要注意放流星的时间,如果第\(t\)秒有流星,则该秒不可以走,需要在每一秒前放流星。那......
  • 1、KVM安装部署及virt-manager图形化工具创建安装虚拟机、命令行工具virt-install创建
    KVM安装部署KVM做单机管理虚拟机,Openstack集群管理虚拟机docker单机管理容器,k8s集群管理容器宿主机环境准备在vmware安装linux系统,并在设置中开启虚拟化CPU开启虚拟化一:开启虚拟化引擎两项内容二:提高内存和处理器至8G验证开启虚拟化grep-Em1"vmx|svm"/proc/cpuinfoInt......