How to use OneinStack to deploy LEMP/LNMP/LAMP on VPS

LEMP stack is another most setup of a server or a virtual private server (VPS) besides LAMP. LEMP (or LNMP) stands for Linux, Nginx, MySQL and PHP.It’s a web server that can server millions of visitors a day with no single blip.

In today’s post I’ll show you how to build a working CentOS/Redhat Debian and Ubuntu VPS to host websites using Nginx Or Apach including steps how to install  full LNMP stack.This guide will make use of OneinStack, a LEMP (Linux, Nginx, MariaDB MySQL & PHP-FPM) web stack installer.


1.A server (VPS / Dedi) :

  1. Linode VPS Review-How to Create a Linode Server
  2. RamNode VPS Review-Cheap KVM and SSD VPS Starts at $3.50/mo

2.A knowledge on:

  1. How To Install LEMP on Debian & Ubuntu (Linux, nginx, MySQL, PHP,PHPMyAdmin)
  2. How to test VPS Speed and Performance? Install and Run UnixBench & sysbench

What is OneinStack?

This script is written using the shell, in order to quickly deploy LEMP/LAMP/LNMP/LNMPA(Linux, Nginx/Tengine/OpenResty, MySQL in a production environment/MariaDB/Percona, PHP), applicable to CentOS 5~7(including redhat), Debian 6~8, Ubuntu 12~16 of 32 and 64.



OneinStack Features

Many Shared Hosting users worry about complexity of setting up and managing a VPS.What OneinStack does is automating most common configuration of server for web hosting. It helps newbies to setup a working server to host their website, blog or forum easily and quickly .

Database versions (MySQL-5.7, MySQL-5.6, MySQL-5.5, MariaDB-10.1, MariaDB-10.0, MariaDB-5.5,Percona-5.7, Percona-5.6, Percona-5.5)
PHP versions (php-7, php-5.6, php-5.5, php-5.4, php-5.3)
Provide Nginx, Tengine, OpenResty
Providing a plurality of Apache version (Apache-2.4, Apache-2.2)
PHP Cache Accelerator: ZendOPcache, xcache, apcu, eAccelerator. 
PHP encryption and decryption tool: ionCube, ZendGuardLoader.
Installation Pureftpd, phpMyAdmin.Install memcached, redis .
Providing add a virtual host script, include Let's Encrypt SSL certificate
Provided under HHVM install CentOS 6,7

How to install Oneinstack ?

For CentOS/Redhat:

yum -y install wget screen   // For CentOS / Redhat
wget   // Contains the source code
tar xzf lnmp-full.tar.gz
cd lnmp    
screen -S lnmp    // if network interruption, you can execute the command `screen -r lnmp` reconnect install window

For Debian/Ubuntu:

apt-get -y install wget screen    
wget   // Contains the source code
tar xzf lnmp-full.tar.gz
cd lnmp    
screen -S lnmp    // if network interruption, you can execute the command `screen -r lnmp` reconnect install window


Select Nginx or Apache to install :

Do you want to install Web server? [y/n]: y.Please select Nginx server:
        1. Install Nginx
        2. Install Tengine
        3. Install OpenResty
        4. Do not install

Please select Apache server:
        1. Install Apache-2.4
        2. Install Apache-2.2
        3. Do not install
Please input a number:(Default 3 press Enter) 

Select which Databases and PHP versions to  use :

Do you want to install Database? [y/n]: y

Please select a version of the Database:
        1. Install MySQL-5.7
        2. Install MySQL-5.6
        3. Install MySQL-5.5
        4. Install MariaDB-10.1
        5. Install MariaDB-10.0
        6. Install MariaDB-5.5
        7. Install Percona-5.7
        8. Install Percona-5.6
        9. Install Percona-5.5
Please input a number:(Default 2 press Enter) 
Please input the root password of database: fydx19871227

Do you want to install PHP? [y/n]: y

