Knowledgebase

Easy Webserver no panel setup Nginx Webserver

Easy setup Nginx Webserver!

Web Server Load Balancing with NGINX Plus

 On any Ubuntu Server or Ubuntu VPS Server use the command:

apt install nginx -y

 

On any Centos Server Use the command:

yum install nginx -y

 

And that is it your done!

(If you get any issues do: apt update or yum update, then try again and reboot if you are still facing issues.)

Recommended setup would be using Ubuntu 18 (64bit)

Where do i upload my website files? (HTML Website template for example)

/www/data

How about if i have a database for my website too?

Install Mysql ( apt install mysql ) ( yum install mysql )

 

How about if my site needs PHP extension compatibility?

Install and Configure PHP-FPM

 Install PHP5-FPM

Next, install php5-fpm using the package management tool that comes with your distro.

For example, on Ubuntu, you can install php5-fpm using apt-get as shown below:

$ sudo apt-get install php5-fpm

Add PHP Configuration to Nginx

Next, modify the /etc/nginx/sites-available/default file, and add the following lines.

$ sudo vi /etc/nginx/sites-available/default
server {
  listen   80;
  root /usr/share/nginx/www;
  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;
  }
}

Set listen Parameter in php5-fpm www.conf

Next, we need to make the following changes in the php-frpm configuration.

By default, you’ll see the following listen entry in the www.conf file

$ sudo vi  /etc/php5/fpm/pool.d/www.conf
listen =  127.0.0.1:9000

In the www.conf file, leave everything as it is, and replace the above listen line with the one shown below.

$ sudo vi  /etc/php5/fpm/pool.d/www.conf
listen = /var/run/php5-fpm.sock

Restart the Nginx and PHP5-FPM and Test it

Restart php5-fpm and nginx as shown below

$  service nginx restart

$ service php5-fpm restart

Finally, create the following index.php file in the nginx document root, and test it.

$ vi /usr/share/nginx/www
<?php
  phpinfo( );
?>

In the final stage, open your browser and go to http://localhost/index.php (or use your ip-address), which will execute the index.php file and display the php information.

 

Nginx for cPanel:

Install Engintron

 

Nginx server for Windows 10 or even a windows server

 

Download the Nginx Server

There are many Windows download versions of Nginx, and Nginx recommends using the “mainline version.” However, you will not find any issues if you download its most recent stable version for Windows.

Select the latest zip file and download the file then extract and move the folder to: C / Program Files then open the nginx.exe file as administrator. You can then go to lochost  or local.host in your browser and you should see a: Welcome to nginx!  Message.

 

Full highly detailed Nginx only webserver setup:

Prebuilt Packages for Linux and BSD

Most Linux distributions and BSD variants have NGINX in the usual package repositories and they can be installed via whatever method is normally used to install software (apt-get on Debian, emerge on Gentoo, ports on FreeBSD, etc).

Be aware that these packages are often somewhat out-of-date. If you want the latest features and bug fixes, it’s recommended to build from source or use packages directly from nginx.org.

Official Red Hat/CentOS packages

To add NGINX yum repository, create a file named /etc/yum.repos.d/nginx.repo and paste one of the configurations below:

CentOS:

[nginx]
name=nginx repo
baseurl=https://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

RHEL:

[nginx]
name=nginx repo
baseurl=https://nginx.org/packages/rhel/$releasever/$basearch/
gpgcheck=0
enabled=1

Due to differences between how CentOS, RHEL, and Scientific Linux populate the $releasever variable, it is necessary to manually replace $releasever with either 5 (for 5.x) or 6 (for 6.x), depending upon your OS version.

Official Debian/Ubuntu packages

Ubuntu:

The available NGINX Ubuntu release support is listed on this distribution page. For a mapping of Ubuntu versions to release names, please visit the Official Ubuntu Releases page.

Append the appropriate stanza to /etc/apt/sources.list. If there is concern about the persistence of repository additions (i.e. DigitalOcean Droplets), the appropriate stanza may instead be added to a different list file under /etc/apt/sources.list.d/, such as /etc/apt/sources.list.d/nginx.list.

## Replace $release with your corresponding Ubuntu release.
deb https://nginx.org/packages/ubuntu/ $release nginx
deb-src https://nginx.org/packages/ubuntu/ $release nginx

e.g. Ubuntu 16.04 (Xenial):

deb https://nginx.org/packages/ubuntu/ xenial nginx
deb-src https://nginx.org/packages/ubuntu/ xenial nginx

To install the packages, execute in your shell:

sudo apt-get update
sudo apt-get install nginx

If a W: GPG error: https://nginx.org/packages/ubuntu xenial Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY $key is encountered during the NGINX repository update, execute the following:

## Replace $key with the corresponding $key from your GPG error.
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $key
sudo apt-get update
sudo apt-get install nginx

Debian 6:

Append the appropriate stanza to /etc/apt/sources.list.

deb https://nginx.org/packages/debian/ squeeze nginx
deb-src https://nginx.org/packages/debian/ squeeze nginx

Ubuntu PPA

This PPA is maintained by volunteers and is not distributed by nginx.org. It has some additional compiled-in modules and maybe more fitting for your environment.

You can get the latest stable version of NGINX from the NGINX PPA on Launchpad: You will need to have root privileges to perform the following commands.

For Ubuntu 10.04 and newer:

sudo -s
nginx=stable # use nginx=development for latest development version
add-apt-repository ppa:nginx/$nginx
apt-get update
apt-get install nginx

If you get an error about add-apt-repository not existing, you will want to install python-software-properties. For other Debian/Ubuntu-based distributions, you can try the lucid variant of the PPA which is the most likely to work on older package sets:

sudo -s
nginx=stable # use nginx=development for latest development version
echo "deb http://ppa.launchpad.net/nginx/$nginx/ubuntu lucid main" > /etc/apt/sources.list.d/nginx-$nginx-lucid.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8C
apt-get update
apt-get install nginx

Official Win32 Binaries

As of NGINX 0.8.50, NGINX is now available as an official Windows binary.

Installation:

cd c:\
unzip nginx-1.2.3.zip
ren nginx-1.2.3 nginx
cd nginx
start nginx

Control:

nginx -s [ stop | quit | reopen | reload ]

For problems look in c:nginxlogserror.log or in EventLog.

A useful command to find and fix any nginx errors and check if it is working: service nginx restart

  • 2 Users Found This Useful
Was this answer helpful?