• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Linux Install Nginx on [Debian 8 and Ubuntu]

Webo

Otland 4ever
Joined
Oct 20, 2013
Messages
621
Solutions
10
Reaction score
229
Location
Warsaw
Installing LEMP on a Debian 8.3 Cloud Server Or VPS wok ubuntu system
First we want to make sure that your server is up to date by running the command:

  • apt-get update
  • apt-get upgrade
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.3
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. If you do not know your IP address you can run the following command:

  • ifconfig
You should get a result similar to the image below.


An example of ifconfig that shows the IP address of 192.168.0.2



In our example, 192.68.0.2 is the IP address. So in our browser we would go to http://192.68.0.2

You should see a web page that looks like the image below.


This example is the default Nginx web page on Debian 8.3



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

Installing MySQL on Debian 8.3
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 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 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



Now that MySQL is installed we can now install PHP.

Installing PHP on Debian 8.3
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:
Code:
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/php.info or http://Your-IP-Address/php.info

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


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

Congratulations you have installed LEMP on Debian 8.3. Thank you for following this How-To! Check back for more updates, and take a look at our how-to Installing WordPress on Debian 8. Atlantic.Net offers expert technical support and services like Managed Cloud Hosting and popular one-click install applications like cPanel Cloud Hosting.


To config, you can add more / phpmyadmin on the ip address which will be given in the

Code:
location /phpmyadmin {
        allow 01.123.45.56;
        allow 127.0.0.1;
        deny  all;
        }

allow 01.123.45.5
replace with your ip

security is very easy for users especially for the Poles, not once I got info that someone broke into the bay: P
Regards!
 
I'm just curious, why would you use Nginx and not Apache? Isn't Apache that easily though?

However, good tutorial.
 
@Dyabl0
because the Apache was originally a small party later add support for PHP. Nginx server and my burden is resistant to several types of atakó immediately and apache does not
 
After i did hit apt-get install mysql-server it installed but no window appear to make a password.

Using Debian 9
Post automatically merged:

after i hit - apt-get install php5 php5-fpm php5-mysql, i get this

Reading package lists... Done
Building dependency tree
Reading state information... Done
Package php5 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package php5-mysql is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
 
Last edited:
After i did hit apt-get install mysql-server it installed but no window appear to make a password.

Using Debian 9
Post automatically merged:

after i hit - apt-get install php5 php5-fpm php5-mysql, i get this

Reading package lists... Done
Building dependency tree
Reading state information... Done
Package php5 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package php5-mysql is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
Bash:
apt-get install php php-fpm php-mysql
 
I failed somewhere i think, phpmyadmin not working still like dont exists. Can someone help to compile all ? Il pay for help or do any favor for you <3
 
I failed somewhere i think, phpmyadmin not working still like dont exists. Can someone help to compile all ? Il pay for help or do any favor for you <3

you have to create a symlink in html folder

Code:
sudo ln -s /usr/share/phpmyadmin/ /var/www/html/phpmyadmin
 
After i did hit apt-get install mysql-server it installed but no window appear to make a password.

Using Debian 9
Post automatically merged:

after i hit - apt-get install php5 php5-fpm php5-mysql, i get this

Reading package lists... Done
Building dependency tree
Reading state information... Done
Package php5 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package php5-mysql is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
same for me. it didnt ask me for password
 
Code:
mysql_secure_installation
mysql
ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourpasswordhere'; flush privileges; exit;
I cannot change because i dont know password to root. its not working without password.
 
Back
Top