Ok so I’m going to make this article quick, simple and to the point. Fuck the bullshit, lets get ya’ll setup with nginx with a reverse proxy to apache in less than an hour. Now this article is made for VPS type system such as linode or slicehost. We’re starting at the point in which you have Fedora 13 actually installed, base system. So lets get started.
Lets start by installing nginx, start the service and configure it to start at boot.
yum install nginx service nginx start chkconfig nginx on
Was going to use fast-cgi but it crashes so often, so I created a reverse proxy into apache.
yum install httpd httpd-devel php php-cli php-devel mysql php-mysql mysql-server php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-magickwand php-magpierss php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy sendmail
nano /etc/nginx/nginx.conf
Once inside the file, change these two values
worker_processes 5; keepalive_timeout 2;
Similar to apache you can set virtual hosts. First lets start by editing the example in the nginx.conf file.
You can define the vhost in server {} containers. Now lets modify the default vhost:
server_name _; makes this a default vhost ( so lets change this to specify a certain domain e.g. www.something.com).
In the location / part, add index.php to the index line. root /usr/share/nginx/html;
This is your DocumentRoot in an apache virtual host, so you can change it to whatever you want..I prefer the /var/www/ directories.
The important part for PHP is the location ~ \.php$ {} container. You need to uncomment it to enable it. Change the root line to the web site’s document root (e.g. root /usr/share/nginx/html; or whatever you directory you chose.). Be sure to pass .php to 127.0.0.1:8080 to proxy php files to apache (we’ll edit httpd.conf later).
nano /etc/httpd/conf/httpd.conf
Pass through to apache port 8080
Listen 127.0.0.1:8080
configure the virtualhost to reflect the same path as the nginx vhost.
Make sure its ready for startup and start it up
chkconfig mysqld on /etc/init.d/mysqld start
mysql_secure_installation
>Enter Current Root Password : Hit Enter
>Set Root Password : Hit Enter
Now enter your password twice
The rest are your choice, I hit enter all the way through.
Lets install some dependencies, most are just needed on a dev server anyway, so group install. Fail2ban is to keep users from attacking your site, they will be banned after 5 failed attemps to login for 10 mins. You can change the configuration in /etc/fail2ban/
yum groupinstall 'Development Tools' yum groupinstall 'Development Libraries' yum install php-pecl-apc yum install fail2ban yum install mlocate chkconfig fail2ban on chkconfig httpd on chkconfig nginx on chkconfig mysqld on updatedb
In the fail2ban configuration file you can change additional settings, they are very self explanatory. To edit fail2ban configuration go to:
nano /etc/fail2ban/jail.conf
Now guess what, you’re done. If you have any questions, just leave a comment and I’ll be sure to answer it, enjoy the nginx server.
Sign up for a linode VPS, I pay $20 a month and it fucking rocks
My Linode.com Referral Code 2bf9ae77ecd8e759a2b79bf1011e1c3147d93525
-Wes