www.linuxexpert.ro

Tutorials

  • Home
  • BGP Tutorials
    • Remove private AS
  • cPanel Tutorials
    • Install ImageMagick on cPanel
    • Install Softaculous
  • Linux Tutorials
    • Auto-reboot Linux after kernel panic
    • Building a firewall with Iptables
    • Change array RAID 1 disk order
    • Configure ntfs-3g on Linux Slackware
    • DHCP Option Codes
    • DansGuardian with Squid and ClamAV
    • Fetchmail for Gmail accounts
    • Install Zend & APC PHP Optimizers
    • Install Atheros AR242x PCI Express Adapter
    • Install awstats with DirectAdmin
    • Install DBD::mysql via CPAN shell
    • Install DjbDNS on Ubuntu
    • Installing fail2ban on Centos 5
    • Install GoDaddy SSL Certificate
    • Install i386 packages under x86_64
    • Install Linux via USB flashdrive
    • Install ModSecurity2 on Apache2.0.x
    • Install Nginx on CentOS
    • Install webalizer with ispconfig
    • Install intel A/B/G/N wireless on linux
    • Kernel Upgrade
    • Mobile phone access via bluetooth
    • Optimize MySQL
    • Optimize Qmail
    • Optimize server load
    • Optimize and Tune Apache for performance
    • Optimize and Tune Nginx for performance
    • Perfect Mailserver on Debian
    • Pidgin "Now Playing" Status Message
    • PHP hardening
    • PHP hardening with Suhosin
    • PHP5 Support allong with PHP4
    • Previewing your site before making DNS changes
    • Proxy Auto Configuration
    • PXE boot install rescue
    • Setup awstats on CentOS
    • Setup EC2 Amazon L2TP IPSec VPN
    • Setup email piping with Qmail
    • Setup Exim with DKIM
    • Setup Exim smart relay with cPanel
    • Setup OpenVPN
    • Setup postfix on nonstandard port
    • Setup SS5 Socks Proxy
    • Setup vsftp with no shell access
    • Sendmail smart relay with gmail auth
    • Squid proxy NCSA authentication
    • Tcpdump filters
    • Upgrade PHP to 5.3 in Plesk 10
    • Useful regular expressions
    • X with [SiS] 771/671 VGA controller
  • Joomla Tutorials
    • Hardening Joomla
    • Module Positions
    • Remove Joomla description meta tag
  • Looking Glasses
  • Optimize Firefox
  • Security
    • Crack WiFi WEP passwords
    • Defend against UDP isc.org DNS query DDOS
    • Detect DDoS attack
    • Remove malware from web sites
    • Sniff SSL passwords with ettercap
    • Snort2BGP
    • Track Hackers
    • What Is My IP
  • Troubleshooting
    • Grub error no such disk
    • named dumping master file: tmp-XXXXXXXXXX: open: permission denied
    • Nginx 413 Request Entity Too Large
    • SSH conection closed by remote host
    • Troubleshooting sis190.c
  • Unix Tutorials
    • FreeBSD reset root password
    • Installing snort on OpenBSD
    • Unix Toolbox
  • Virtualization Tutorials
    • Convert VirtualBox image to VMWare
    • VMware SNMP Enable
  • VoIP Tutorials
    • Install Elastix
    • Qos for Asterisk

Who's Online

We have 18 guests and no members online

Most Read

  • Setup SS5 Socks Proxy
  • Install webalizer with ispconfig
  • Sniff SSL passwords with ettercap
  • __404__
  • Optimize and Tune Apache for performance

Products and Services

  • Home
  • Linux Products and Services
  • Buy VPN Account
  • Privacy Policy for Linuxexpert
  • Remove malware

Install Nginx on CentOS

  • Print
  • Email
Details
Parent Category: Tutorials
Published: 03 February 2011
Hits: 10268

This tutorial is dedicated all linux users wich wish to setup or install Nginx on CentOS or Linux servers

First install the Nginx:
Method 1:
#rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
#yum update
#yum install nginx php-cli php make automake gcc gcc-c++ spawn-fcgi wget


Method2:

#wget ftp://fr2.rpmfind.net/linux/epel/5/x86_64/nginx-0.8.53-1.el5.x86_64.rpm
#yum install GeoIP
#yum install gd
#yum install libxslt
#rpm -ivh nginx-0.8.53-1.el5.x86_64.rpm

Set nginx to startup at boot:

#chkconfig --add nginx
#chkconfig --level 35 nginx on
#service nginx start


Install php extensions:

#yum install lighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldap php-odbc \
php-pear php-xml php-xmlrpc php-eaccelerator php-magickwand php-magpierss \
php-mapserver php-mbstring php-mcrypt php-mhash php-mssql php-shout php-snmp \
php-soap php-tidy

Now let's configure a vhost:


#mkdir -p /srv/www/www.example.com/public_html
#mkdir /srv/www/www.example.com/logs
#chown -R nginx:nginx /srv/www/www.example.com

#mkdir /etc/nginx/sites-available
#mkdir /etc/nginx/sites-enabled

Add the following lines to your /etc/nginx/nginx.conf file, immediately after the line for "include /etc/nginx/conf.d/*.conf":

# Load config files from the /etc/nginx/conf.d directory
#include /etc/nginx/conf.d/*.conf;
# Load virtual host configuration files.
include /etc/nginx/sites-enabled/*;


Create file: /etc/nginx/sites-available/www.example.com:

server {
listen 80;
server_name www.example.com example.com;
access_log /srv/www/www.example.com/logs/access.log;
error_log /srv/www/www.example.com/logs/error.log;

# location / {
# root /srv/www/www.example.com/public_html;
# index index.html index.htm index.php;
# }
location / {
root /srv/www/www.example.com/public_html;
index index.html index.htm index.php;
if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
}

location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /srv/www/www.example.com/public_html$fastcgi_script_name;
}
}
#cd /etc/nginx/sites-enabled/
#ln -s /etc/nginx/sites-available/www.example.com
#service nginx restart

#cd /opt
#wget https://library.linode.com/web-servers/nginx/php-fastcgi/reference/php-fastcgi-rpm.sh
#mv php-fastcgi-rpm.sh /usr/bin/php-fastcgi
#chmod +x /usr/bin/php-fastcgi
#wget https://library.linode.com/web-servers/nginx/php-fastcgi/reference/php-fastcgi-init-rpm.sh
#mv php-fastcgi-init-rpm.sh /etc/rc.d/init.d/php-fastcgi
#chmod +x /etc/rc.d/init.d/php-fastcgi
#chkconfig --add php-fastcgi
#chkconfig php-fastcgi on


Add this in /etc/php.ini at the end of file:

cgi.fix_pathinfo = 1
#/etc/init.d/php-fastcgi start

Enjoy

Note:

We use Hosting and VPS Hosting, from: www.star-host.org

We like and trust them.

Good prices, high security.



fShare
Tweet