Please select a version of the PHP:
        1. Install php-5.3
        2. Install php-5.4
        3. Install php-5.5
        4. Install php-5.6
        5. Install php-7
Please input a number:(Default 3 press Enter) 

Opcode cache\ImageMagick or GraphicsMagick\phpMyAdmin\redis\memcached\HHVM:

Do you want to install opcode cache of the PHP? [y/n]: y
Please select a opcode cache of the PHP:
        1. Install Zend OPcache
Please input a number:(Default 1 press Enter) 

Do you want to install ImageMagick or GraphicsMagick? [y/n]: n

Do you want to install Pure-FTPd? [y/n]: n

Do you want to install phpMyAdmin? [y/n]: y

Do you want to install redis? [y/n]: y

Do you want to install memcached? [y/n]: y

Do you want to use jemalloc or tcmalloc optimize Database and Web server? [y/n]: y
Please select jemalloc or tcmalloc:
        1. jemalloc
        2. tcmalloc
Please input a number:(Default 1 press Enter) 

Do you want to install HHVM? [y/n]: n

Once you’ve followed all those steps above including the last step, you can see it .

So fire up your browser and point it to the servers’ IP address.OneinStack default welcome page should be seen there:

Now you can manage your MySQL databases from phpMyAdmin web interface.

Navigate to  http://server-ip-address/phpinfo.php. It will display all the details about php such as version, build date and commands etc.

How to use OneinStack?

Add a virtual host:

cd ~/lnmp    // Must enter the directory execution under lnmp
./    // Do not sh or bash such execution

Delete a virtual host:

cd ~/lnmp
./ del


cd ~/lnmp
./    // Backup parameters 
./    // Perform the backup immediately 
crontab -l    // Can be added to scheduled tasks, such as automatic backups every day 1:00 
  0 1 * * * cd ~/lnmp;./  > /dev/null 2>&1 &

How to manage service

Nginx/Tengine/OpenResty: service nginx {start|stop|status|restart|reload|configtest}

MySQL/MariaDB/Percona: service mysqld {start|stop|restart|reload|status}

PHP: service php-fpm {start|stop|restart|reload|status}

HHVM: service supervisord {start|stop|status|restart|reload}

Apache:service httpd {start|restart|stop}

Pure-Ftpd: service pureftpd {start|stop|restart|status}

Redis: service redis-server {start|stop|status|restart|reload}

Memcached: service memcached {start|stop|status|restart|reload}


Finally, at this point you have installed and configured full LEMP stack properly. All you have to do is just adding some more additional Virtual Host / Server Block for each domain you want to host to that server.

How To Install LEMP on Debian & Ubuntu (Linux, nginx, MySQL, PHP,PHPMyAdmin)

The LEMP (Linux, nginx, MySQL, PHP,PHP,MyAdmin)software stack is a group of software that can be used to serve dynamic web pages and web applications.In this guide, I will walk you through installing all of these components on Debian & Ubuntu .

This tutorial series helps sysadmins set up a new web server using the LEMP stack, as well as all of the required repos to download nginx and php-fpm. It will also review how to configure php and nginx, as well as how to create a php info page.

You can read the following articles to know more about Cheap VPS Hosting and VPS Tutorials .

  1. How to test VPS Speed and Performance? Install and Run UnixBench & sysbench
  2. RamNode VPS Review-Cheap KVM and SSD VPS Starts at $3.50/mo
  3. host1plus VPS Review-Affordable & Quick VPS Hosting RAM 256 MB Only $2.00/mo

How to Install the Nginx Web Server

Nginx is a open source web server. Generally, Apache is installed on majority of the servers but Nginx tends to give better performance out of the box compared to Apache.

There are several ways to install Nginx.

1.Install Nginx from Repositories

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install nginx

2.Install Nginx from a Source Distribution

