Install LEMP Server (Nginx, PHP 7.0, MariaDB & phpMyAdmin) on LinuxMint 17.1, 17.2, 17.3 & 18

LEMP stack stands for Linux, Nginx, MySQL, MariaDB, MongoDB, PHP, Perl, Python & phpMyAdmin. LEMP is bunch of open source software which is developed by different organization.

NGINX stands for engine-x is a free, open-source, high-performance HTTP server and reverse proxy, as well as an mail (IMAP/POP3) proxy server. Nginx is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption. Currently 146 million websites use NGINX to deliver super-fast web experiences. The big companies like (WordPress, facebook, GitHub & cloudflare, etc..) using nginx.

PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features which is very useful for busy sites, like 20000+ hits per day. Navigate to PHP-FPM site to know more about it.

Remove Existing LAMP stack

I would advise users to remove existing LEMP stack completely to avoid conflicts. Use the following single command to purge everything.

[Remove LAMP Stack]
$ sudo apt-get purge apache2* php7.0* mysql* phpmyadmin*
$ sudo apt-get autoremove
$ sudo apt-get autoclean

[Remove Apache Configuration files]
$ whereis apache2
$ sudo rm -Rf /etc/apache2

[Remove MySQL Configuration files]
$ sudo rm -Rf /var/lib/mysql/
$ sudo rm -Rf /etc/mysql/

Then recheck once, if anything still available. Using below commands.

$ dpkg -l | grep apache2*
$ dpkg -l | grep php7.0*
$ dpkg -l | grep mysql*
$ dpkg -l | grep phpmyadmin*

1) Install Nginx

Linux Mint 1 (Sarah) shipped with latest Nginx version, so just fire the below command to install Nginx on Mint. For older version of Mint users, add Nginx Repository to get latest stable version. The default Nginx web root directory is located at /usr/share/nginx/html.

[Install Nginx]
$ sudo apt-get install nginx

[Start, Enable & check the Status of Nginx service on systemd System]
$ sudo systemctl start nginx.service
$ sudo systemctl enable nginx.service
$ sudo systemctl status nginx.service

[Start, Enable & check the Status of Nginx service on SysVinit System]
$ sudo service nginx start
$ sudo service nginx status
$ sudo chkconfig nginx on

Nginx Version checking

$ nginx -v
nginx version: nginx/1.10.0 (Ubuntu)

2) Check Nginx Index page

Make sure you have to change the default web root in /etc/nginx/nginx.conf from /var/www/html to /usr/share/nginx/html, only for Mint 18 users. Finally restart sudo systemctl restart nginx.service. Now, open your web browser and navigate to http://localhost/ or http://your-server-ip-address/ or http://127.0.0.1/
install-lemp-on-linuxmint-18-sarah-1

3) MariaDB installation

MariaDB is a drop-in replacement for MySQL. MariaDB is open source relational database management system (RDBMS) which is supporting database access. By default Linux Mint included MariaDB 10.0 to their official repository. So, just fire the below command to install it. For older system, add MariaDB 10.x to get latest stable version.

[Install MariaDB]
$ sudo apt-get -y install mariadb-server mariadb-client

[Start, Enable & check the Status of MariaDB service on systemd & SysVinit System]

[Start, Enable & check the Status of MariaDB service on systemd System]
$ sudo systemctl start mysql.service
$ sudo systemctl enable mysql.service
$ sudo systemctl status mysql.service

[Start, Enable & check the Status of MariaDB service on SysVinit System]
$ sudo service mysqld start
$ sudo chkconfig mysqld on

3a) Set MySQL root password

By default MySQL/MariaDB instance doesn’t come with root password and we have to set by running below command to make DB more secure. Run mysql_secure_installation command which will set root password and adjust other settings too, such as removing anonymous users, Disallow root login remotely, Remove test database and access & Reload privilege tables.

[MariaDB Secure installation]
$ sudo mysql_secure_installation

Enter current password for root (enter for none): Enter Your Current Password
OK, successfully used password, moving on...

