<?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; Web Database</title>
	<atom:link href="http://www.tajidyakub.com/category/web-database/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>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>
		<item>
		<title>Installation and Basic Configuration Apache, MySQL and PHP on CentOS 5.1 (64 bit)</title>
		<link>http://www.tajidyakub.com/web-servers/installation-and-basic-configuration-apache-mysql-and-php-on-centos-51-64-bit-2008-06-27.html</link>
		<comments>http://www.tajidyakub.com/web-servers/installation-and-basic-configuration-apache-mysql-and-php-on-centos-51-64-bit-2008-06-27.html#comments</comments>
		<pubDate>Thu, 26 Jun 2008 18:48:05 +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[centos]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://tajidyakub.com/?p=11</guid>
		<description><![CDATA[These are the simple steps to Install and do basic configuration Apache 2.2.3, MySQL 5.0.22 and PHP on a base install CentOS 5.1 x86_64. Required Pack Install the required package using yum; yum install gettext httpd mysql mysql-server perl yum install php php-mysql php-xml php-imap php-mbstring php-mcrypt php-pecl-Fileinfo php-pecl-memcache php-pear-DB php-pear-File php-pear-Log php-pear-Mail-Mime php-pear-Auth-SASL php-pear-Date [...]]]></description>
			<content:encoded><![CDATA[<p>These are the simple steps to Install and do basic configuration Apache 2.2.3, MySQL 5.0.22 and PHP on a base install CentOS 5.1 x86_64.</p>
<p><span id="more-11"></span></p>
<p><strong>Required Pack</strong></p>
<p>Install the required package using yum;</p>
<pre class="brush: bash">

yum install gettext httpd mysql mysql-server perl

yum install php php-mysql php-xml php-imap php-mbstring php-mcrypt php-pecl-Fileinfo php-pecl-memcache php-pear-DB php-pear-File php-pear-Log php-pear-Mail-Mime php-pear-Auth-SASL php-pear-Date php-pear-HTTP-Request php-pear-Mail php-pear-Net-Sieve php-pear-Net-Socket php-pear-Net-SMTP

yum install openssl perl-Net-SSLeay

yum install php-devel gcc
</pre>
<p><strong>Start the Service</strong></p>
<p>Start Apache and MySQL daemon, and add them to startup script so it will survive reboot.</p>
<pre class="brush: bash">

service httpd restart
chkconfig httpd on

service mysqld restart
chkconfig mysqld on
</pre>
<p><strong>Standard MySQL First Step After Install</strong></p>
<p>Run the mysql_secure script to do basic securing MySQL and give root password to your MySQL databases;</p>
<pre class="brush: bash">mysql_secure_installation</pre>
<p><strong>Apache and Basic Virtual Host Configuration</strong></p>
<p>Edit the apache configuration file to fit your requirement.</p>
<pre class="brush: bash">

vi /etc/httpd/conf/httpd.conf

###Modify

Listen vvv.xxx.yyy.zzz:80  &lt;--Put your IP Address here

###Add

&lt;Directory “/path/to/rootwwwdir/public_html”&gt;
Options Indexes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
AllowOverride None
&lt;/Directory&gt;

&lt;Directory “/path/to/rootwwwdir/public_html”&gt;
Options Indexes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
AllowOverride None
&lt;/Directory&gt;

Virtual Host Configuration

NameVirtualHost vvv.xxx.yyy.zzz:80

&lt;VirtualHost vvv.xxx.yyy.zzz:80&gt;
ServerAdmin hostmaster@magnet-id.com
DocumentRoot /path/to/rootwwwdir/public_html
ServerName virt1.magnet-id.com
ErrorLog logs/virt1.magnet-id.com-error_log
CustomLog logs/virt1.magnet-id.com-access_log common
&lt;/VirtualHost&gt;

&lt;VirtualHost vvv.xxx.yyy.zzz:80&gt;
ServerAdmin hostmaster@magnet-id.com
DocumentRoot /path/to/rootwwwdir/public_html
ServerName virt2.magnet-id.com
ErrorLog logs/virt2.magnet-id.com-error_log
CustomLog logs/virt2.magnet-id.com-access_log common
&lt;/VirtualHost&gt;

###Empty the file
/etc/httpd/conf.d/welcome.conf
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.tajidyakub.com/web-servers/installation-and-basic-configuration-apache-mysql-and-php-on-centos-51-64-bit-2008-06-27.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Securing MySQL Installation</title>
		<link>http://www.tajidyakub.com/web-database/securing-mysql-installation-2008-06-27.html</link>
		<comments>http://www.tajidyakub.com/web-database/securing-mysql-installation-2008-06-27.html#comments</comments>
		<pubDate>Thu, 26 Jun 2008 17:11:41 +0000</pubDate>
		<dc:creator>Tajid Yakub</dc:creator>
				<category><![CDATA[Web Database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[securing]]></category>

		<guid isPermaLink="false">http://tajidyakub.com/?p=6</guid>
		<description><![CDATA[This is the step for standard security implementation to a fresh MySQL installation; it will; Give the root password Remove anonymous users Disallow root login remotely Remove test database and access to it Reload privilege tables If you answer Y (Yes) to all question. Notice the error log on the output below is because this [...]]]></description>
			<content:encoded><![CDATA[<p>This is the step for standard security implementation to a fresh MySQL installation; it will;</p>
<ul>
<li>Give the root password</li>
<li>Remove anonymous users</li>
<li>Disallow root login remotely</li>
<li>Remove test database and access to it</li>
<li>Reload privilege tables</li>
</ul>
<p>If you answer Y (Yes) to all question. Notice the error log on the output below is because this is not the first time I ran it.</p>
<p><span id="more-6"></span></p>
<pre class="brush: bash">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>
]]></content:encoded>
			<wfw:commentRss>http://www.tajidyakub.com/web-database/securing-mysql-installation-2008-06-27.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding MySQL User</title>
		<link>http://www.tajidyakub.com/web-database/adding-mysql-user-2008-06-26.html</link>
		<comments>http://www.tajidyakub.com/web-database/adding-mysql-user-2008-06-26.html#comments</comments>
		<pubDate>Thu, 26 Jun 2008 16:56:27 +0000</pubDate>
		<dc:creator>Tajid Yakub</dc:creator>
				<category><![CDATA[Web Database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[user]]></category>

		<guid isPermaLink="false">http://tajidyakub.com/?p=5</guid>
		<description><![CDATA[This one from MySQL Docs; mysql --user=root mysql -p Insert your MySQL root password, it will jump you to mysql database (keeping user account information); mysql&#62; GRANT ALL PRIVILEGES ON *.* TO &#039;username&#039;@&#039;localhost&#039; -&#62; IDENTIFIED BY &#039;some_pass&#039; WITH GRANT OPTION; mysql&#62; GRANT ALL PRIVILEGES ON *.* TO &#039;username&#039;@&#039;%&#039; -&#62; IDENTIFIED BY &#039;some_pass&#039; WITH GRANT OPTION; [...]]]></description>
			<content:encoded><![CDATA[<p>This one from <a title="Adding User MySQL" href="http://dev.mysql.com/doc/refman/5.0/en/adding-users.html" target="_blank">MySQL Docs</a>;</p>
<pre class="brush: bash">

mysql --user=root mysql -p
</pre>
<p>Insert your MySQL root password, it will jump you to mysql database (keeping user account information);</p>
<pre class="brush: bash">

mysql&gt; GRANT ALL PRIVILEGES ON *.* TO &#039;username&#039;@&#039;localhost&#039;
-&gt;     IDENTIFIED BY &#039;some_pass&#039; WITH GRANT OPTION;
mysql&gt; GRANT ALL PRIVILEGES ON *.* TO &#039;username&#039;@&#039;%&#039;
-&gt;     IDENTIFIED BY &#039;some_pass&#039; WITH GRANT OPTION;
</pre>
<p>This is when you want the spesific user to have all access to all database from anywhere (username@%)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tajidyakub.com/web-database/adding-mysql-user-2008-06-26.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

