<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>experimental &#187; nginx</title>
	<atom:link href="http://www.tajidyakub.com/tag/nginx/feed" rel="self" type="application/rss+xml" />
	<link>http://www.tajidyakub.com</link>
	<description>Experience the Experiment</description>
	<lastBuildDate>Sat, 10 Oct 2009 19:32:38 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Removing Nginx Server Version</title>
		<link>http://www.tajidyakub.com/web-servers/removing-nginx-server-version-2008-07-31.html</link>
		<comments>http://www.tajidyakub.com/web-servers/removing-nginx-server-version-2008-07-31.html#comments</comments>
		<pubDate>Wed, 30 Jul 2008 19:52:37 +0000</pubDate>
		<dc:creator>Tajid Yakub</dc:creator>
				<category><![CDATA[Web Servers]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[server tokens]]></category>

		<guid isPermaLink="false">http://tajidyakub.com/?p=16</guid>
		<description><![CDATA[Just add the following configuration on http {} directive inside your nginx.conf
http {
...
server_tokens   off;
...
}
]]></description>
			<content:encoded><![CDATA[<p>Just add the following configuration on http {} directive inside your nginx.conf</p>
<pre class="brush: bash">http {
...
server_tokens   off;
...
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.tajidyakub.com/web-servers/removing-nginx-server-version-2008-07-31.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nginx, MySQL, PHP in CentOS 5.1 (x86_64)</title>
		<link>http://www.tajidyakub.com/web-servers/nginx-mysql-php-in-centos-51-x86_64-2008-06-28.html</link>
		<comments>http://www.tajidyakub.com/web-servers/nginx-mysql-php-in-centos-51-x86_64-2008-06-28.html#comments</comments>
		<pubDate>Sat, 28 Jun 2008 03:29:29 +0000</pubDate>
		<dc:creator>Tajid Yakub</dc:creator>
				<category><![CDATA[Web Database]]></category>
		<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[Web Servers]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://tajidyakub.com/?p=13</guid>
		<description><![CDATA[Nginx (pronounced &#8220;engine x&#8221;) is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. Written by Igor Sysoev in 2005, still in beta, Nginx is known for its stability, rich feature set, simple configuration, and low resource consumption, taken from the wiki. I will not go deeper on [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Nginx" href="http://nginx.net" target="_blank">Nginx</a> (pronounced &#8220;engine x&#8221;) is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. Written by <a title="Nginx Developer" href="http://sysoev.ru/en/" target="_blank">Igor Sysoev</a> in 2005, still in beta, Nginx is known for its stability, rich feature set, simple configuration, and low resource consumption, <a title="nginx wiki" href="http://wiki.codemongers.com/Main" target="_blank">taken from the wiki</a>. I will not go deeper on the subject of nginx as a preferrable alteranate HTTP Server asides from <a title="Apache HTTP Server" href="http://httpd.apache.org/" target="_blank">Apache</a>, since I don&#8217;t have a lot of knowledge on the subject.</p>
<p>This article intends to show you a step by step tutorial on how to install (and do basic configuration) for Nginx powered Web Sites with <a title="PHP Site" href="http://php.net" target="_blank">PHP</a> (through <a title="php-fpm" href="http://php-fpm.anight.org/" target="_blank">php-fpm</a>) and <a title="MySQL" href="http://mysql.com/" target="_blank">MySQL</a> Enabled in <a title="CentOS!" href="http://centos.org" target="_blank">CentOS 5.1</a> (x86_64) Virtual Box. The Box is from <a title="Magnet Hosting and Server" href="http://magnet-id.com" target="_blank">Magnet VPS</a> (Entry with 128MB Dedicated RAM, 256MB SWAP Space and 5GB HDD Space).</p>
<p><span id="more-13"></span></p>
<p><strong>Install and Securing (Basic) MySQL</strong></p>
<pre class="brush: bash">

yum install -y mysql-server mysql-devel
service mysqld start
mysql_secure_installation

Enter current password for root (enter for none): Enter
Set root password? [Y/n] Y
New password: rootpasssql
Re-enter new password: rootpasssql
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
</pre>
<p><strong>Install Required Package for Compiling</strong></p>
<p>We need to install a few basic package since this is a very base install of CentOS, some of the package will depend on your wanted php configuration.</p>
<pre class="brush: bash">

yum install -y wget patch gcc libtool libmcrypt-devel libxml2-devel flex bison make pcre-devel zlib-devel openssl-devel gd-devel
</pre>
<p><strong>Install PHP From Source</strong></p>
<p>We are going to install PHP 5.2.6 along with php-fpm patch (patch for PHP to improve FastCGI SAPI Usage in Production)</p>
<pre class="brush: bash">
cd /usr/local/src
wget http://id2.php.net/get/php-5.2.6.tar.gz/from/id2.php.net/mirror
tar xzvf php-5.2.6.tar.gz
wget http://php-fpm.anight.org/downloads/head/php-5.2.6-fpm-0.5.8.diff.gz
gzip -cd php-5.2.6-fpm-0.5.8.diff.gz | patch -d php-5.2.6 -p1
cd php-5.2.6
./configure --enable-fastcgi --enable-fpm --with-mcrypt --with-zlib --enable-mbstring --with-openssl --with-mysql --with-mysql-sock --with-gd --with-jpeg-dir=/usr/lib --enable-gd-native-ttf --without-sqlite --disable-pdo --disable-reflection --with-libdir=lib64
make all install
strip /usr/local/bin/php-cgi
</pre>
<p>Adjust php-fpm configuration, remove the comment sign in line 63 and 65, adjust the user in which nginx will run, in this example I am using nobody (default)</p>
<pre class="brush: bash">
vi /usr/local/etc/php-fpm.conf
&lt;value name=&quot;user&quot;&gt;nobody&lt;/value&gt;
&lt;value name=&quot;group&quot;&gt;nobody&lt;/value&gt;
</pre>
<p>Now we will install X-Cache opcode php cacher</p>
<pre class="brush: bash">
cd /usr/local/src
wget http://xcache.lighttpd.net/pub/Releases/1.2.2/xcache-1.2.2.tar.gz
tar xzvf xcache-1.2.2.tar.gz
cd xcache-1.2.2
phpize
./configure --with-php-config=/usr/local/bin/php-config --enable-xcache
make install
</pre>
<p>Insert xcache in php.ini</p>
<pre class="brush: bash">

vi /usr/local/lib/php.ini

magic_quotes_gpc=0
[xcache-common]
zend_extension = /usr/local/lib/php/extensions/no-debug-non-zts-20060613/xcache.so
[xcache]
xcache.shm_scheme = &quot;mmap&quot;
xcache.size = 64M
</pre>
<p>Check your PHP Installation</p>
<pre class="brush: bash">
php -v
PHP 5.2.6 (cli) (built: Jun 28 2008 08:56:02)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
with XCache v1.2.2, Copyright (c) 2005-2007, by mOo
</pre>
<p><strong>Init Script for php-fpm</strong></p>
<p>Put php-fpm init script in your rc.local to auto start during reboot</p>
<pre class="brush: bash">
cd /etc/init.d/
ln -s /usr/local/sbin/php-fpm php-fpm

## add this line to /etc/rc.local ##
/etc/init.d/php-fpm
</pre>
<p><strong>Install Nginx</strong></p>
<p>Now we will install nginx, the current stable version is 0.6.31, check their site for updates;</p>
<pre class="brush: bash">
export NGINX=0.6.31
cd /usr/local/src
wget http://sysoev.ru/nginx/nginx-${NGINX}.tar.gz
tar xfz nginx-${NGINX}.tar.gz
cd nginx-${NGINX}
./configure --pid-path=/usr/local/nginx/logs/nginx.pid --sbin-path=/usr/local/sbin/nginx --with-md5=/usr/lib --with-sha1=/usr/lib --with-http_ssl_module  --with-http_dav_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module
make
make install
</pre>
<p><strong>Nginx Daemon for CentOS</strong></p>
<p>Get Nginx daemon for CentOS and add the service to startup so it start automatically during reboot.</p>
<pre class="brush: bash">
wget http://notrocketsurgery.com/files/nginx -O /etc/init.d/nginx
chmod 750 /etc/init.d/nginx
## Install start-stop-daemon ##
cd /usr/local/src
wget http://developer.axis.com/download/distribution/apps-sys-utils-start-stop-daemon-IR1_9_18-1.tar.gz
tar zxvf apps-sys-utils-start-stop-daemon-IR1_9_18-1.tar.gz
cd apps/sys-utils/start-stop-daemon-IR1_9_18-1/
gcc start-stop-daemon.c -o start-stop-daemon
cp start-stop-daemon /usr/sbin
chkconfig --add nginx
chkconfig --level 345 nginx on
</pre>
<p><strong>Configure Nginx</strong></p>
<p>This is a sample configuration for wordpress running on nginx web sites. Notice that I am disabling logs, the sample is only for basic configuration, you should read more on nginx manual for the configuration directive.</p>
<pre class="brush: bash">

service nginx start
## Edit the main configuration File ##
vi /usr/local/nginx/conf/nginx.conf
## Put only these lines ##
user  nobody;
worker_processes  5;
error_log  /var/log/nginx/error.log;
events {
worker_connections  768;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nodelay on;
keepalive_timeout 10 10;
gzip on;
gzip_comp_level 1; gzip_proxied any;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

server {
listen  80;
server_name your.hostname.tld;
location / {
root   html;
autoindex  off;
index  index.html index.htm;
}
}
include /usr/local/nginx/sites-enabled/*;
}

## Make a sites config ##
cd /usr/local/nginx
mkdir sites-enabled
cd sites-enabled
vi yourwordpressblog.tld

## Put these lines ##

server {
listen yourwordpressblog.tld:80;
server_name yourwordpressblog.tld www.yourwordpressblog.tld;
index index.php;
root /var/www/yourwordpressblog.tld;

location / {
error_page 404 = //index.php?q=$uri;
}

location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /usr/local/nginx/conf/fastcgi_params;
}
}

## Add this line to fastcgi_params /usr/local/nginx/fastcgi_params##
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
</pre>
<p>Make the root www directory for your wordpressblog, this is subject for security notice in the future, I haven&#8217;t look further.</p>
<pre class="brush: bash">
mkdir -p /var/www/yourwordpressblog.tld
touch /var/www/yourwordpressblog.tld/index.php
chown -R nobody.nobody /var/www/yourwordpressblog.tld
</pre>
<p>Restart nginx, but make sure that your domain already resolved to your nginx web server, otherwise it will fail to start.</p>
<pre class="brush: bash">
service nginx restart
</pre>
<h2>Update</h2>
<p>It is now CentOS 5.3, PHP and fpm patch 5.2.10, and nginx 0.7.61 stable release. This post is obsolete, unless you can modify the steps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tajidyakub.com/web-servers/nginx-mysql-php-in-centos-51-x86_64-2008-06-28.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
