{"id":6884,"date":"2024-08-23T08:16:32","date_gmt":"2024-08-23T08:16:32","guid":{"rendered":"https:\/\/blog.ssdnodes.com\/blog\/?p=6884"},"modified":"2025-05-15T15:45:58","modified_gmt":"2025-05-15T15:45:58","slug":"how-to-install-lemp-on-ubuntu-24-04","status":"publish","type":"post","link":"https:\/\/www.ssdnodes.com\/blog\/how-to-install-lemp-on-ubuntu-24-04\/","title":{"rendered":"Simple Guide \u2013 How to Install LEMP on Ubuntu 24.04"},"content":{"rendered":"<p>In this simple tutorial, I will walk you through how to install LEMP on Ubuntu 24.04 in a few steps. I have tested all the instructions on a brand new <a href=\"https:\/\/ssdnodes.com\/\" target=\"_blank\" rel=\"noopener\">Ubuntu 24.04 server<\/a> to make sure all the commands are working and ensure that the LEMP installation works as expected.<\/p>\n<h2>What is LEMP in Linux?<\/h2>\n<p>The LEMP (<a href=\"https:\/\/www.ssdnodes.com\/blog\/cheap-linux-vps-comparison-report\/\">Linux<\/a>, Nginx, MySQL, PHP) stack in Linux refers to a toolkit comprising of Linux as the operating system, Nginx (pronounced <strong>E<\/strong>ngine-x) as the web server, MySQL (or MariaDB) as the database system, and PHP (or Perl\/Python) as the scripting language. These components are commonly used for creating web applications.<\/p>\n<h2>What is a LEMP Stack Used for?<\/h2>\n<p>A LEMP stack is used for building and deploying dynamic PHP-based web applications. It combines Linux as the operating system, Nginx as the web server, MySQL for database management, and PHP (or Perl\/Python) for server-side scripting. This stack offers a robust and efficient environment for developing scalable and high-performance web applications.<\/p>\n<h2>What Does LEMP Stack Stand for?<\/h2>\n<p><strong>LEMP<\/strong> stands for \"Linux, Nginx, MySQL, and PHP.\" Together, these software technologies can be used to create a fully-functional web application<\/p>\n<ul>\n<li><strong>L<\/strong>inux is the most popular, secure and open source operating system used in web servers.<\/li>\n<li><strong>A<\/strong>pache HTTP Server is a free and open-source web server that delivers web content through the internet.<\/li>\n<li><strong>M<\/strong>ySQL is a relational database engine that allows you to store data and manage it.<\/li>\n<li><strong>P<\/strong>HP is a widely used open source and general purpose server side scripting language used mainly in web development to create dynamic websites and applications.<\/li>\n<\/ul>\n<p><strong>NOTE:<\/strong> In this tutorial, we\u2019ll be using MariaDB\u2014 a backward compatible, drop-in replacement of the MySQL\u00ae Database Server. MariaDB was designed to maintain the same functionality while introducing new features and improvements.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-10477 size-full\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/LEMP-article-.jpg\" alt=\"install lemp on ubuntu 24.04\" width=\"600\" height=\"400\" srcset=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/LEMP-article-.jpg 600w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/LEMP-article--300x200.jpg 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<h2>Installing LEMP on Ubuntu 24.04<\/h2>\n<p>To install LEMP on Ubuntu 24.04, you'll first update the Ubuntu package index, then install the MariaDB database server and secure it, install Nginx, then install PHP and configure the Nginx web server to handle PHP processing.<\/p>\n<h2>Prerequisites for Installing LEMP on Ubuntu 24.04<\/h2>\n<ul>\n<li>Familiarity with the Linux command line.<\/li>\n<li>An Ubuntu 24.04 server with a non-root user with\u00a0<code>sudo<\/code>\u00a0privileges.\u00a0If you haven't noticed, we offer top-tier Ubuntu servers at the globe's best prices. Check out our <a href=\"https:\/\/www.ssdnodes.com\/pricing\/\">offerings<\/a> and get ready to be amazed \ud83e\udd2f.<\/li>\n<\/ul>\n<p>Check out our\u00a0<a href=\"https:\/\/www.ssdnodes.com\/blog\/tutorial-setting-up-and-securing-ssh-based-authentication\/\">How to access your server using SSH<\/a>\u00a0guide to learn how to access your server and create a\u00a0<code>sudo<\/code>\u00a0user.<\/p>\n<h3>Note<\/h3>\n<p>Want to skip these time-consuming technical steps? Our engineers have created a ready-to-use <strong>1-click<\/strong> LEMP application. Just select one of <a href=\"https:\/\/ssdnodes.com\/\" target=\"_blank\" rel=\"noopener\">our servers<\/a>, choose <strong>LAMP<\/strong> from the <strong>App<\/strong> menu during checkout, and LEMP will be set up in minutes. However, if you prefer to learn how to do it yourself, keep reading.<\/p>\n<h2>Step 1: Update The Package Cache<\/h2>\n<p>Start by updating the packages in the package manager cache to the latest available versions using the following command:<\/p>\n<pre><code>sudo apt update<\/code><\/pre>\n<h2>Step 2: Install the MariaDB Database Server<\/h2>\n<p>After updating our package cache, we will now install the MariaDB database server. We'll use MariaDB instead of MySQL because it includes more features and supports new storage engines, in addition to its high performance.<\/p>\n<p>To install MariaDB, execute the following command:<\/p>\n<pre><code>sudo apt install mariadb-server mariadb-client<\/code><\/pre>\n<p>Tap the <strong>y<\/strong> key then <strong>Enter<\/strong> to continue the installation.<\/p>\n<p>In the preceding command, you install two packages:<\/p>\n<ul>\n<li><code>mariadb-server<\/code>: The MariaDB database server which actually stores data.<\/li>\n<li><code>mariadb-client<\/code>: The MariaDB database client which allows you to interact with and manage the database server via the command line.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-10450\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/install-mariadb-1024x411.webp\" alt=\"install lemp on ubuntu: mariadb\" width=\"600\" height=\"241\" srcset=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/install-mariadb-1024x411.webp 1024w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/install-mariadb-300x120.webp 300w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/install-mariadb-768x308.webp 768w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/install-mariadb.webp 1426w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>Once the installation is finished, verify that the MariaDB database server is running properly by executing the following command to check out the MariaDB service status:<\/p>\n<pre><code>sudo service mariadb status<\/code><\/pre>\n<p>The output should show that the service is enabled and running:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-10451\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/mariadb-status-1024x523.webp\" alt=\"lemp stack installation: mariadb status\" width=\"600\" height=\"306\" srcset=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/mariadb-status-1024x523.webp 1024w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/mariadb-status-300x153.webp 300w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/mariadb-status-768x392.webp 768w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/mariadb-status.webp 1426w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>Here, you can see that the service is active and running in the line <code>\"Active: active (running) ...\"<\/code>.<\/p>\n<h3>Ensure That MariaDB Starts at Boot<\/h3>\n<p>To make sure that the MariaDB database server starts with the system at boot, use the <code>enable<\/code> subcommand of the <code>systemctl<\/code> command. To do so, execute the following command:<\/p>\n<pre><code>sudo systemctl enable mariadb.service<\/code><\/pre>\n<p>You should receive the following output:<\/p>\n<pre><code>Synchronizing state of mariadb.service with SysV service script with \/lib\/systemd\/systemd-sysv-install.\r\nExecuting: \/lib\/systemd\/systemd-sysv-install enable mariadb<\/code><\/pre>\n<h3>Securing The MariaDB Database Server<\/h3>\n<p>MariaDB comes with some unsafe default settings which may expose your database server to dangerous security vulnerabilities. It's recommended that you run a security script that comes with MariaDB to strengthen your database server and minimize the risk of database intrusions or breaches.<\/p>\n<p>To secure your MariaDB database server, execute the following command, where you will be presented with seven prompts:<\/p>\n<p>First, run the script:<\/p>\n<pre><code>sudo mysql_secure_installation<\/code><\/pre>\n<p>You\u2019ll be asked for your current root password:<\/p>\n<pre><code>In order to log into MariaDB to secure it, we'll need the current\r\npassword for the root user. If you've just installed MariaDB, and\r\nhaven't set the root password yet, you should just press enter here.\r\n\r\nEnter current password for root (enter for none): <\/code><\/pre>\n<p>Tap <strong>Enter<\/strong>.<\/p>\n<p>Next, you'll be asked whether you want to use the <code>unix_socket<\/code> authentication method:<\/p>\n<pre><code>OK, successfully used password, moving on...\r\n\r\nSetting the root password or using the unix_socket ensures that nobody\r\ncan log into the MariaDB root user without the proper authorisation.\r\n\r\nSwitch to unix_socket authentication [Y\/n] <\/code><\/pre>\n<p>Tap <strong>Y<\/strong> to enable <code>unix_socket<\/code> authentication for better security.<\/p>\n<p>The <code>unix_socket<\/code> authentication method uses the Unix user's credentials instead of a password to connect to the MariaDB account with the same username, which makes it a passwordless security mechanism, and because it depends on the user's credentials, it cannot be used to grant multiple Unix users access to a single MariaDB user account. With this, access to your MariaDB database server is limited to the Unix user, adding a security layer for your MariaDB account and preventing attackers from brute forcing or taking advantage of an accidental password leak.<\/p>\n<p>The <code>unix_socket<\/code> authentication method is particularly strong due to the default sturdiness of Unix user security in preventing remote access. However, unskilled administration of your Unix user system may expose dangerous vulnerabilities. So, keep a wide and open eye on potential Unix user security issues such as weak passwords or accidental password exposure, excessive <code>sudo<\/code> permissions that allow users to execute commands of a different Unix user, scripts of other users executed by your MariaDB Unix user, running unsafe scripts, or weak remote access security.<\/p>\n<p>Next, you'll be asked to change the root password:<\/p>\n<pre><code>Enabled successfully!\r\nReloading privilege tables..\r\n ... Success!\r\n\r\nChange the root password? [Y\/n] <\/code><\/pre>\n<p>Tap <strong>Y<\/strong> to set a new password for root, and re-enter it for validation.<\/p>\n<p>Next, you'll be asked to remove anonymous users:<\/p>\n<pre><code>Change the root password? [Y\/n] y\r\nNew password: \r\nRe-enter new password: \r\nPassword updated successfully!\r\nReloading privilege tables..\r\n ... Success!\r\n\r\nBy default, a MariaDB installation has an anonymous user, allowing anyone\r\nto log into MariaDB without having to have a user account created for\r\nthem.  This is intended only for testing, and to make the installation\r\ngo a bit smoother.  You should remove them before moving into a\r\nproduction environment.\r\n\r\nRemove anonymous users? [Y\/n] <\/code><\/pre>\n<p>Tap <strong>Y<\/strong> to remove the anonymous users that come with your MariaDB installation.<\/p>\n<p>Next, you\u2019ll be asked whether you want to disallow remote root logins:<\/p>\n<pre><code>Remove anonymous users? [Y\/n] y\r\n ... Success!\r\n\r\nNormally, root should only be allowed to connect from 'localhost'.  This\r\nensures that someone cannot guess at the root password from the network.\r\n\r\nDisallow root login remotely? [Y\/n] <\/code><\/pre>\n<p>Tap <strong>Y<\/strong> to disable remote root login.<\/p>\n<p>Next, you\u2019ll be asked whether you want to remove the test database that comes with your MariaDB installation:<\/p>\n<pre><code>Disallow root login remotely? [Y\/n] y\r\n ... Success!\r\n\r\nBy default, MariaDB comes with a database named 'test' that anyone can\r\naccess.  This is also intended only for testing, and should be removed\r\nbefore moving into a production environment.\r\n\r\nRemove test database and access to it? [Y\/n] <\/code><\/pre>\n<p>Tap <strong>Y<\/strong> to remove your MariaDB test database and disable access to it.<\/p>\n<p>In order for the changes you've made to take effect, you\u2019ll be asked to reload your MariaDB privilege tables:<\/p>\n<pre><code>Remove test database and access to it? [Y\/n] y\r\n - Dropping test database...\r\n ... Success!\r\n - Removing privileges on test database...\r\n ... Success!\r\n\r\nReloading the privilege tables will ensure that all changes made so far\r\nwill take effect immediately.\r\n\r\nReload privilege tables now? [Y\/n] <\/code><\/pre>\n<p>Tap <strong>Y<\/strong> to reload your MariaDB privilege tables. This will ensure that your changes will take effect immediately.<\/p>\n<pre><code>Reload privilege tables now? [Y\/n] y\r\n ... Success!\r\n\r\nCleaning up...\r\n\r\nAll done!  If you've completed all of the above steps, your MariaDB\r\ninstallation should now be secure.\r\n\r\nThanks for using MariaDB!<\/code><\/pre>\n<p>With this, your MariaDB installation is more secure than before, provided that you follow security best practices.<\/p>\n<p>You now have the MariaDB database server installed, and you\u2019re ready to store and manage your data. Next, you\u2019ll need to serve the data you store using an HTTP server, which is the NGINX web server in the LEMP stack.<\/p>\n<h2>Step 3: Install NGINX<\/h2>\n<p>After installing and securing the MariaDB database server, the next step in our LEMP stack installation is installing the NGINX HTTP server, which serves web content.<\/p>\n<p>Use <code>apt<\/code> to install the NGINX web server using the following command:<\/p>\n<pre><code>sudo apt install nginx<\/code><\/pre>\n<p>You\u2019ll be asked to confirm the installation. Tap the y key then Enter to continue.<\/p>\n<p>Once the installation is finished, check NGINX\u2019s version to confirm that it was properly installed using the following command:<\/p>\n<pre><code>sudo nginx -v<\/code><\/pre>\n<p>You should receive an output that looks as follows:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-10454\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/sudo-nginx-v-1024x157.webp\" alt=\"lemp on ubuntu: nginx version\" width=\"600\" height=\"92\" srcset=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/sudo-nginx-v-1024x157.webp 1024w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/sudo-nginx-v-300x46.webp 300w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/sudo-nginx-v-768x117.webp 768w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/sudo-nginx-v.webp 1426w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>Check NGINX\u2019s status with the following command:<\/p>\n<pre><code>sudo systemctl status nginx<\/code><\/pre>\n<p>The output should show that the Nginx service is enabled and running:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-10452\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/nginx-status-1024x279.webp\" alt=\"Nginx status\" width=\"600\" height=\"163\" srcset=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/nginx-status-1024x279.webp 1024w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/nginx-status-300x82.webp 300w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/nginx-status-768x209.webp 768w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/nginx-status.webp 1426w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<h3>Ensure That NGINX Starts at Boot<\/h3>\n<p>To make sure that the NGINX web server starts with the system at boot, use the <code>enable<\/code> subcommand of the <code>systemctl<\/code> command. To do so, execute the following command:<\/p>\n<pre><code>sudo systemctl enable nginx.service<\/code><\/pre>\n<p>You should receive the following output:<\/p>\n<pre><code>Synchronizing state of nginx.service with SysV service script with \/lib\/systemd\/systemd-sysv-install.\r\nExecuting: \/lib\/systemd\/systemd-sysv-install enable nginx<\/code><\/pre>\n<p>You now have NGINX installed. Next, you\u2019ll install the PHP language.<\/p>\n<h2>Step 4: Install PHP<\/h2>\n<p>With MariaDB you can store and manage data, and the NGINX HTTP server allows you to serve it. You now need to install PHP to dynamically display data, and allow users to interact with your web service via easy-to-use web forms or API calls.<\/p>\n<p>Use the following command to install the main PHP package, along with basic PHP packages that allow you to interact with your database and HTTP server:<\/p>\n<pre><code>sudo apt install php-fpm php-mysql php-xml php-mbstring<\/code><\/pre>\n<p>When prompted, tap the <strong>y<\/strong> key then <strong>Enter<\/strong> to continue the installation.<\/p>\n<p>In the preceding command, you install the following packages:<\/p>\n<ul>\n<li><code>php-fpm<\/code>: A package that allows NGINX to handle PHP processes and serve websites written in PHP.<\/li>\n<li><code>php-mysql<\/code>: A package that allows PHP to communicate with MySQL-based databases such as MariaDB.<\/li>\n<li><code>php-xml<\/code>: A package that provides a DOM, SimpleXML, WDDX, XML, and XSL module for PHP.<\/li>\n<li><code>php-mbstring<\/code>: A package that provides the MBSTRING module for PHP, which is used to manage non-ASCII strings.<\/li>\n<\/ul>\n<p>The main PHP language package will be installed automatically as part of the installation process as a dependency.<\/p>\n<p>To ensure PHP was successfully installed, check its version using the following command:<\/p>\n<pre><code>php -v<\/code><\/pre>\n<p>You should receive an output similar to the following:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-10453\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/php-v-1024x248.webp\" alt=\"install lemp on ubuntu: php version\" width=\"600\" height=\"146\" srcset=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/php-v-1024x248.webp 1024w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/php-v-300x73.webp 300w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/php-v-768x186.webp 768w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/08\/php-v.webp 1426w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>This means that you\u2019ve successfully installed PHP.<\/p>\n<h2>Step 5: Configure NGINX to Handle PHP Processing<\/h2>\n<p>After we've finished installing all the components of the LEMP stack, we will now configure NGINX so it can serve PHP-based websites.<\/p>\n<p>By default, NGINX is configured to serve files out of a root web directory located at <code>\/var\/www\/html<\/code>. This default configuration is suitable for small single-site web servers, but hosting multiple sites using this method will quickly become unmanageable and cumbersome. Instead, it is best to create a root web directory for each site you\u2019d like to host on your web server, while leaving the default <code>\/var\/www\/html<\/code> root web directory to be served when a user requests a site that doesn\u2019t exist.<br \/>\nCreate the root web directory for your site as follows, replacing <code>mysite<\/code> with your site\u2019s name:<\/p>\n<pre><code>sudo mkdir \/var\/www\/mysite<\/code><\/pre>\n<p>Next, open a new configuration file in NGINX\u2019s <code>sites-available<\/code> directory, which is a directory that contains configuration for each of your sites. Again, make sure to replace <code>mysite<\/code> with your site\u2019s name:<\/p>\n<pre><code>sudo nano \/etc\/nginx\/sites-available\/mysite<\/code><\/pre>\n<p>Paste into it the following:<\/p>\n<pre><code>server {\r\n    listen 80;\r\n    server_name mysite www.mysite;\r\n    root \/var\/www\/mysite;\r\n\r\n    index index.html index.htm index.php;\r\n\r\n    location \/ {\r\n        try_files $uri $uri\/ =404;\r\n    }\r\n\r\n    location ~ .php$ {\r\n        include snippets\/fastcgi-php.conf;\r\n        fastcgi_pass unix:\/var\/run\/php\/php8.3-fpm.sock;\r\n     }\r\n}<\/code><\/pre>\n<p><strong>Note: The preceding NGINX configuration is called a <em>server block<\/em>.<\/strong><\/p>\n<p>Remember to replace <code>mysite<\/code> with your site\u2019s name.<\/p>\n<p>If you don\u2019t have a domain name, you can replace the line <code>server_name mysite www.mysite;<\/code> with just <code> server_name your_IP_address;<\/code>, where <code>your_IP_address<\/code> is your server\u2019s IP address.<\/p>\n<p>Save the file by pressing <strong>CTRL+x<\/strong> and then <strong>y<\/strong> and Enter to confirm.<\/p>\n<p>In the preceding configuration file, you set up the following:<\/p>\n<ul>\n<li><code>listen<\/code>:The port number NGINX will listen on. Here, you set its value to <code>80<\/code>, which is the port number assigned to HTTP.<\/li>\n<li><code>server_name<\/code>: The domain names or IP addresses this server block configuration should respond for. Remember to replace <code>mysite<\/code> with your site\u2019s name. If you don\u2019t have a domain name, you can replace the line <code>server_name mysite www.mysite;<\/code> with just <code>server_name your_IP_adress;<\/code>, where <code>your_IP_adress<\/code> is your server\u2019s IP address.<\/li>\n<li><code>root<\/code>: The root web directory, also known as the <em>document root<\/em>, that stores the files served by your website. Here, you set its value to <code>\/var\/www\/mysite<\/code>, which is the root web directory we created earlier, so make sure to set the proper value in your case.<\/li>\n<li><code>index<\/code>: The order in which NGINX will prioritize index files for your website. Here, you set the order as follows: <code>index.html index.htm index.php<\/code>, which means that when requesting the index page, NGINX will initially look for a file called <code>index.html<\/code> in your root web directory and serve it, if no file matches that filename, it will look for a file called <code>index.htm<\/code> and serve it instead. Otherwise, it will look for a PHP file called <code>index.php<\/code>.<\/li>\n<li><code>location \/<\/code>: The main location block, which includes a <code>try_files<\/code> directive, and it allows NGINX to route HTTP requests to the correct location within the file system. It looks for files or directories matching a URL request. If no resource matches the HTTP request, NGINX will return a <code>404 Not Found<\/code> HTTP error.<\/li>\n<li><code>location ~ .php$<\/code>: A location block that handles PHP processing. It tells NGINX to handle any HTTP request with a URL that ends with <code>.php<\/code> with the directives included in this location block. This effectively points NGINX to the <code>fastcgi-php.conf<\/code> configuration file and the <code>php8.3-fpm.sock<\/code> file, which declares the socket that is associated with <code>php-fpm<\/code>.<\/li>\n<\/ul>\n<h3>Activate NGINX Configuration<\/h3>\n<p>Now that you\u2019ve set up an NGINX server block configuration for your site, you need to activate it. You can do this by linking your <code>mysite<\/code> configuration file to the configuration file from NGINX\u2019s <code>sites-enabled<\/code> directory:<\/p>\n<pre><code>sudo ln -s \/etc\/nginx\/sites-available\/mysite \/etc\/nginx\/sites-enabled<\/code><\/pre>\n<p>To check that your configuration file has been properly linked to NGINX\u2019s <code>sites-enabled<\/code> directory, run the following command:<\/p>\n<pre><code>sudo ls -l \/etc\/nginx\/sites-enabled<\/code><\/pre>\n<p>You should receive an output that\u2019s similar to the following:<\/p>\n<pre><code>total 0\r\nlrwxrwxrwx 1 root root 34 Aug  4 09:43 default -&gt; \/etc\/nginx\/sites-available\/default\r\nlrwxrwxrwx 1 root root 33 Aug  4 10:07 mysite -&gt; \/etc\/nginx\/sites-available\/mysite<\/code><\/pre>\n<p>Here, you can see that your <code>sites-available\/mysite<\/code> configuration file has been successfully linked.<br \/>\nNext, unlink the default NGINX configuration from the <code>\/sites-enabled\/<\/code> directory. This forces NGINX to use your <code>mysite<\/code> configuration instead of the default configuration:<\/p>\n<pre><code>sudo unlink \/etc\/nginx\/sites-enabled\/default<\/code><\/pre>\n<p>To check that the default NGINX configuration has been properly unlinked from the <code>sites-enabled<\/code> directory, run the following command:<\/p>\n<pre><code>sudo ls -l \/etc\/nginx\/sites-enabled<\/code><\/pre>\n<p>You should receive an output that\u2019s similar to the following:<\/p>\n<pre><code>total 0\r\nlrwxrwxrwx 1 root root 33 Aug  4 10:07 mysite -&gt; \/etc\/nginx\/sites-available\/mysite\r\n<\/code><\/pre>\n<p>Here, you can see that the <code>default<\/code> configuration symlink is no longer in the <code>sites-enabled<\/code> directory, which means that it has been successfully unlinked.<br \/>\nNext, test your configuration\u2019s syntax using the following command:<\/p>\n<pre><code>sudo nginx -t<\/code><\/pre>\n<p>You should receive an output that\u2019s similar to the following:<\/p>\n<pre><code>nginx: the configuration file \/etc\/nginx\/nginx.conf syntax is ok\r\nnginx: configuration file \/etc\/nginx\/nginx.conf test is successful<\/code><\/pre>\n<p>This output shows that there are no errors in the configuration file.<\/p>\n<p>If you receive any errors, review your configuration file and make sure you\u2019ve set your directives and values properly.<\/p>\n<p>Next, reload NGINX for the changes you\u2019ve made to take effect by running the following command:<\/p>\n<pre><code>sudo systemctl reload nginx<\/code><\/pre>\n<p>With this, you can now create an HTML test file to test your setup.<\/p>\n<p>In your <code>\/var\/www\/mysite<\/code> root web directory, create a new <code>index.html<\/code> file:<\/p>\n<pre><code>sudo nano \/var\/www\/mysite\/index.html<\/code><\/pre>\n<p>Paste The following HTML code into it:<\/p>\n<pre><code>&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"en\"&gt;\r\n&lt;head&gt;\r\n    &lt;meta charset=\"UTF-8\"&gt;\r\n    &lt;title&gt;My website&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    &lt;h1&gt;Hello World!&lt;\/h1&gt;\r\n    &lt;p&gt;This is the landing page of &lt;strong&gt;My Site&lt;\/strong&gt;&lt;\/p&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<p>As you can see, this is straightforward HTML code.<\/p>\n<p>Save the file by pressing <strong>CTRL+x<\/strong> and then <strong>y<\/strong> and <strong>Enter<\/strong> to confirm.<\/p>\n<p>Now, open your browser and navigate to your server\u2019s domain name or IP address:<\/p>\n<pre><code>http:\/\/your_server_domain_or_IP_address<\/code><\/pre>\n<p>You should see that the <code>index.html<\/code> file you created earlier is properly served.<\/p>\n<p><strong>Note:<\/strong> What we\u2019ve done in this article is suitable for testing purposes and personal use, whereas if you want to publish your site to production, and securely process your online transactions, we do suggest you check our <a href=\"https:\/\/www.ssdnodes.com\/blog\/install-lets-encrypt-on-ubuntu-certbot-apache-and-nginx\/\">How To Install Let\u2019s Encrypt on Ubuntu 24.04<\/a> article, that explains in detail how to secure your site with SSL certificates.<\/p>\n<h2>Reader Alert!<\/h2>\n<p>If you feel that the technical instructions in this tutorial are time-consuming, or beyond your expertise, you can choose a very convenient and practical solution, ready-made, fully and professionally tested, and developed by SSD Nodes (That is us \ud83d\ude0a). Just visit <a href=\"https:\/\/www.ssdnodes.com\/\">our website<\/a>, choose the server\u2019s specifications that fit your needs, and while prompted to choose among the operating systems and the 1-Click Applications we have, choose <strong>LEMP<\/strong> from the <strong>Apps<\/strong> dropdown menu, complete your checkout, and in a couple of minutes our algorithms will take care of all the technical aspects smoothly and effortlessly, just for you!<\/p>\n<p><strong>Bonus:<\/strong> All our 1-Click applications are now installed with an active HTTPS self-signed certificate!<\/p>\n<h2>Conclusion<\/h2>\n<p>For the next steps to go live, it is important to secure your web server connections by serving requests with HTTPS instead of HTTP. You can accomplish this using a CA certificate, which is the more convenient solution when going public; check out our<a href=\"https:\/\/www.ssdnodes.com\/blog\/install-lets-encrypt-on-ubuntu-certbot-apache-and-nginx\/\"> How To Install Let\u2019s Encrypt on Ubuntu<\/a> guide.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Master LEMP installation on Ubuntu 24.04 with our guide! Set up Nginx, MariaDB, and PHP in no time, even if you&#8217;re a beginner. Perfect your web hosting skills!<\/p>\n","protected":false},"author":15,"featured_media":10476,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[18],"tags":[197,185],"class_list":["post-6884","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","tag-lemp","tag-ubuntu"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts\/6884","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/comments?post=6884"}],"version-history":[{"count":11,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts\/6884\/revisions"}],"predecessor-version":[{"id":12938,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts\/6884\/revisions\/12938"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/media\/10476"}],"wp:attachment":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/media?parent=6884"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/categories?post=6884"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/tags?post=6884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}