First we want to make sure that your server is up to date by running the command:

  • apt-get update

Note: Depending on your installation you may need to remove apache2. You can do that by running the commands:

  • apt-get remove apache2*

Followed by:

  • apt-get autoremove

Installing Nginx on Debian 8.2

To install Nginx use the command:

  • apt-get install nginx

When it asks “Do you want to continue? ”  Hit enter.

Start the Nginx service with the following command:

  • service nginx start

We can now test Nginx, by going to your hostname or IP address in your browsers address bar. You should see a web page that looks like the image below.

This is the default webpage when installing Nginx on Debian 8

This example is the default Nginx web page on Debian 8.2

 

Now that Nginx is installed, we can move on to installing MySQL.

Installing MySQL on Debian 8.2

Install MySQL with the command:

  • apt-get install mysql-server

When it asks “Do you want to continue?” hit enter.

Shortly after, a screen similar to the image below will appear.  You need enter a password for your MySQL root user. It should be a strong password.

Insert your own secure password for your new MySQL root passwod

Insert your secure password for your new MySQL root password

Hit enter to continue. Once you have hit enter, a new screen will appear prompting you to re-enter the password you just picked.

Re-enter your new root password.

Re-enter your new root MySQL password.

 

Now that MySQL is installed we need to do the MySQL secure installation by running the command:

  • mysql_secure_installation

Enter your MySQL root password. When it asks “Change the root password?” Type N followed by enter. The rest of the questions are up to you. For standard installations, you can hit enter for the defaults.

An example of the mysql_secure_install

An example of the mysql_secure_install

 

Now that MySQL is installed we can now install PHP.

Installing PHP on Debian 8.2

Install PHP with the following command:

  • apt-get install php5 php5-fpm php5-mysql

When it asks “Do you want to continue?” hit enter.

For Nginx to work with PHP correctly, we need to edit a Nginx configuration file. In this how to, we are going to place a simple Nginx config file.

First we need to moved the original to a new file name, run the command:

  • mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.old

Using a text editor of your choice, we are going to make a file called default in /etc/nginx/sites-available. For nano use the command:

  • nano /etc/nginx/sites-available/default

Copy the following into your text editor:

  • server {
  • listen 80;
  • server_name your_site_name.com;
  • root /var/www/html;
  • index index.php index.html index.htm index.nginx-debian.html;
  • location / {
  • try_files $uri $uri/ =404;
  • }
  • error_page 404 /404.html;
  • error_page 500 502 503 504 /50x.html;
  • location = /50x.html {
  • root /var/www/html;
  • }
  • 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;
  • }
  • }

In nano to exit and save, hit ctrl+x and type y and then enter.

We are now going to make a simple PHP page to test.

Using a text editor of your choice, we are going make a file called info.php in /var/www/html

  • nano /var/www/html/info.php

Copy the following into your text editor.

  • <?php
  • phpinfo();
  • ?>

Since we made changes to the conf files, we need to restart Nginx, by running the command:

  • service nginx restart

In your browser, you can go to http://Your-Hostname/info.php or http://Your-IP-Address/info.php

You should see a web page similar to the one below.

An example of what your php.info file should look like

An example of what your php.info file should look like

Congratulations you have installed LEMP on Debian 8.2. Thank you for following this How-To.

 

Fuente: https://www.atlantic.net/community/howto/install-lemp-on-debian-8/

Deja un comentario