Set root password? [Y/n] n
 ... skipping.

Remove anonymous users? [Y/n] y
 ... Success!

Disallow root login remotely? [Y/n] y
 ... Success!

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

install-lamp-on-linuxmint-18-sarah-2

About Magesh Maruthamuthu

Love to play with all Linux distribution

View all posts by Magesh Maruthamuthu

29 Comments on “Install LEMP Server (Nginx, PHP 7.0, MariaDB & phpMyAdmin) on LinuxMint 17.1, 17.2, 17.3 & 18”

  1. hi, I’m stuck at the last step: ‘installing phpmyadmin’. I did as you taught me, I’ve create the symlink etc, but when I tried to open localhost/phpmyadmin, it start download a BIN file instead of opening the page. Can you guys help me?

  2. The poor grammar and the writer’s misinformation and erros led to a failure of the entire LEMP stack. 1. the file to be modified after nginx installation in /etc was not nginx.conf but the default file in sites-available. 2. The ubuntu os does not like to use mariadb and mysqyl without the proper dependencies available. That was due to the fact that the mariadb (whatever version the writer intends is not specified) cannot be installeed before mysql (again, the mariadb install only works with an unspecified version of mysql that is installed prior to installing mariadb. Thank you for your attention.

  3. I use Linux 18.1 Cinnamon. Your instructions are really good. I did notice that sudo was omitted a couple of times, for instance with the softlink creation, but no problems for me. I had tried to set this up before on my own and failed miserably. Thank you very much.

  4. After installation MYSQL open:
    sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
    and edit:
    bind-address = 127.0.0.1
    on
    bind-address = / your ip address /
    to avoid the 404 error

  5. I’m running Linux Mint 18 and I’ve made about 3 times the whole process (2 with distro repositories and one with nginx ones), but i can’t make it work with php…
    I’m also having some problems with step 2), file doesn’t contains /var/www/html, i tested it and that’s the root folder, but i couldn’t change it

    It doesn’t matter what i do, the php files always give 404 error

  6. “Select the webserver to configure phpMyAdmin automatically. We knows, we are using apache.”

    But we are not using apache. We need to press tab and proceed without selecting neither of the servers.

  7. @disqus_OnjdFboXsR:disqus,
    1 & 2) I missed to update, it’s only for Mint 18 users. Updated on article too.

    Also modified the phpmyadmin url link

  8. I am using Linux Mint 17.3 but after following this guide I get a 404 when opening http://localhost/phpMyAdmin. Some problems I had when following this guide was:

    1. On step 2) /etc/nginx/nginx.conf didn’t contain /var/www/html anywhere, so I could not replace it with /usr/share/nginx/html.
    2. systemctl didn’t work for me, so I used sudo service nginx restart instead of sudo systemctl restart nginx.service. Is this a problem?
    3. When phpmyadmin was installing I got an error saying “address already in use” over and over. I assume it is because port 80 is already being used somehow? Maybe by nginx? If port 80 is already being used by nginx then how is phpmyadmin supposed to use apache to install with port 80 as well?

    Thanks for the guide but unfortunately it did not work perfectly for me.

  9. run service nginx reload here is what i got
    nginx: [emerg] invalid variable name in /etc/nginx/nginx.conf:63
    nginx: configuration file /etc/nginx/nginx.conf test failed

      1. Thanks. I started over and do clean install. It works now.
        Can you make video how to use ssl on nginx and I would like to add owncloud with ssl too.
        I know it is simple for you but i snot for I am still confused with the concept
        I know where the files are but still dont get it

  10. Thanks for the nice article. Really helpful. next time I ran to a problem, I’ll run to you instead of stack 😀

  11. Hello, now worked for me, I forgot to close the block with ” }” to see the php working I had to replace the include fastcgi_params; with include fastcgi.conf;

  12. For me didn’t work, my sites-available/default file doesn’t have the commented fastcgi_split_path_info ^(.+\.php)(/.+)$;
    I’ve tried like yours but the nginx didn’t start

Leave a Reply

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