Nginx is a high performance lightweight web server. It also serves as a reverse proxy,which passes the incoming requests on to web servers on the back, on different ports etc. So that it can easily handle aspects like SSL / HTTPS, GZip, cache headers, load balancing and a lot of other stuff.
Main Advantage of using NGINX is it doesn’t rely on threads to handle requests. Instead it uses a much more scalable event-driven (asynchronous) architecture. One more thing is this architecture makes it possible to use very small, but more importantly, predictable amounts of memory under load.
Some Good Features of Nginx Server:
- Simple load balancing with fault tolerance.
- HTTP basic authentication.
- Both name-based and ip-based virtual server can be configured.
- Supports rewrite module.
- Reverse proxy with caching.
- Supports gzip, XSLT, SSI and image resizing filters.
Steps needs to be followed to configure your user account:
- Login to your server using putty.
- Since Nginx packages are already present inside the server so you need to check the status using the command:
server nginx status
server php-fpm status
If it is found to be inactive then start it using:
server nginx start
server php-fpm start
chkconfig nginx on
chkconfig php-fpm on
3. Under the path /etc/nginx/nginx.conf you need to update user as apache:
user apache;
4. You need to do the proper domain configurations under the path /etc/nginx/availablesites/
Create file named for example, domain_name.conf and the default
configuration looks like:
Server {
listen 80;
server_name designwebtech.in www.designwebtech.in
Access_log
/var/logs/domains/designwebtech/designwebtech.in-access.log;
location / {
root /var/www/html/designwebtech/public_html;
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
root /var/www/html/designwebtech/public_html/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
Fastcgi_paramSCRIPT_FILENAME /var/www/html/designwebtech/public_html$fastcgi_script_name;
include fastcgi_params;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
5. After successful completion of changes you need to restart the nginx server.
service nginx restart
Note : If you found an error while restarting NGINX, it may be due to not properly changing the server block file in the sites-available directory. Make sure that you have all your { } brackets closed and that all directives end in a semicolon.