{"id":4774,"date":"2018-06-08T20:48:10","date_gmt":"2018-06-08T16:48:10","guid":{"rendered":"https:\/\/www.howtoforge.com\/tutorial\/how-to-install-magento-with-nginx-on-ubuntu\/"},"modified":"2018-06-08T20:48:10","modified_gmt":"2018-06-08T16:48:10","slug":"how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04\/","title":{"rendered":"How to Install Magento 2 with Nginx and Letsencrypt on Ubuntu 18.04"},"content":{"rendered":"<p>Magento is a widely used Open Source e-commerce software and content management system for e-commerce websites based on the PHP Zend Framework. It uses MySQL or MariaDB as database backend. The Magento development has been started in 2008 by Varien.<\/p>\n<p>In this tutorial, I will show you how to install Magento 2 with Nginx, PHP 7.1 FPM, and MySQL as the database. I will use ubuntu 18.04 (Bionic Beaver) as server operating system. If you don&#8217;t have a minimal server setup yet, please see this tutorial to get a proper base setup.<\/p>\n<h2 id=\"prerequisites\">Prerequisites<\/h2>\n<ul>\n<li>Ubuntu 18.04<\/li>\n<li>2GB or more RAM memory<\/li>\n<li>Root privileges<\/li>\n<\/ul>\n<h2 id=\"what-we-will-do\">What we will do<\/h2>\n<ol>\n<li>Install Nginx on Ubuntu 18.04<\/li>\n<li>Install and Configure PHP-FPM 7.1<\/li>\n<li>Install and Configure MySQL Server<\/li>\n<li>Install and Configure Magento 2<\/li>\n<ol>\n<li>Install PHP Composer<\/li>\n<li>Download Magento 2<\/li>\n<li>Install Magento Components<\/li>\n<li>Generate SSL Letsencrypt<\/li>\n<li>Configure Nginx Virtual Host for Magento<\/li>\n<li>Magento Post-Installation<\/li>\n<\/ol>\n<li>Testing<\/li>\n<\/ol>\n<h2 id=\"step-install-nginx-on-ubuntu-lts\">Step 1 &#8211; Install Nginx on Ubuntu 18.04 LTS<\/h2>\n<p>In this tutorial, we will be using the Nginx web server for our Magento installation.<\/p>\n<p>Log in to the server, update the repository, and upgrade all packages.<\/p>\n<p class=\"command\">sudo apt update<br \/>sudo apt upgrade<\/p>\n<p>Now install the Nginx web server using the apt command below.<\/p>\n<p class=\"command\">sudo apt install nginx -y<\/p>\n<p>After the installation is complete, start the Nginx service and enable it to launch every time at system boot.<\/p>\n<p class=\"command\">systemctl start nginx<br \/>systemctl enable nginx<\/p>\n<p>Nginx web server has been installed, check it using netstat command and make sure the HTTP port 80 is on the &#8216;LISTEN&#8217; state. Another way is by using curl command as below.<\/p>\n<p class=\"command\">netstat -plntu<br \/>curl -I localhost<\/p>\n<p><a class=\"fancybox\" id=\"img-1\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_magento_2_with_nginx_and_letsencrypt_on_ubuntu_1804_lts\/big\/1.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04.png\" alt=\"Install Nginx web server\" width=\"500\" height=\"363\" title=\"\"><\/a><\/p>\n<h2 id=\"step-install-and-configure-phpfpm-\">Step 2 &#8211; Install and Configure PHP-FPM 7.1<\/h2>\n<p>After the Nginx web server installation, we will install PHP 7.1 on the server as Magento does not support PHP 7.2 yet. We will install PHP-FPM with all extensions needed by Magento 2.<\/p>\n<p>List of PHP extensions needed for Magento 2 installation:<\/p>\n<ul>\n<li>bc-math<\/li>\n<li>ctype<\/li>\n<li>curl<\/li>\n<li>dom<\/li>\n<li>gd, ImageMagick 6.3.7 (or later) or both<\/li>\n<li>intl<\/li>\n<li>mbstring<\/li>\n<li>mcrypt<\/li>\n<li>hash<\/li>\n<li>openssl<\/li>\n<li>PDO\/MySQL<\/li>\n<li>SimpleXML<\/li>\n<li>soap<\/li>\n<li>spl<\/li>\n<li>libxml<\/li>\n<li>xsl<\/li>\n<li>zip<\/li>\n<li>json<\/li>\n<li>iconv<\/li>\n<\/ul>\n<p>For this guide, we will install PHP-FPM packages from the PPA repository. We will be using the &#8216;ondrej\/php&#8217; repository.<\/p>\n<p>Install the &#8216;software-properties-common&#8217; package and add the &#8216;ondrej\/php&#8217; repository using commands below.<\/p>\n<p class=\"command\">sudo apt install software-properties-common -y<br \/>sudo add-apt-repository ppa:ondrej\/php -y<\/p>\n<p><a class=\"fancybox\" id=\"img-2\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_magento_2_with_nginx_and_letsencrypt_on_ubuntu_1804_lts\/big\/2.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-1.png\" alt=\"Install PHP 7.1\" width=\"500\" height=\"308\" title=\"\"><\/a><\/p>\n<p>Now install PHP-FPM 7.1 with all extensions needed.<\/p>\n<p class=\"command\">sudo apt install php7.1-fpm php7.1-mcrypt php7.1-curl php7.1-cli php7.1-mysql php7.1-gd php7.1-xsl php7.1-json php7.1-intl php-pear php7.1-dev php7.1-common php7.1-mbstring php7.1-zip php7.1-soap php7.1-bcmath -y<\/p>\n<p>After the installation is complete, check the PHP version and installed extensions using PHP commands.<\/p>\n<p class=\"command\">php -v<br \/>php -me<\/p>\n<p><a class=\"fancybox\" id=\"img-3\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_magento_2_with_nginx_and_letsencrypt_on_ubuntu_1804_lts\/big\/3.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-2.png\" alt=\"Check PHP installation\" width=\"500\" height=\"170\" title=\"\"><\/a><\/p>\n<p>Next, we will configure the php.ini file for the PHP-FPM and PHP-CLI.<\/p>\n<p>Edit the php.ini files using <a href=\"https:\/\/www.howtoforge.com\/vim-basics\" target=\"_blank\" rel=\"noopener noreferrer\">vim<\/a>.<\/p>\n<p class=\"command\">vim \/etc\/php\/7.1\/fpm\/php.ini<br \/>vim \/etc\/php\/7.1\/cli\/php.ini<\/p>\n<p>Change the value of those lines as below.<\/p>\n<pre>memory_limit = 512M&#13;\nmax_execution_time = 180&#13;\nzlib.output_compression = On<\/pre>\n<p>Save and exit.<\/p>\n<p>Now restart the PHP-fpm service and enable it to launch every time at system boot.<\/p>\n<p class=\"command\">systemctl restart php7.1-fpm<br \/>systemctl enable php7.1-fpm<\/p>\n<p>The PHP-FPM 7.1 installation and configuration has been completed, check the service using netstat command.<\/p>\n<p class=\"command\">netstat -pl | grep php<\/p>\n<p>And you will get the PHP-fpm socks file as below.<\/p>\n<p><a class=\"fancybox\" id=\"img-4\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_magento_2_with_nginx_and_letsencrypt_on_ubuntu_1804_lts\/big\/4.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-3.png\" alt=\"Check PHP-FPM socket\" width=\"500\" height=\"179\" title=\"\"><\/a><\/p>\n<h2 id=\"step-install-and-configure-mysql-server\">Step 3 &#8211; Install and Configure MySQL Server<\/h2>\n<p>The Magento software requires MySQL 5.6.x, and the Magento 2.1.2 or later require the MySQL 5.7.x. In this tutorial, we will install latest MySQL server 5.8 on the Ubuntu 18.04 system.<\/p>\n<p>Install MySQL 5.8 using the apt command below.<\/p>\n<p class=\"command\">sudo apt install mysql-server mysql-client -y<\/p>\n<p>After the installation is complete, start the MySQL service and enable it to launch every time at system boot.<\/p>\n<p class=\"command\">systemctl start mysql<br \/>systemctl enable mysql<\/p>\n<p>Now we will configure the MySQL root password using &#8216;mysql_secure_installation&#8217; command.<\/p>\n<p class=\"command\">mysql_secure_installation<\/p>\n<p>In this MySQL 5.8 version, there is a security improvement for the MySQL password policy. You need to choose the password policy &#8211; 0 for the LOW policy, 1 for the MEDIUM policy, and 2 for a STRONG password policy.<\/p>\n<p>For this guide, we will be using the &#8216;MEDIUM&#8217; password policy, and it&#8217;s recommended to use the &#8216;STRONG&#8217; password policy on the production server.<\/p>\n<p>Choose number &#8216;1&#8217; and press Enter, then type your new MySQL &#8216;root&#8217; password.<\/p>\n<p><a class=\"fancybox\" id=\"img-5\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_magento_2_with_nginx_and_letsencrypt_on_ubuntu_1804_lts\/big\/5.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-4.png\" alt=\"Secure MySQL installation\" width=\"500\" height=\"349\" title=\"\"><\/a><\/p>\n<pre class=\"system\"> Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y<br\/>Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y<br\/>Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y<br\/>Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y<\/pre>\n<p>The MySQL root password has been set up.<\/p>\n<p>Next, we will create a new database for our Magento installation. We will create a new database named\u00a0 &#8216;magentodb&#8217; with user &#8216;magentouser&#8217; and the password is &#8216;<a href=\"https:\/\/www.howtoforge.com\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"723f1315171c061d4246444132\" target=\"_blank\" rel=\"noopener\">[email\u00a0protected]<\/a>#&#8217;.<\/p>\n<p>Login to the MySQL shell using the root user.<\/p>\n<p class=\"command\">mysql -u root -p<\/p>\n<p>Now run MySQL queries below to create the database and user.<\/p>\n<p class=\"command\">create database magentodb;<br \/>create user <a href=\"https:\/\/www.howtoforge.com\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"117c7076747f657e64627463517d7e72707d797e6265\" target=\"_blank\" rel=\"noopener\">[email\u00a0protected]<\/a> identified by &#8216;<a href=\"https:\/\/www.howtoforge.com\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"de93bfb9bbb0aab1eeeae8ed9e\" target=\"_blank\" rel=\"noopener\">[email\u00a0protected]<\/a>#&#8217;;<br \/>grant all privileges on magentodb.* to <a href=\"https:\/\/www.howtoforge.com\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"107d7177757e647f65637562507c7f73717c787f6364\" target=\"_blank\" rel=\"noopener\">[email\u00a0protected]<\/a> identified by &#8216;<a href=\"https:\/\/www.howtoforge.com\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"a2efc3c5c7ccd6cd92969491e2\" target=\"_blank\" rel=\"noopener\">[email\u00a0protected]<\/a>#&#8217;;<br \/>flush privileges;<\/p>\n<p>The MySQL server installation and configuration for the Magento installation has been completed.<\/p>\n<p><a class=\"fancybox\" id=\"img-6\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_magento_2_with_nginx_and_letsencrypt_on_ubuntu_1804_lts\/big\/6.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-5.png\" alt=\"Create MySQL database and user for Magento\" width=\"500\" height=\"357\" title=\"\"><\/a><\/p>\n<h2 id=\"step-install-and-configure-magento-\">Step 4 &#8211; Install and Configure Magento 2<\/h2>\n<p>In this step, we will install Magento 2.2.4 latest version from Github repository. We will install the PHP composer for installing the Magento components, download Magento from Github repository, configure Nginx virtual host for Magento, and install Magento using the web-based post installation.<\/p>\n<h3 id=\"-install-php-composer\">&#8211; Install PHP Composer<\/h3>\n<p>Install PHP Composer on ubuntu 18.04 using the apt command below.<\/p>\n<p class=\"command\">sudo apt install composer -y<\/p>\n<p>After the installation is complete, check the composer version installed on the system.<\/p>\n<p class=\"command\">composer -V<\/p>\n<p><a class=\"fancybox\" id=\"img-7\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_magento_2_with_nginx_and_letsencrypt_on_ubuntu_1804_lts\/big\/7.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-6.png\" alt=\"Install PHP composer\" width=\"500\" height=\"106\" title=\"\"><\/a><\/p>\n<p>The latest version PHP Composer has been installed.<\/p>\n<h3 id=\"-download-magento-\">&#8211; Download Magento 2<\/h3>\n<p>Go to the &#8216;\/var\/www&#8217; directory and download the Magento archive source code from Github using wget command.<\/p>\n<p class=\"command\">cd \/var\/www\/<br \/>wget https:\/\/github.com\/magento\/magento2\/archive\/2.2.4.tar.gz<\/p>\n<p>Now extract the Magento archive file and rename the directory to &#8216;magento2&#8217;.<\/p>\n<p class=\"command\">tar -xf 2.2.4.tar.gz<br \/>mv magento2-2.2.4\/ magento2\/<\/p>\n<p>The Magento source code has been downloaded, and the &#8216;\/var\/www\/magento2&#8217; directory will be the web root for the Magento site.<\/p>\n<h3 id=\"-install-magento-components\">&#8211; Install Magento Components<\/h3>\n<p>Install Magento components using the PHP composer. Go to the &#8216;magento2&#8217; directory and install all the PHP components needed by Magento using the &#8216;composer&#8217; command.<\/p>\n<p class=\"command\">cd \/var\/www\/magento2<br \/>composer install -v<\/p>\n<p>After the installation is complete, you will get the result as shown below.<\/p>\n<p><a class=\"fancybox\" id=\"img-8\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_magento_2_with_nginx_and_letsencrypt_on_ubuntu_1804_lts\/big\/8.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-7.png\" alt=\"Check composer version\" width=\"500\" height=\"134\" title=\"\"><\/a><\/p>\n<h3 id=\"-generate-ssl-letsencrypt\">&#8211; Generate SSL Letsencrypt<\/h3>\n<p>We will secure our Magento installation using SSL from Letsencrypt. Install the Letsencrypt using the apt command below.<\/p>\n<p class=\"command\">sudo apt install letsencrypt -y<\/p>\n<p>After the installation is complete, stop the nginx service.<\/p>\n<p class=\"command\">systemctl stop nginx<\/p>\n<p>Now generate the SSL certificates for the domain name using certbot command as below.<\/p>\n<p class=\"command\">certbot certonly &#8211;standalone -d magento.hakase-labs.pw<\/p>\n<p>Type your email address, accept the Letsencrypt TOS, then type &#8216;N&#8217; for email sharing.<\/p>\n<p><a class=\"fancybox\" id=\"img-10\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_magento_2_with_nginx_and_letsencrypt_on_ubuntu_1804_lts\/big\/10.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-8.png\" alt=\"Enable Let&#039;s encrypt SSL certificate\" width=\"500\" height=\"377\" title=\"\"><\/a><\/p>\n<p>When it&#8217;s complete, you will get the result as below.<\/p>\n<p><a class=\"fancybox\" id=\"img-11\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_magento_2_with_nginx_and_letsencrypt_on_ubuntu_1804_lts\/big\/11.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-9.png\" alt=\"SSL cert issues successfully\" width=\"500\" height=\"339\" title=\"\"><\/a><\/p>\n<p>The Letsencrypt SSL certificate files have been generated to the &#8216;\/etc\/letsencrypt\/live&#8217; directory.<\/p>\n<h3 id=\"-configure-nginx-virtual-host\">&#8211; Configure Nginx Virtual Host<\/h3>\n<p>Go to the &#8216;\/etc\/nginx\/sites-available&#8217; directory and create new virtual host file &#8216;magento&#8217; using <a href=\"https:\/\/www.howtoforge.com\/vim-basics\" target=\"_blank\" rel=\"noopener noreferrer\">vim<\/a>.<\/p>\n<p class=\"command\">cd \/etc\/nginx\/sites-available\/<br \/>vim magento<\/p>\n<p>Paste the following configuration there.<\/p>\n<pre>upstream fastcgi_backend {&#13; server unix:\/run\/php\/php7.1-fpm.sock;&#13;\n}&#13;\n&#13;\nserver {&#13; listen 80;&#13; listen [::]:80;&#13; server_name magento.hakase-labs.pw;&#13; return 301 https:\/\/$server_name$request_uri;&#13;\n}&#13;\n&#13;\nserver {&#13;\n&#13; listen 443 ssl;&#13; server_name magento.hakase-labs.pw;&#13;\n&#13; ssl on;&#13; ssl_certificate \/etc\/letsencrypt\/live\/magento.hakase-labs.pw\/fullchain.pem;&#13; ssl_certificate_key \/etc\/letsencrypt\/live\/magento.hakase-labs.pw\/privkey.pem;&#13;\n&#13; set $MAGE_ROOT \/var\/www\/magento2;&#13; set $MAGE_MODE developer;&#13; include \/var\/www\/magento2\/nginx.conf.sample;&#13;\n}<\/pre>\n<p>Save the configuration and exit.<\/p>\n<p>Now activate the virtual host by creating the symbolic link for the Magento virtual host file to the &#8216;sites-enabled&#8217; directory.<\/p>\n<p class=\"command\">ln -s \/etc\/nginx\/sites-available\/magento \/etc\/nginx\/sites-enabled\/<\/p>\n<p>Test nginx configuration file and make sure there is no error.<\/p>\n<p class=\"command\">nginx -t<\/p>\n<p>Now restart the PHP-FPM and Nginx service.<\/p>\n<p class=\"command\">systemctl restart php7.1-fpm<br \/>systemctl restart nginx<\/p>\n<p>And change the owner of Magento web-root directory to the &#8216;www-data&#8217; user and group.<\/p>\n<p class=\"command\">chown -R www-data:www-data \/var\/www\/magento2\/<\/p>\n<p>The nginx virtual host for Magento has been added.<\/p>\n<h3 id=\"-magento-postinstallation\">&#8211; Magento Post-Installation<\/h3>\n<p>Open the web browser and type the Magento URL. Mine is:<\/p>\n<p>https:\/\/magento.hakase-labs.pw\/<\/p>\n<p>For the &#8216;Terms and Agreement&#8217;, click the &#8216;Agree and Setup Magento&#8217; button.<\/p>\n<p><a class=\"fancybox\" id=\"img-12\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_magento_2_with_nginx_and_letsencrypt_on_ubuntu_1804_lts\/big\/12.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-10.png\" alt=\"Magento web installer\" width=\"500\" height=\"234\" title=\"\"><\/a><\/p>\n<p>Now check all system and server configuration for Magento &#8216;Readlines Check&#8217;, and make sure it &#8216;passes&#8217; all system and configuration check as below.<\/p>\n<p><a class=\"fancybox\" id=\"img-13\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_magento_2_with_nginx_and_letsencrypt_on_ubuntu_1804_lts\/big\/13.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-11.png\" alt=\"Check prerequisites\" width=\"500\" height=\"289\" title=\"\"><\/a><\/p>\n<p>Now click &#8216;Next&#8217; button.<\/p>\n<p>Database configuration for Magento &#8211; type all our database info and click &#8216;Next&#8217;.<\/p>\n<p><a class=\"fancybox\" id=\"img-14\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_magento_2_with_nginx_and_letsencrypt_on_ubuntu_1804_lts\/big\/14.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-12.png\" alt=\"Database configuration\" width=\"500\" height=\"256\" title=\"\"><\/a><\/p>\n<p>For the web configuration, change the &#8216;store address&#8217; to HTTPS, &#8216;Magento Admin Address&#8217; with your admin path URL and uncheck the &#8216;Apache Rewrites&#8217;, because we&#8217;re using the Nginx web server.<\/p>\n<p><a class=\"fancybox\" id=\"img-15\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_magento_2_with_nginx_and_letsencrypt_on_ubuntu_1804_lts\/big\/15.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-13.png\" alt=\"Web configuration\" width=\"500\" height=\"291\" title=\"\"><\/a><\/p>\n<p>Click the &#8216;Next&#8217; button again.<\/p>\n<p>Leave the &#8216;Customize Your Store&#8217; as default and click &#8216;Next&#8217;.<\/p>\n<p><a class=\"fancybox\" id=\"img-16\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_magento_2_with_nginx_and_letsencrypt_on_ubuntu_1804_lts\/big\/16.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-14.png\" alt=\"Customize Magento store\" width=\"500\" height=\"254\" title=\"\"><\/a><\/p>\n<p>Type your admin user and password, then click &#8216;Next&#8217;.<\/p>\n<p><a class=\"fancybox\" id=\"img-17\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_magento_2_with_nginx_and_letsencrypt_on_ubuntu_1804_lts\/big\/17.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-15.png\" alt=\"Setup the admin account\" width=\"500\" height=\"248\" title=\"\"><\/a><\/p>\n<p>And click &#8216;Install Now&#8217; button to install Magento.<\/p>\n<p><a class=\"fancybox\" id=\"img-18\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_magento_2_with_nginx_and_letsencrypt_on_ubuntu_1804_lts\/big\/18.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-16.png\" alt=\"Start Magento installation\" width=\"500\" height=\"209\" title=\"\"><\/a><\/p>\n<p>And when installation is complete, you will get the &#8216;success&#8217; result as below.<\/p>\n<p><a class=\"fancybox\" id=\"img-19\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_magento_2_with_nginx_and_letsencrypt_on_ubuntu_1804_lts\/big\/19.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-17.png\" alt=\"Magento installation successful\" width=\"500\" height=\"289\" title=\"\"><\/a><\/p>\n<p>Now we need to disable write access for the &#8216;\/var\/www\/magento2\/app\/etc&#8217; directory. Run the command below.<\/p>\n<p class=\"command\">sudo chmod -w \/var\/www\/magento2\/app\/etc<\/p>\n<p>Magento has been installed on to the Ubuntu 18.04 Bionic Beaver server.<\/p>\n<h2 id=\"step-testing\">Step 5 &#8211; Testing<\/h2>\n<p>Type the Magento URL home address and make sure you get the Magento default home page. Mine is: https:\/\/magento.hakase-labs.pw\/<\/p>\n<p><a class=\"fancybox\" id=\"img-23\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_magento_2_with_nginx_and_letsencrypt_on_ubuntu_1804_lts\/big\/23.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-18.png\" alt=\"Magento homepage\" width=\"500\" height=\"289\" title=\"\"><\/a><\/p>\n<p>Now login to the Magento admin dashboard by visiting the URL defined during the installation &#8216;admin_hakase&#8217;. Mine is:<\/p>\n<p>https:\/\/magento.hakase-labs.pw\/admin_hakase\/<\/p>\n<p><a class=\"fancybox\" id=\"img-20\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_magento_2_with_nginx_and_letsencrypt_on_ubuntu_1804_lts\/big\/20.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-19.png\" alt=\"Magento backend login\" width=\"500\" height=\"282\" title=\"\"><\/a><\/p>\n<p>Type the username and password, then click the &#8216;Sign in&#8217; button.<\/p>\n<p>And you will get the Magento admin dashboard as below.<\/p>\n<p><a class=\"fancybox\" id=\"img-22\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_magento_2_with_nginx_and_letsencrypt_on_ubuntu_1804_lts\/big\/22.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-20.png\" alt=\"Magento dashboard\" width=\"500\" height=\"291\" title=\"\"><\/a><\/p>\n<p>Magento 2 has been installed on Ubuntu 18.04 with Nginx web server, MySQL database, and PHP-FPM 7.1.<\/p>\n<h3 id=\"additional\">Additional:<\/h3>\n<p>If you get an error about a missing Magento indexer cronjob, then you can solve it by generating the crontab script using the command below.:<\/p>\n<p class=\"command\">cd \/var\/www\/magento2<br \/>sudo -u www-data php bin\/magento cron:install &#8211;force<\/p>\n<p>Now check the list crontab script for the &#8216;www-data&#8217; user.<\/p>\n<p class=\"command\">crontab -u www-data -l<\/p>\n<p><a class=\"fancybox\" id=\"img-21\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_magento_2_with_nginx_and_letsencrypt_on_ubuntu_1804_lts\/big\/21.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-21.png\" alt=\"Setup Magento indexer cronjob\" width=\"500\" height=\"153\" title=\"\"><\/a><\/p>\n<h2 id=\"reference\">Reference<\/h2>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<p>\n<a href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fhow-to-install-magento-with-nginx-on-ubuntu%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-22.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fhow-to-install-magento-with-nginx-on-ubuntu%2F&amp;text=How+to+Install+Magento+2+with+Nginx+and+Letsencrypt+on+Ubuntu+18.04&amp;via=howtoforgecom&amp;related=howtoforgecom\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-23.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/howtoforgecom\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-24.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/plus.google.com\/share?url=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fhow-to-install-magento-with-nginx-on-ubuntu%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-magento-2-with-nginx-and-letsencrypt-on-ubuntu-18-04-25.png\" height=\"20\" alt=\"\" title=\"\"><\/a>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Magento is a widely used Open Source e-commerce software and content management system for e-commerce websites based on the PHP Zend Framework. It uses MySQL or MariaDB as database backend. The Magento development has been started in 2008 by Varien. In this tutorial, I will show you how to install Magento 2 with Nginx, PHP [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-4774","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/4774","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=4774"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/4774\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=4774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=4774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=4774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}