Setting up a LEMP stack
Setting up a LEMP stack
This is a guide on setting up a LEMP stack on a Linux VPS running ubuntu 12.04 LTS. I have personally done this before. You will need either a LEMP stack or a LAMP stack when you are setting up your botnet or RAT. A LEMP stack stands for Linux Nginx ( pronounced Engine x)Mysql PHP. A LEMP stack is different from a LAMP stack because of the web server.
A LAMP stack web server is Apache and a LEMP stack web server is Nginx. Nginx is a lot faster and uses less space. The decision is up to you which stack you prefer.
Tools
1. Linux VPS
2. Putty ssh client
3. This guide
Steps
Once you have purchased your Linux VPS all you do is login to putty using your ssh logins which is provided to you by the company
you bought the Linux VPS from. See Working with SSH Client for more information on setting up Putty.
Once you have logged in to putty, what you have to do is type:
sudo apt-get update.
On May 8th, 2012, a serious php vulnerability was discovered,
and it is important that we download all of the latest patched software to protect the virtual private server.
after we do this the next step is to install Mysql.
For that we type:
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql.
It will prompt you that this download will take up X amount of space just type (y).
During the installation Mysql will ask for you to set a password, do that then mysql will be installed.
Now Mysql is installed and to activate it we need to do this command:
sudo mysql_install_db
Then finish up by doing this command:
sudo /usr/bin/mysql_secure_installation
They will ask you for your current root password which is the same password you used to login to putty.
Then the prompt will ask you if you want to change the root password. Go ahead and choose N and move on to the next step.
After this you will be asked a series of questions and the relevant answer to them is (y) so type y and it will finish install.
Once you have done this and the installation is complete then you install php and that command is:
sudo apt-get install php5
press y to continue and it will install.
The next step will be to install Nginx. You use this command to install Nginx:
sudo apt-get install nginx
nginx does not start on its own. To get nginx running, type:
sudo service nginx start.
You can confirm that nginx has installed an your web server by directing your browser to your IP address.
You can run the following command to reveal your VPS's IP address:
ifconfig eth0 | grep inet | awk '{ print $2 }'
Now we are going to install PHP5 fpm. To install PHP-FPM, open terminal and type in these commands:
sudo apt-get install php5-fpm
Now we must configure PHP-fpm. We need to make one small change in the php configuration.Open up php.ini:
sudo nano /etc/php5/fpm/php.ini
Find the line, cgi.fix_pathinfo=1, and change the 1 to 0. This is what it should look like:
cgi.fix_pathinfo=0
If this number is kept as 1, the php interpreter will do its best to process the file that is as near to the requested file as possible.
This is a possible security risk. If this number is set to 0, conversely, the interpreter will only process the exact file path—a much safer alternative. We need to save our changes and exit and to do that just type:
ctrl + y, then enter and type: ctrl + x
We need to make another small change in the php5-fpm configuration. Open up www.conf:
sudo nano /etc/php5/fpm/pool.d/www.conf
Find the line, listen = 127.0.0.1:9000, and change the 127.0.0.1:9000 to /var/run/php5-fpm.sock. It should look like this:
listen = /var/run/php5-fpm.sock. Save and exit like before
Now we are going to Restart php-fpm type:
sudo service php5-fpm restart
Now it's time to configure Nginx. Open up the default virtual host file Type:
sudo nano /etc/nginx/sites-available/default
Now in this configuration file if /usr/share/nginx/www does not exist, then it's usually /var/www/. Here are the details of the changes:
Add index.php to the index line.
Change the server_name from local host to your domain name or IP address
Change the correct lines in “location ~ \.php$ {“ section
save and exit.
Now your nginx config file should look like this:
server {
listen 80;
root /usr/share/nginx/www; (as stated above, sometimes /var/www/ will be here) index index.php index.html index.htm;
server_name example.com;
location / { try_files $uri $uri/ /index.html; }
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/www; }
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params;
We can quickly see all of the details of the new php configuration.
To set this up, first create a new file:
sudo nano /usr/share/nginx/www/info.php or sudo nano /var/www/info.php
Add in the following line:
<?php phpinfo(); ?>
Then Save and Exit.
Restart nginx by typing this command:
sudo service nginx restart
You can see the nginx and php-fpm configuration details by visiting:
http://youripaddress/info.php
Your LEMP stack is now set up and configured on your virtual private server.
--True wealth comes from knowledge, and true knowledge comes from research, the wages of fraud is equivalent to money by the power of 10 18:50, 23 October 2013 (EDT)