sudo apt-get install libpcre3-dev build-essential libssl-dev
cd /opt/
sudo wget
sudo tar -zxvf nginx*.tar.gz
cd /opt/nginx-*
sudo ./configure --prefix=/opt/nginx --user=nginx --group=nginx --with-http_ssl_module --with-ipv6
sudo make
sudo make install
sudo adduser --system --no-create-home --disabled-login --disabled-password --group nginx
#Create a script to run Nginx: /lib/systemd/system/nginx.service
Description=A high performance web server and a reverse proxy server
ExecStartPre=/opt/nginx/sbin/nginx -t -q -g 'daemon on; master_process on;'
ExecStart=/opt/nginx/sbin/nginx -g 'daemon on; master_process on;'
ExecReload=/opt/nginx/sbin/nginx -g 'daemon on; master_process on;' -s reload
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /opt/nginx/logs/

sudo chmod +x /lib/systemd/system/nginx.service
sudo systemctl start nginx

3.Configure Server Blocks

Now, we need to configure nginx.Create the server block file /etc/nginx/sites-available/ with your domain:)

server {
listen   80;
access_log /var/www/html/;
error_log /var/www/html/;

location / {
    root   /var/www/html/;
    index  index.html index.htm;


4.Create the public_html and log directories.

sudo mkdir -p /var/www/html/{public_html,logs}

5.Enable the site and restart the web server.

sudo rm /etc/nginx/sites-enabled/
sudo /etc/init.d/nginx restart

After installation, we can verify nginx installation by opening the ip of server. It should display default nginx page.

Install and Configure PHP

PHP is a server-side scripting language designed for web development. The scripting role can also be filled with Python or Perl. We can do so by the running the following commands:

sudo apt-get install php5-fpm php5-mysql

Then open up php.ini:

sudo nano /etc/php5/fpm/php.ini
# Find the line cgi.fix_pathinfo=1 and change the 1 to 0.


php5-fpm configuration. Open up www.conf:

sudo nano /etc/php5/fpm/pool.d/www.conf

#Find the line, listen =, and change the to /var/run/php5-fpm.sock.
listen = /var/run/php5-fpm.sock
sudo service php5-fpm restart

Install and Configure MySQL Database Server

MySQL is commonly used as the database for most LEMP stacks or other LAMP stacks.Open terminal and type in these commands:

sudo apt-get install mysql-server

During the installation,You should set a root password.


Create a database and grant permissions.

mysql -u root -p
create database howsvps;
grant all on howsvps.* to 'howsvpsu' identified by '1234567';
sudo /etc/init.d/php-fastcgi restart


#to generate the directory structure
sudo mysql_install_db
sudo mysql_secure_installation

Install and Configure phpMyAdmin

PhpMyAdmin is a powerful PHP based gui for MySQL. phpMyAdmin was originally developed by Tobias Ratschiller.Installing phpMyAdmin is almost as easy as installing MySQL, just a few more steps.

Install phpMyAdmin

sudo apt-get install phpmyadmin

During the installation,You could choose the web server that will automatically configured to run PhpMyadmin .

The next prompt will ask if you would like dbconfig-common to configure a database for phpmyadmin to use. Select “Yes” to continue.

Afterward, you will be asked to select and confirm a password for a new database that will hold phpMyAdmin’s own data.

You just need to create a symbolic link from the installation files to our Nginx document root directory by typing this:

sudo ln -s /usr/share/phpmyadmin /usr/share/nginx/html

#enable the mcrypt PHP module
sudo php5enmod mcrypt
sudo service php5-fpm restart

You should now have a configured and secured PHPMyAdmin instance and MySQL database ready to use. Go to your server’s domain name or public IP address followed by /phpmyadmin, in your web browser:


You should now have Linux, nginx, MySQL, PHP,PHPMyAdmin configured and ready to use on your Debian & Ubuntu server. If you want to host websites on your server running NGINX ,you can use NGINX server blocks.

Server blocks are the NGINX equivalent of Apache’s virtual hosts – they let you direct incoming HTTP traffic for a domain name to a particular directory on your server.