<?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>System Network Programming Solution - Linux - windows - centos- security- cpanel - plesk -directadmin helm&#187; Mysql</title>
	<atom:link href="http://thegioinguonmo.com/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://thegioinguonmo.com</link>
	<description>SHARING EVERYTHING</description>
	<lastBuildDate>Mon, 06 Feb 2012 09:45:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>When To Use Indexes In MySQL</title>
		<link>http://thegioinguonmo.com/database-server/mysql/when-to-use-indexes-in-mysql.html</link>
		<comments>http://thegioinguonmo.com/database-server/mysql/when-to-use-indexes-in-mysql.html#comments</comments>
		<pubDate>Tue, 31 Jan 2012 21:43:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mysql]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[use]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=1275</guid>
		<description><![CDATA[This comes up in discussions almost every new project I work on, because it’s a very important thing to consider when designing a database. When deciding when and how to create an index in your MySQL database, it’s important to consider how the data is being used. Let’s say you have a database of employees. [...]]]></description>
			<content:encoded><![CDATA[<p>This comes up in discussions almost every new project I work on, because it’s a very important thing to consider when designing a database.</p>
<p>When deciding when and how to create an index in your MySQL database, it’s important to consider how the data is being used.</p>
<p>Let’s say you have a database of employees. We will create it like this:</p>
<blockquote>
<pre class="brush:plain">CREATE TABLE employees (
ID INT,
name VARCHAR(60),
salary decimal(10,2),
date hired(date)
)</pre>
</blockquote>
<p>So you will notice that this table is pretty simplistic, and doesn’t really contain all the info you would need to actually manage employees, but its just for the sake of demonstration, and you could always add more later, or even make another table and use joins if you had really complex needs.</p>
<p>For now we will go over these real quick.</p>
<p>The ID is basically just a number (INT) which can hold a very large number. If this were real world I would probably make it unsigned, since you will never have a negative employee ID – but either way, you will never reach the number of employees it would take to get to the number that would fill up an INT.</p>
<p>Even unsigned int will hold values up to 2,147,483,647. So if you have 2 billion employees, you would probably not be a developer anymore  .</p>
<p>You might want to consider making the field an auto increment, and primary key, the auto increment depending on how data will be entered into this database.</p>
<p>Name is a simple varchar(60) which should cover most people’s names.</p>
<p>Salary is a decimal with 10 total digits, two on the right hand side of the decimal point. This would handle a salary of up to 99,999,999.99 – again, you’re not likely to hit this limit.</p>
<p>Date hired will be a date in this format 2010-05-06. YYYY-MM-DD.</p>
<p>So when considering this simple table, where would you expect to need an index?<br />
If we assign ID as a primary key, we don’t need one there.</p>
<p>Indexes are best used on columns that are frequently used in where clauses, and in any kind of sorting, such as “order by”.</p>
<p>You should also pay attention to whether or not this information will change frequently, because it will slow down your updates and inserts. Since you wont frequently be adding employees, you don’t have to worry about the inserts.</p>
<p>Let’s say that you will be looking up the employees with a php web interface and the end user will be typing in the employees name to find them, since remembering the employee ID’s would be cumbersome.</p>
<p>It sounds like this situation would be good to use an index.</p>
<p>A – You won’t be updating the employee’s name very often, so you don’t have to worry about a performance hit there.</p>
<p>B – You WILL be using the employee in where clauses like this:</p>
<p><code>select * from employees where name ='smith';</code></p>
<p>C – You WILL be generating reports, which will probably be alphabetic, like this:</p>
<p><code>select * from employees order by name asc;</code></p>
<p>So in this simple example it’s easy to see when it would be important to use indexes.</p>
<p>So, you could do it like this:</p>
<p><code>create index name_index on employees (name);</code></p>
<p>You might be working on a more complex database, so it’s good to remember a few simple rules.</p>
<p>- Indexes slow down inserts and updates, so you want to use them carefully on columns that are FREQUENTLY updated.</p>
<p>- Indexes speed up where clauses and order by.</p>
<p>Remember to think about HOW your data is going to be used when building your tables.</p>
<p>There are a few other things to remember. If your table is very small, i.e., only a few employees, it’s worse to use an index than to leave it out and just let it do a table scan. Indexes really only come in handy with tables that have a lot of rows.</p>
<p>So, if Joe’s Pet Shop was using this database, they would probably be able to leave the index off the “name” column.</p>
<p>If Microsoft was using this database (hah!) they might want to throw and index in there.</p>
<p>Another thing to remember, that is a con in the situation of our employees database, is that if the column is a variable length, indexes (as well as most of MySQL) perform much less efficiently.</p>
<p>As you can see there are many things to consider with indexes, even with a very simple table as this.</p>
<p>I would suggest looking at the explain command in MySQL, which I will be writing about in the future.</p>
<p><a rel="nofollow" target="_blank" title="http://www.tsmonaghan.com" href="http://www.tsmonaghan.com/" target="_blank">http://www.tsmonaghan.com </a></p>
]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/database-server/mysql/when-to-use-indexes-in-mysql.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backup Databases in MySQL</title>
		<link>http://thegioinguonmo.com/database-server/mysql/backup-databases-in-mysql.html</link>
		<comments>http://thegioinguonmo.com/database-server/mysql/backup-databases-in-mysql.html#comments</comments>
		<pubDate>Fri, 20 Jan 2012 21:39:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mysql]]></category>
		<category><![CDATA[database server]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=799</guid>
		<description><![CDATA[How about backing up all the databases in the server? That’s an easy one, just use the –all-databases parameter to backup all the databases in the server in one step. mysqldump –all-databases&#62; alldatabases.sql How to Backing up only the Database Structure in MySQL You can backup only the database structure by telling mysqldump not to [...]]]></description>
			<content:encoded><![CDATA[<p>How about backing up all the databases in the server? That’s an easy one, just use the –all-databases parameter to backup all the databases in the server in one step.</p>
<blockquote dir="ltr">
<pre class="brush:shell">mysqldump –all-databases&gt; alldatabases.sql</pre>
</blockquote>
<p>How to Backing up only the Database Structure in MySQL<br />
You can backup only the database structure by telling mysqldump not to back up the data. You can do this by using the –no-data parameter when you call mysqldump.</p>
<blockquote dir="ltr">
<pre class="brush:shell">mysqldump –no-data –databases Customers Orders Comments &gt; structurebackup.sql</pre>
</blockquote>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/database-server/mysql/backup-databases-in-mysql.html" title="mysqlreport access denied for user">mysqlreport access denied for user</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/database-server/mysql/backup-databases-in-mysql.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Set Up WebDAV With Apache2 On CentOS 5.5</title>
		<link>http://thegioinguonmo.com/os/linux/set-webdav-apache2-centos-55.html</link>
		<comments>http://thegioinguonmo.com/os/linux/set-webdav-apache2-centos-55.html#comments</comments>
		<pubDate>Fri, 20 Jan 2012 10:02:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[webdav]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2212</guid>
		<description><![CDATA[This guide explains how to set up WebDAV with Apache2 on a CentOS 5.5 server. WebDAV stands for Web-based Distributed Authoring and Versioning and is a set of extensions to the HTTP protocol that allow users to directly edit files on the Apache server so that they do not need to be downloaded/uploaded via FTP. [...]]]></description>
			<content:encoded><![CDATA[<p>This guide explains how to set up WebDAV with Apache2 on a CentOS 5.5 server. WebDAV stands for <em>Web-based Distributed Authoring and Versioning</em> and is a set of extensions to the HTTP protocol that allow users to directly edit files on the Apache server so that they do not need to be downloaded/uploaded via FTP. Of course, WebDAV can also be used to upload and download files.</p>
<p>I do not issue any guarantee that this will work for you!</p>
<p>&nbsp;</p>
<h3>1 Preliminary Note</h3>
<p>I&#8217;m using a CentOS 5.5 server with the IP address 192.168.0.100 here.</p>
<p>&nbsp;</p>
<h3>2 Installing WebDAV</h3>
<p>If Apache is not already installed, install it as follows:</p>
<p>yum install httpd</p>
<p>Afterwards, open /etc/httpd/conf/httpd.conf and make sure that the dav and dav_fs modules are enabled in the LoadModule section (they should be enabled by default):</p>
<p>vi /etc/httpd/conf/httpd.conf</p>
<table width="90%" border="1" cellspacing="0" cellpadding="2" align="center" bgcolor="#cccccc">
<tbody>
<tr>
<td>
<pre>[...]
LoadModule dav_module modules/mod_dav.so
[...]
LoadModule dav_fs_module modules/mod_dav_fs.so
[...]</pre>
</td>
</tr>
</tbody>
</table>
<p>Then create the system startup links for Apache and start it:</p>
<p>chkconfig &#8211;levels 235 httpd on<br />
/etc/init.d/httpd start</p>
<p>&nbsp;</p>
<h3>3 Creating A Virtual Host</h3>
<p>I will now create a default Apache vhost in the directory /var/www/web1/web. For this purpose, I will add a default vhost at the end of /etc/httpd/conf/httpd.conf. If you already have a vhost for which you&#8217;d like to enable WebDAV, you must adjust this tutorial to your situation.</p>
<p>First, we create the directory /var/www/web1/web and make the Apache user and group (apache) the owner of that directory:</p>
<p>mkdir -p /var/www/web1/web<br />
chown apache:apache /var/www/web1/web</p>
<p>Then add the new vhost at the end of /etc/httpd/conf/httpd.conf:</p>
<p>vi /etc/httpd/conf/httpd.conf</p>
<table width="90%" border="1" cellspacing="0" cellpadding="2" align="center" bgcolor="#cccccc">
<tbody>
<tr>
<td>
<pre>[...]
NameVirtualHost *:80
&lt;VirtualHost *:80&gt;
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www/web1/web/
        &lt;Directory /var/www/web1/web/&gt;
                Options Indexes MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        &lt;/Directory&gt;

&lt;/VirtualHost&gt;</pre>
</td>
</tr>
</tbody>
</table>
<p>Then reload Apache:</p>
<p>/etc/init.d/httpd reload</p>
<p>&nbsp;</p>
<h3>4 Configure The Virtual Host For WebDAV</h3>
<p>Now we create the WebDAV password file /var/www/web1/passwd.dav with the user test (the -c switch creates the file if it does not exist):</p>
<p>htpasswd -c /var/www/web1/passwd.dav test</p>
<p>You will be asked to type in a password for the user test.</p>
<p>(Please don&#8217;t use the -c switch if /var/www/web1/passwd.dav is already existing because this will recreate the file from scratch, meaning you lose all users in that file!)</p>
<p>Now we change the permissions of the /var/www/web1/passwd.dav file so that only root and the members of the apache group can access it:</p>
<p>chown root:apache /var/www/web1/passwd.dav<br />
chmod 640 /var/www/web1/passwd.dav</p>
<p>Now we modify our vhost at the end of /etc/httpd/conf/httpd.conf and add the following lines to it:</p>
<p>vi /etc/httpd/conf/httpd.conf</p>
<table width="90%" border="1" cellspacing="0" cellpadding="2" align="center" bgcolor="#cccccc">
<tbody>
<tr>
<td>
<pre>[...]
        Alias /webdav /var/www/web1/web

        &lt;Location /webdav&gt;
           DAV On
           AuthType Basic
           AuthName "webdav"
           AuthUserFile /var/www/web1/passwd.dav
           Require valid-user
       &lt;/Location&gt;
[...]</pre>
</td>
</tr>
</tbody>
</table>
<p>The Alias directive makes (together with &lt;Location&gt;) that when you call /webdav, WebDAV is invoked, but you can still access the whole document root of the vhost. All other URLs of that vhost are still &#8220;normal&#8221; HTTP.</p>
<p>The final vhost should look like this:</p>
<table width="90%" border="1" cellspacing="0" cellpadding="2" align="center" bgcolor="#cccccc">
<tbody>
<tr>
<td>
<pre>[...]
NameVirtualHost *:80
&lt;VirtualHost *:80&gt;
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www/web1/web/
        &lt;Directory /var/www/web1/web/&gt;
                Options Indexes MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        &lt;/Directory&gt;

        Alias /webdav /var/www/web1/web

        &lt;Location /webdav&gt;
           DAV On
           AuthType Basic
           AuthName "webdav"
           AuthUserFile /var/www/web1/passwd.dav
           Require valid-user
       &lt;/Location&gt;

&lt;/VirtualHost&gt;</pre>
</td>
</tr>
</tbody>
</table>
<p>Reload Apache afterwards:</p>
<p>/etc/init.d/httpd reload</p>
<p>&nbsp;</p>
<h3>5 Testing WebDAV</h3>
<p>We will now install cadaver, a command-line WebDAV client:</p>
<p>yum install cadaver</p>
<p>To test if WebDAV works, type:</p>
<p>cadaver http://localhost/webdav/</p>
<p>You should be prompted for a user name. Type in test and then the password for the user test. If all goes well, you should be granted access which means WebDAV is working ok. Type quit to leave the WebDAV shell:</p>
<p>[root@server1 ~]# cadaver http://localhost/webdav/<br />
Authentication required for webdav on server `localhost&#8217;:<br />
Username: test<br />
Password:<br />
dav:/webdav/&gt; quit<br />
Connection to `localhost&#8217; closed.<br />
[root@server1 ~]#</p>
<h3>6 Configure A Windows XP Client To Connect To The WebDAV Share</h3>
<div></div>
<p>Click on My Network Places on your desktop (I have a German Windows, so the names are a bit different in the screenshots):</p>
<p><img src="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/1.jpg" alt="1 How To Set Up WebDAV With Apache2 On CentOS 5.5" width="118" height="154" title="How To Set Up WebDAV With Apache2 On CentOS 5.5" /></p>
<p>Select Add a Network Place from the Network Tasks menu (on the left):</p>
<p><img src="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/2.png" alt="2 How To Set Up WebDAV With Apache2 On CentOS 5.5" width="302" height="532" title="How To Set Up WebDAV With Apache2 On CentOS 5.5" /></p>
<p>The Add Network Place Wizard comes up. Click on the Next button:</p>
<p><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/big/3.png"><img src="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/3.png" alt="3 How To Set Up WebDAV With Apache2 On CentOS 5.5" width="550" height="455" title="How To Set Up WebDAV With Apache2 On CentOS 5.5" /></a></p>
<div><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/big/3.png"><img src="http://static.howtoforge.com/images/click_to_enlarge.png" alt="click to enlarge How To Set Up WebDAV With Apache2 On CentOS 5.5" width="100" height="12" border="0" title="How To Set Up WebDAV With Apache2 On CentOS 5.5" /> </a></div>
<p>Select Choose another network location, and click on Next:</p>
<p><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/big/4.png"><img src="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/4.png" alt="4 How To Set Up WebDAV With Apache2 On CentOS 5.5" width="550" height="456" title="How To Set Up WebDAV With Apache2 On CentOS 5.5" /></a></p>
<div><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/big/4.png"><img src="http://static.howtoforge.com/images/click_to_enlarge.png" alt="click to enlarge How To Set Up WebDAV With Apache2 On CentOS 5.5" width="100" height="12" border="0" title="How To Set Up WebDAV With Apache2 On CentOS 5.5" /> </a></div>
<p>Enter http://192.168.0.100:80/webdav as the location and click on Next. You must specify the port in the WebDAV URL (:80). For some strange reason this makes Windows XP accept the normal username (e.g. test) &#8211; otherwise Windows XP expects NTLM usernames (that would have the form www.example.com\test).</p>
<p><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/big/5.png"><img src="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/5.png" alt="5 How To Set Up WebDAV With Apache2 On CentOS 5.5" width="550" height="456" title="How To Set Up WebDAV With Apache2 On CentOS 5.5" /></a></p>
<div><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/big/5.png"><img src="http://static.howtoforge.com/images/click_to_enlarge.png" alt="click to enlarge How To Set Up WebDAV With Apache2 On CentOS 5.5" width="100" height="12" border="0" title="How To Set Up WebDAV With Apache2 On CentOS 5.5" /> </a></div>
<p>You will be prompted for a user name and a password. Type in the user name test and the password for the user test:</p>
<p><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/big/6.png"><img src="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/6.png" alt="6 How To Set Up WebDAV With Apache2 On CentOS 5.5" width="550" height="434" title="How To Set Up WebDAV With Apache2 On CentOS 5.5" /></a></p>
<div><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/big/6.png"><img src="http://static.howtoforge.com/images/click_to_enlarge.png" alt="click to enlarge How To Set Up WebDAV With Apache2 On CentOS 5.5" width="100" height="12" border="0" title="How To Set Up WebDAV With Apache2 On CentOS 5.5" /> </a></div>
<p>Then type in a name for the WebDAV folder:</p>
<p><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/big/7.png"><img src="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/7.png" alt="7 How To Set Up WebDAV With Apache2 On CentOS 5.5" width="550" height="457" title="How To Set Up WebDAV With Apache2 On CentOS 5.5" /></a></p>
<div><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/big/7.png"><img src="http://static.howtoforge.com/images/click_to_enlarge.png" alt="click to enlarge How To Set Up WebDAV With Apache2 On CentOS 5.5" width="100" height="12" border="0" title="How To Set Up WebDAV With Apache2 On CentOS 5.5" /> </a></div>
<p>To open the new connection, keep the Open this network place when I click Finish box checked, and click on Finish:</p>
<p><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/big/8.png"><img src="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/8.png" alt="8 How To Set Up WebDAV With Apache2 On CentOS 5.5" width="550" height="454" title="How To Set Up WebDAV With Apache2 On CentOS 5.5" /></a></p>
<div><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/big/8.png"><img src="http://static.howtoforge.com/images/click_to_enlarge.png" alt="click to enlarge How To Set Up WebDAV With Apache2 On CentOS 5.5" width="100" height="12" border="0" title="How To Set Up WebDAV With Apache2 On CentOS 5.5" /> </a></div>
<p>The WebDAV folder will then open where you can browse the contents of the /var/www/web1/web directory and its subdirectories on the server, and you will find an icon for your new WebDAV share in the My Network Places folder:</p>
<p><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/big/9.png"><img src="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/9.png" alt="9 How To Set Up WebDAV With Apache2 On CentOS 5.5" width="550" height="501" title="How To Set Up WebDAV With Apache2 On CentOS 5.5" /></a></p>
<h3>7 Configure A Linux Client (GNOME) To Connect To The WebDAV Share</h3>
<div></div>
<p>If you want to connect to the WebDAV share from a GNOME desktop, go to Places &gt; Connect to Server&#8230;:</p>
<p><img src="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/10.jpg" alt="10 How To Set Up WebDAV With Apache2 On CentOS 5.5" width="550" height="438" title="How To Set Up WebDAV With Apache2 On CentOS 5.5" /></p>
<p>Select WebDAV (HTTP) as the Service type, type in the Server (192.168.0.100 in this example) and then the Folder (webdav). Do not fill in a User Name yet because otherwise the connection will fail. Click on Connect afterwards:</p>
<p><img src="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/11.jpg" alt="11 How To Set Up WebDAV With Apache2 On CentOS 5.5" width="360" height="364" title="How To Set Up WebDAV With Apache2 On CentOS 5.5" /></p>
<p>Now you are being prompted for a user name and password. Type in test along with the password, then click on Connect:</p>
<p><img src="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/12.jpg" alt="12 How To Set Up WebDAV With Apache2 On CentOS 5.5" width="370" height="290" title="How To Set Up WebDAV With Apache2 On CentOS 5.5" /></p>
<p>You might get the following error&#8230;</p>
<p><img src="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/13.jpg" alt="13 How To Set Up WebDAV With Apache2 On CentOS 5.5" width="368" height="188" title="How To Set Up WebDAV With Apache2 On CentOS 5.5" /></p>
<p>&#8230; but at the same time the WebDAV share should appear on the desktop, which means you can ignore the error:</p>
<p><img src="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/14.jpg" alt="14 How To Set Up WebDAV With Apache2 On CentOS 5.5" width="148" height="94" title="How To Set Up WebDAV With Apache2 On CentOS 5.5" /></p>
<p>Double-click on the icon to open the WebDAV share:</p>
<p><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/big/15.png"><img src="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/15.png" alt="15 How To Set Up WebDAV With Apache2 On CentOS 5.5" width="550" height="440" title="How To Set Up WebDAV With Apache2 On CentOS 5.5" /></a></p>
<div><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/apache2_webdav_fedora_5.5/big/15.png"><img src="http://static.howtoforge.com/images/click_to_enlarge.png" alt="click to enlarge How To Set Up WebDAV With Apache2 On CentOS 5.5" width="100" height="12" border="0" title="How To Set Up WebDAV With Apache2 On CentOS 5.5" /> </a></div>
<p>&nbsp;</p>
<h3>8 Links</h3>
<ul>
<li>WebDAV: <a rel="nofollow" target="_blank" href="http://www.webdav.org/" target="_blank">http://www.webdav.org/</a></li>
<li>Apache: <a rel="nofollow" target="_blank" href="http://httpd.apache.org/" target="_blank">http://httpd.apache.org/</a></li>
<li>CentOS: <a rel="nofollow" target="_blank" href="http://www.centos.org/" target="_blank">http://www.centos.org/</a></li>
</ul>
<p>&nbsp;</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/os/linux/set-webdav-apache2-centos-55.html" title="directadmin webdav">directadmin webdav</a> (3)</li><li><a href="http://thegioinguonmo.com/os/linux/set-webdav-apache2-centos-55.html" title="webdav directadmin">webdav directadmin</a> (2)</li><li><a href="http://thegioinguonmo.com/os/linux/set-webdav-apache2-centos-55.html" title="apache dav">apache dav</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/set-webdav-apache2-centos-55.html" title="webdav centos howto">webdav centos howto</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/set-webdav-apache2-centos-55.html" title="webdav centos">webdav centos</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/set-webdav-apache2-centos-55.html" title="webdav apache http web server windows 7">webdav apache http web server windows 7</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/set-webdav-apache2-centos-55.html" title="server dav">server dav</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/set-webdav-apache2-centos-55.html" title="how to configure webdav on different centos port">how to configure webdav on different centos port</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/set-webdav-apache2-centos-55.html" title="connect to cpanel webdav on centos">connect to cpanel webdav on centos</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/set-webdav-apache2-centos-55.html" title="centos upload to webdav">centos upload to webdav</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/os/linux/set-webdav-apache2-centos-55.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Apache2 With PHP5 And MySQL Support On CentOS 5.5 (LAMP)</title>
		<link>http://thegioinguonmo.com/os/linux/installing-apache2-php5-mysql-support-centos-55-lamp.html</link>
		<comments>http://thegioinguonmo.com/os/linux/installing-apache2-php5-mysql-support-centos-55-lamp.html#comments</comments>
		<pubDate>Fri, 20 Jan 2012 09:57:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2209</guid>
		<description><![CDATA[LAMP is short for Linux, Apache, MySQL, PHP. This tutorial shows how you can install an Apache2 webserver on a CentOS 5.5 server with PHP5 support (mod_php) and MySQL support. I do not issue any guarantee that this will work for you! &#160; 1 Preliminary Note In this tutorial I use the hostname server1.example.com with [...]]]></description>
			<content:encoded><![CDATA[<p>LAMP is short for <strong>L</strong>inux, <strong>A</strong>pache, <strong>M</strong>ySQL, <strong>P</strong>HP. This tutorial shows how you can install an Apache2 webserver on a CentOS 5.5 server with PHP5 support (mod_php) and MySQL support.</p>
<p>I do not issue any guarantee that this will work for you!</p>
<p>&nbsp;</p>
<h3>1 Preliminary Note</h3>
<p>In this tutorial I use the hostname server1.example.com with the IP address 192.168.0.100. These settings might differ for you, so you have to replace them where appropriate.</p>
<p>&nbsp;</p>
<h3>2 Installing MySQL 5.0</h3>
<p>To install MySQL, we do this:</p>
<p>yum install mysql mysql-server</p>
<p>Then we create the system startup links for MySQL (so that MySQL starts automatically whenever the system boots) and start the MySQL server:</p>
<p>chkconfig &#8211;levels 235 mysqld on<br />
/etc/init.d/mysqld start</p>
<p>Set passwords for the MySQL root account:</p>
<p>mysql_secure_installation</p>
<p>[root@server1 ~]# mysql_secure_installation</p>
<p>NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL<br />
SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!</p>
<p>In order to log into MySQL to secure it, we&#8217;ll need the current<br />
password for the root user.  If you&#8217;ve just installed MySQL, and<br />
you haven&#8217;t set the root password yet, the password will be blank,<br />
so you should just press enter here.</p>
<p>Enter current password for root (enter for none):<br />
OK, successfully used password, moving on&#8230;</p>
<p>Setting the root password ensures that nobody can log into the MySQL<br />
root user without the proper authorisation.</p>
<p>Set root password? [Y/n] &lt;&#8211; ENTER<br />
New password: &lt;&#8211; yourrootsqlpassword<br />
Re-enter new password: &lt;&#8211; yourrootsqlpassword<br />
Password updated successfully!<br />
Reloading privilege tables..<br />
&#8230; Success!</p>
<p>By default, a MySQL installation has an anonymous user, allowing anyone<br />
to log into MySQL without having to have a user account created for<br />
them.  This is intended only for testing, and to make the installation<br />
go a bit smoother.  You should remove them before moving into a<br />
production environment.</p>
<p>Remove anonymous users? [Y/n] &lt;&#8211; ENTER<br />
&#8230; Success!</p>
<p>Normally, root should only be allowed to connect from &#8217;localhost&#8217;.  This<br />
ensures that someone cannot guess at the root password from the network.</p>
<p>Disallow root login remotely? [Y/n] &lt;&#8211; ENTER<br />
&#8230; Success!</p>
<p>By default, MySQL comes with a database named &#8217;test&#8217; that anyone can<br />
access.  This is also intended only for testing, and should be removed<br />
before moving into a production environment.</p>
<p>Remove test database and access to it? [Y/n] &lt;&#8211; ENTER<br />
- Dropping test database&#8230;<br />
&#8230; Success!<br />
- Removing privileges on test database&#8230;<br />
&#8230; Success!</p>
<p>Reloading the privilege tables will ensure that all changes made so far<br />
will take effect immediately.</p>
<p>Reload privilege tables now? [Y/n] &lt;&#8211; ENTER<br />
&#8230; Success!</p>
<p>Cleaning up&#8230;</p>
<p>All done!  If you&#8217;ve completed all of the above steps, your MySQL<br />
installation should now be secure.</p>
<p>Thanks for using MySQL!</p>
<p>[root@server1 ~]#</p>
<p>&nbsp;</p>
<h3>3 Installing Apache2</h3>
<p>Apache2 is available as a CentOS package, therefore we can install it like this:</p>
<p>yum install httpd</p>
<p>Now configure your system to start Apache at boot time&#8230;</p>
<p>chkconfig &#8211;levels 235 httpd on</p>
<p>&#8230; and start Apache:</p>
<p>/etc/init.d/httpd start</p>
<p>Now direct your browser to http://192.168.0.100, and you should see the Apache2 placeholder page:</p>
<p><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/lamp_centos_5.5/big/1.png"><img src="http://static.howtoforge.com/images/lamp_centos_5.5/1.png" alt="1 Installing Apache2 With PHP5 And MySQL Support On CentOS 5.5 (LAMP)" width="550" height="399" title="Installing Apache2 With PHP5 And MySQL Support On CentOS 5.5 (LAMP)" /></a></p>
<div><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/lamp_centos_5.5/big/1.png"><img src="http://static.howtoforge.com/images/click_to_enlarge.png" alt="click to enlarge Installing Apache2 With PHP5 And MySQL Support On CentOS 5.5 (LAMP)" width="100" height="12" border="0" title="Installing Apache2 With PHP5 And MySQL Support On CentOS 5.5 (LAMP)" /> </a></div>
<p>Apache&#8217;s default document root is /var/www/html on CentOS, and the configuration file is /etc/httpd/conf/httpd.conf. Additional configurations are stored in the /etc/httpd/conf.d/ directory.</p>
<p>&nbsp;</p>
<h3>4 Installing PHP5</h3>
<p>We can install PHP5 and the Apache PHP5 module as follows:</p>
<p>yum install php</p>
<p>We must restart Apache afterwards:</p>
<p>/etc/init.d/httpd restart</p>
<h3>5 Testing PHP5 / Getting Details About Your PHP5 Installation</h3>
<div></div>
<p>The document root of the default web site is /var/www/html. We will now create a small PHP file (info.php) in that directory and call it in a browser. The file will display lots of useful details about our PHP installation, such as the installed PHP version.</p>
<p>vi /var/www/html/info.php</p>
<table width="90%" border="1" cellspacing="0" cellpadding="2" align="center" bgcolor="#cccccc">
<tbody>
<tr>
<td>
<pre>&lt;?php
phpinfo();
?&gt;</pre>
</td>
</tr>
</tbody>
</table>
<p>Now we call that file in a browser (e.g. http://192.168.0.100/info.php):</p>
<p><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/lamp_centos_5.5/big/2.png"><img src="http://static.howtoforge.com/images/lamp_centos_5.5/2.png" alt="2 Installing Apache2 With PHP5 And MySQL Support On CentOS 5.5 (LAMP)" width="550" height="399" title="Installing Apache2 With PHP5 And MySQL Support On CentOS 5.5 (LAMP)" /></a></p>
<div><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/lamp_centos_5.5/big/2.png"><img src="http://static.howtoforge.com/images/click_to_enlarge.png" alt="click to enlarge Installing Apache2 With PHP5 And MySQL Support On CentOS 5.5 (LAMP)" width="100" height="12" border="0" title="Installing Apache2 With PHP5 And MySQL Support On CentOS 5.5 (LAMP)" /> </a></div>
<p>As you see, PHP5 is working, and it&#8217;s working through the Apache 2.0 Handler, as shown in the Server API line. If you scroll further down, you will see all modules that are already enabled in PHP5. MySQL is not listed there which means we don&#8217;t have MySQL support in PHP5 yet.</p>
<p>&nbsp;</p>
<h3>6 Getting MySQL Support In PHP5</h3>
<p>To get MySQL support in PHP, we can install the php-mysql package. It&#8217;s a good idea to install some other PHP5 modules as well as you might need them for your applications. You can search for available PHP5 modules like this:</p>
<p>yum search php</p>
<p>Pick the ones you need and install them like this:</p>
<p>yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc</p>
<p>Now restart Apache2:</p>
<p>/etc/init.d/httpd restart</p>
<p>Now reload http://192.168.0.100/info.php in your browser and scroll down to the modules section again. You should now find lots of new modules there, including the MySQL module:</p>
<p><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/lamp_centos_5.5/big/3.png"><img src="http://static.howtoforge.com/images/lamp_centos_5.5/3.png" alt="3 Installing Apache2 With PHP5 And MySQL Support On CentOS 5.5 (LAMP)" width="550" height="399" title="Installing Apache2 With PHP5 And MySQL Support On CentOS 5.5 (LAMP)" /></a></p>
<div><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/lamp_centos_5.5/big/3.png"><img src="http://static.howtoforge.com/images/click_to_enlarge.png" alt="click to enlarge Installing Apache2 With PHP5 And MySQL Support On CentOS 5.5 (LAMP)" width="100" height="12" border="0" title="Installing Apache2 With PHP5 And MySQL Support On CentOS 5.5 (LAMP)" /> </a></div>
<p>&nbsp;</p>
<h3>7 phpMyAdmin</h3>
<p><a rel="nofollow" target="_blank" href="http://www.phpmyadmin.net/" target="_blank">phpMyAdmin</a> is a web interface through which you can manage your MySQL databases.</p>
<p>First we enable the <a rel="nofollow" target="_blank" href="https://rpmrepo.org/RPMforge/Using" target="_blank">RPMforge repository</a> on our CentOS system as phpMyAdmin is not available in the official CentOS 5.5 repositories:</p>
<p>On x86_64 systems:</p>
<p>wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm<br />
rpm -Uhv rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm</p>
<p>On i386 systems:</p>
<p>wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.i386.rpm<br />
rpm -Uhv rpmforge-release-0.5.1-1.el5.rf.i386.rpm</p>
<p>phpMyAdmin can now be installed as follows:</p>
<p>yum install phpmyadmin</p>
<p>Now we configure phpMyAdmin. We change the Apache configuration so that phpMyAdmin allows connections not just from localhost (by commenting out the &lt;Directory &#8220;/usr/share/phpmyadmin&#8221;&gt; stanza):</p>
<p>vi /etc/httpd/conf.d/phpmyadmin.conf</p>
<table width="90%" border="1" cellspacing="0" cellpadding="2" align="center" bgcolor="#cccccc">
<tbody>
<tr>
<td>
<pre>#
#  Web application to manage MySQL
#

#&lt;Directory "/usr/share/phpmyadmin"&gt;
#  Order Deny,Allow
#  Deny from all
#  Allow from 127.0.0.1
#&lt;/Directory&gt;

Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /mysqladmin /usr/share/phpmyadmin</pre>
</td>
</tr>
</tbody>
</table>
<p>Next we change the authentication in phpMyAdmin from cookie to http:</p>
<p>vi /usr/share/phpmyadmin/config.inc.php</p>
<table width="90%" border="1" cellspacing="0" cellpadding="2" align="center" bgcolor="#cccccc">
<tbody>
<tr>
<td>
<pre>[...]
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'http';
[...]</pre>
</td>
</tr>
</tbody>
</table>
<p>Restart Apache:</p>
<p>/etc/init.d/httpd restart</p>
<p>Afterwards, you can access phpMyAdmin under http://192.168.0.100/phpmyadmin/:</p>
<p><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/lamp_centos_5.5/big/4.png"><img src="http://static.howtoforge.com/images/lamp_centos_5.5/4.png" alt="4 Installing Apache2 With PHP5 And MySQL Support On CentOS 5.5 (LAMP)" width="550" height="399" title="Installing Apache2 With PHP5 And MySQL Support On CentOS 5.5 (LAMP)" /></a></p>
<div><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/lamp_centos_5.5/big/4.png"><img src="http://static.howtoforge.com/images/click_to_enlarge.png" alt="click to enlarge Installing Apache2 With PHP5 And MySQL Support On CentOS 5.5 (LAMP)" width="100" height="12" border="0" title="Installing Apache2 With PHP5 And MySQL Support On CentOS 5.5 (LAMP)" /> </a></div>
<p>&nbsp;</p>
<h3>8 Links</h3>
<ul>
<li>Apache: <a rel="nofollow" target="_blank" href="http://httpd.apache.org/" target="_blank">http://httpd.apache.org/</a></li>
<li>PHP: <a rel="nofollow" target="_blank" href="http://www.php.net/" target="_blank">http://www.php.net/</a></li>
<li>MySQL: <a rel="nofollow" target="_blank" href="http://www.mysql.com/" target="_blank">http://www.mysql.com/</a></li>
<li>CentOS: <a rel="nofollow" target="_blank" href="http://www.centos.org/" target="_blank">http://www.centos.org/</a></li>
<li>phpMyAdmin: <a rel="nofollow" target="_blank" href="http://www.phpmyadmin.net/" target="_blank">http://www.phpmyadmin.net/</a></li>
</ul>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/os/linux/installing-apache2-php5-mysql-support-centos-55-lamp.html" title="centos 5 5 phpmyadmin installation">centos 5 5 phpmyadmin installation</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/installing-apache2-php5-mysql-support-centos-55-lamp.html" title="centos vmware installed with php apache mysql and cpanel">centos vmware installed with php apache mysql and cpanel</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/installing-apache2-php5-mysql-support-centos-55-lamp.html" title="centos yum mod_php">centos yum mod_php</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/installing-apache2-php5-mysql-support-centos-55-lamp.html" title="install phpmyadmin in var/www/html folder in centos 5 5">install phpmyadmin in var/www/html folder in centos 5 5</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/os/linux/installing-apache2-php5-mysql-support-centos-55-lamp.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shell script to backup MySql database</title>
		<link>http://thegioinguonmo.com/database-server/mysql/shell-script-to-backup-mysql-database.html</link>
		<comments>http://thegioinguonmo.com/database-server/mysql/shell-script-to-backup-mysql-database.html#comments</comments>
		<pubDate>Sat, 14 Jan 2012 09:47:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mysql]]></category>
		<category><![CDATA[shell script]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=372</guid>
		<description><![CDATA[#!/bin/bash # Shell script to backup MySql database # To backup Nysql databases file to /backup dir and later pick up by your # script. You can skip few databases from backup too. # ——————————————————————– # This is a free shell script under GNU GPL version 2.0 or above # Copyright (C) 2004, 2005 nixCraft [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>#!/bin/bash<br />
# Shell script to backup MySql database<br />
# To backup Nysql databases file to /backup dir and later pick up by your<br />
# script. You can skip few databases from backup too.<br />
# ——————————————————————–<br />
# This is a free shell script under GNU GPL version 2.0 or above<br />
# Copyright (C) 2004, 2005 nixCraft project<br />
# ————————————————————————-</p>
<p>MyUSER=“SET-MYSQL-USER-NAME” # USERNAME<br />
MyPASS=“SET-PASSWORD” # PASSWORD<br />
MyHOST=“localhost” # Hostname</p>
<p># Linux bin paths, change this if it can‘t be autodetected via which command<br />
MYSQL=”$(which mysql)”<br />
MYSQLDUMP=”$(which mysqldump)”<br />
CHOWN=”$(which chown)”<br />
CHMOD=”$(which chmod)”<br />
GZIP=”$(which gzip)”</p>
<p># Backup Dest directory, change this if you have someother location<br />
DEST=”/backup”</p>
<p># Main directory where backup will be stored<br />
MBD=”$DEST/mysql”</p>
<p># Get hostname<br />
HOST=”$(hostname)”</p>
<p># Get data in dd-mm-yyyy format<br />
NOW=”$(date +”%d-%m-%Y”)”</p>
<p># File to store current backup file<br />
FILE=”&#8221;<br />
# Store list of databases<br />
DBS=”&#8221;</p>
<p># DO NOT BACKUP these databases<br />
IGGY=”test”</p>
<p>[ ! -d $MBD ] &amp;&amp; mkdir -p $MBD || :</p>
<p># Only root can access it!<br />
$CHOWN 0.0 -R $DEST<br />
$CHMOD 0600 $DEST</p>
<p># Get all database list first<br />
DBS=”$($MYSQL -u $MyUSER -h $MyHOST -p$MyPASS -Bse ‘show databases‘)”</p>
<p>for db in $DBS<br />
do<br />
skipdb=-1<br />
if [ "$IGGY" != "" ];<br />
then<br />
for i in $IGGY<br />
do<br />
[ "$db" == "$i" ] &amp;&amp; skipdb=1 || :<br />
done<br />
fi</p>
<p>if [ "$skipdb" == "-1" ] ; then<br />
FILE=”$MBD/$db.$HOST.$NOW.gz”<br />
# do all inone job in pipe,<br />
# connect to mysql using mysqldump for select mysql database<br />
# and pipe it out to gz file in backup dir<br />
$MYSQLDUMP -u $MyUSER -h $MyHOST -p$MyPASS $db | $GZIP -9 &gt; $FILE<br />
fi<br />
done</p></blockquote>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/database-server/mysql/shell-script-to-backup-mysql-database.html" title="centos shell command backup oracle xe">centos shell command backup oracle xe</a> (1)</li><li><a href="http://thegioinguonmo.com/database-server/mysql/shell-script-to-backup-mysql-database.html" title="how to monitor remote machine using icinga in ubuntu 11 04">how to monitor remote machine using icinga in ubuntu 11 04</a> (1)</li><li><a href="http://thegioinguonmo.com/database-server/mysql/shell-script-to-backup-mysql-database.html" title="how to set backup system for mysql database">how to set backup system for mysql database</a> (1)</li><li><a href="http://thegioinguonmo.com/database-server/mysql/shell-script-to-backup-mysql-database.html" title="mysql Access denied for user -localhost">mysql Access denied for user -localhost</a> (1)</li><li><a href="http://thegioinguonmo.com/database-server/mysql/shell-script-to-backup-mysql-database.html" title="shell cpanel">shell cpanel</a> (1)</li><li><a href="http://thegioinguonmo.com/database-server/mysql/shell-script-to-backup-mysql-database.html" title="shell script to backup mysql database on windows">shell script to backup mysql database on windows</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/database-server/mysql/shell-script-to-backup-mysql-database.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysqldump: Got error: 1016: Can’t open file: … (errno: 24) when using LOCK TABLES</title>
		<link>http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1016-open-file-errno-24-lock-tables.html</link>
		<comments>http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1016-open-file-errno-24-lock-tables.html#comments</comments>
		<pubDate>Tue, 03 Jan 2012 14:08:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mysql]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[database server]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql database]]></category>
		<category><![CDATA[MYSQLDUMP]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2141</guid>
		<description><![CDATA[Sometimes, when you have got a large number of tables in your database and while taking the dump of that particular database, you would have encountered this strange error mysqldump: Got error: 1016: Can't open file: '.\database\certain_table.frm' (errno: 24) when using LOCK TABLES There are two solutions to avoid this error 1. Set the following [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>Sometimes, when you have got a large number of tables in your database and while taking the dump of that particular database, you would have encountered this strange error</p>
<pre><span style="color: #ff0000;">mysqldump: Got error: 1016: Can't open file: '.\database\certain_table.frm' (errno: 24) when using LOCK TABLES</span></pre>
<p>There are two solutions to avoid this error</p>
<p>1. Set the following value to some higher number in your mysql database</p>
<pre class="brush:shell">set open-files-limit=20000</pre>
<p>2. or, While taking the mysql dump, use <em>–lock-tables=off</em> option.</p>
<pre class="brush:shell">mysqldump --lock-tables=off -u root -p db-with-lots-of-tables &gt; db.sql</pre>
</div>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1016-open-file-errno-24-lock-tables.html" title="1016 - can\t open file: \ /phpmyadmin/pma_history frm\ (errno: 24)">1016 - can\t open file: \ /phpmyadmin/pma_history frm\ (errno: 24)</a> (1)</li><li><a href="http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1016-open-file-errno-24-lock-tables.html" title="plesk to directadmn mysql">plesk to directadmn mysql</a> (1)</li><li><a href="http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1016-open-file-errno-24-lock-tables.html" title="plesk system database windows">plesk system database windows</a> (1)</li><li><a href="http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1016-open-file-errno-24-lock-tables.html" title="mysqldump: got error: 1016: cant open file: (errno: 24) when using lock tables">mysqldump: got error: 1016: cant open file: (errno: 24) when using lock tables</a> (1)</li><li><a href="http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1016-open-file-errno-24-lock-tables.html" title="mysqldump on windows plesk">mysqldump on windows plesk</a> (1)</li><li><a href="http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1016-open-file-errno-24-lock-tables.html" title="mysqldump lock-tables off">mysqldump lock-tables off</a> (1)</li><li><a href="http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1016-open-file-errno-24-lock-tables.html" title="mysqldump error output: mysqldump: got error: table directadmin">mysqldump error output: mysqldump: got error: table directadmin</a> (1)</li><li><a href="http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1016-open-file-errno-24-lock-tables.html" title="mysqldump error 1016">mysqldump error 1016</a> (1)</li><li><a href="http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1016-open-file-errno-24-lock-tables.html" title="mysqldump cant open file when using lock tables">mysqldump cant open file when using lock tables</a> (1)</li><li><a href="http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1016-open-file-errno-24-lock-tables.html" title="mysql error 1016 cant open file error no 24">mysql error 1016 cant open file error no 24</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1016-open-file-errno-24-lock-tables.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysqldump: Got error: 1045: Access denied for user</title>
		<link>http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1045-access-denied-user.html</link>
		<comments>http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1045-access-denied-user.html#comments</comments>
		<pubDate>Tue, 03 Jan 2012 14:06:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mysql]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql database]]></category>
		<category><![CDATA[MYSQLDUMP]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2138</guid>
		<description><![CDATA[Today working on a client project, a shell script which uses MySQL to dump the database, has got me into this error mysqldump: Got error: 1045: Access denied for user &#160; I was typically amazed getting this error because all my configurations were correct. I have created proper users to access MySQL database and correctly [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>Today working on a client project, a shell script which uses MySQL to dump the database, has got me into this error</p>
<blockquote>
<h3><span style="color: #ff0000;">mysqldump: Got error: 1045: Access denied for user</span></h3>
</blockquote>
<p>&nbsp;</p>
<p>I was typically amazed getting this error because all my configurations were correct. I have created proper users to access MySQL database and correctly configured the MySQL server settings. FYI, my script was on one server and the MySQL was running on a separate dedicated box. The connection between them were TCP based.</p>
<p>After few minutes of head hunching, I was able to figure out the problem. So if you got into the same problem any time, follow the following guidelines to get over with it:</p>
<p>1. Check that whether you have created the proper MySQL user and gave them the required permission. You can check the user permission by following command.</p>
<pre class="brush:shell">SHOW GRANTS FOR 'user'@'localhost';

SHOW GRANTS FOR 'user'@'192.168.1.1';</pre>
<p>If the permissions are not proper, you might think of providing it properly by</p>
<pre class="brush:shell">GRANT ALL ON database.* TO 'user'@'localhost' identified by 'password';</pre>
<p>2. Check whether you are including the host properly in case of remote MySQL connections.</p>
<pre class="brush:shell">mysql -h host -u user -p database</pre>
<p>3. Finally, if you have created user and didn’t restarted your MySQL server or ran following command, your MySQL user permissions will not take effect in-spite of creating them. (Ps. This was the issue I was having.)</p>
<pre class="brush:shell">FLUSH PRIVILEGES</pre>
<p>After running the above command, my script was able to connect to database properly.</p>
</div>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1045-access-denied-user.html" title="mysqldump: got error: 1045: access denied for user">mysqldump: got error: 1045: access denied for user</a> (3)</li><li><a href="http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1045-access-denied-user.html" title="cannot connect to mysql database access denied error 1045">cannot connect to mysql database access denied error 1045</a> (2)</li><li><a href="http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1045-access-denied-user.html" title="ERROR: MySql connection problem Access denied ocs inventory">ERROR: MySql connection problem Access denied ocs inventory</a> (1)</li><li><a href="http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1045-access-denied-user.html" title="mysql 1045 access denied for user remote">mysql 1045 access denied for user remote</a> (1)</li><li><a href="http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1045-access-denied-user.html" title="mysql error 1045 remote">mysql error 1045 remote</a> (1)</li><li><a href="http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1045-access-denied-user.html" title="mysqldump network">mysqldump network</a> (1)</li><li><a href="http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1045-access-denied-user.html" title="[mysql error 1045] access denied for user cpanel">[mysql error 1045] access denied for user cpanel</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/database-server/mysql/mysqldump-error-1045-access-denied-user.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Virtual Users And Domains With Postfix, Courier And MySQL (+ SMTP-AUTH, Quota, SpamAssassin, ClamAV) &#8211; Part 4</title>
		<link>http://thegioinguonmo.com/os/linux/virtual-users-and-domains-with-postfix-courier-and-mysql-smtp-auth-quota-spamassassin-clamav-part-4.html</link>
		<comments>http://thegioinguonmo.com/os/linux/virtual-users-and-domains-with-postfix-courier-and-mysql-smtp-auth-quota-spamassassin-clamav-part-4.html#comments</comments>
		<pubDate>Thu, 22 Dec 2011 04:39:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[clamav]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[nano]]></category>
		<category><![CDATA[Postfix]]></category>
		<category><![CDATA[Quota]]></category>
		<category><![CDATA[txt]]></category>
		<category><![CDATA[usr bin]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=29</guid>
		<description><![CDATA[8 Install Razor, Pyzor And DCC And Configure SpamAssassin Razor, Pyzor and DCC are spamfilters that use a collaborative filtering network. To install them, run apt-get install razor pyzor dcc-client Now we have to tell SpamAssassin to use these three programs. Edit /etc/spamassassin/local.cf so that it looks like this: # This is the right place [...]]]></description>
			<content:encoded><![CDATA[<p><strong><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: x-small;">8 Install Razor, Pyzor And DCC And Configure SpamAssassin</span></strong></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: x-small;">Razor, Pyzor and DCC are spamfilters that use a collaborative filtering network. To install them, run</span></p>
<p><em><span style="font-family: Courier New,Courier,mono; font-size: x-small;">apt-get install razor pyzor dcc-client</span></em></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: x-small;">Now we have to tell SpamAssassin to use these three programs. Edit <em><span style="font-family: Courier New,Courier,mono;">/etc/spamassassin/local.cf</span></em> so that it looks like this:</span></p>
<table width="90%" border="1" cellspacing="0" cellpadding="2" align="center" bgcolor="#cccccc">
<tbody>
<tr>
<td>
<pre># This is the right place to customize your installation of SpamAssassin.
#
# See 'perldoc Mail::SpamAssassin::Conf' for details of what can be
# tweaked.
#
###########################################################################
#
# rewrite_header Subject *****SPAM*****
# report_safe 1
# trusted_networks 212.17.35.
# lock_method flock

# dcc
use_dcc 1
dcc_path /usr/bin/dccproc
dcc_add_header 1
dcc_dccifd_path /usr/sbin/dccifd

#pyzor
use_pyzor 1
pyzor_path /usr/bin/pyzor
pyzor_add_header 1

#razor
use_razor2 1
razor_config /etc/razor/razor-agent.conf

#bayes
use_bayes 1
use_bayes_rules 1
bayes_auto_learn 1</pre>
</td>
</tr>
</tbody>
</table>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: x-small;">Run</span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: x-small;"><em><span style="font-family: Courier New,Courier,mono;">/etc/init.d/amavis restart</span></em></span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: x-small;">afterwards.</span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: x-small;">Now I want to insert some custom rulesets that can be found on the internet into SpamAssassin. I have tested those rulesets, and they make spam filtering a lot more effective. Create the file <em><span style="font-family: Courier New,Courier,mono;">/usr/local/sbin/sa_rules_update.sh</span></em>:</span></p>
<table width="90%" border="1" cellspacing="0" cellpadding="2" align="center" bgcolor="#cccccc">
<tbody>
<tr>
<td>
<pre><span style="font-size: xx-small;">#!/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/71_sare_redirect_pre3.0.0.cf -O 71_sare_redirect_pre3.0.0.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/70_sare_bayes_poison_nxm.cf -O 70_sare_bayes_poison_nxm.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/70_sare_html.cf -O 70_sare_html.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/70_sare_html4.cf -O 70_sare_html4.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/70_sare_html_x30.cf -O 70_sare_html_x30.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/70_sare_header0.cf -O 70_sare_header0.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/70_sare_header3.cf -O 70_sare_header3.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/70_sare_header_x30.cf -O 70_sare_header_x30.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/70_sare_specific.cf -O 70_sare_specific.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/70_sare_adult.cf -O 70_sare_adult.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/72_sare_bml_post25x.cf -O 72_sare_bml_post25x.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/99_sare_fraud_post25x.cf -O 99_sare_fraud_post25x.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/70_sare_spoof.cf -O 70_sare_spoof.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/70_sare_random.cf -O 70_sare_random.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/70_sare_oem.cf -O 70_sare_oem.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/70_sare_genlsubj0.cf -O 70_sare_genlsubj0.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/70_sare_genlsubj3.cf -O 70_sare_genlsubj3.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/70_sare_genlsubj_x30.cf -O 70_sare_genlsubj_x30.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/70_sare_unsub.cf -O 70_sare_unsub.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/70_sare_uri.cf -O 70_sare_uri.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://mywebpages.comcast.net/mkettler/sa/antidrug.cf -O antidrug.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.timj.co.uk/linux/bogus-virus-warnings.cf -O bogus-virus-warnings.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.yackley.org/sa-rules/evilnumbers.cf -O evilnumbers.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.stearns.org/sa-blacklist/random.current.cf -O random.current.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/88_FVGT_body.cf -O 88_FVGT_body.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/88_FVGT_rawbody.cf -O 88_FVGT_rawbody.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/88_FVGT_subject.cf -O 88_FVGT_subject.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/88_FVGT_headers.cf -O 88_FVGT_headers.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/88_FVGT_uri.cf -O 88_FVGT_uri.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/99_FVGT_DomainDigits.cf -O 99_FVGT_DomainDigits.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/99_FVGT_Tripwire.cf -O 99_FVGT_Tripwire.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.rulesemporium.com/rules/99_FVGT_meta.cf -O 99_FVGT_meta.cf &amp;&gt; /dev/null cd /etc/spamassassin/ &amp;&gt; /dev/null &amp;&amp; /usr/bin/wget http://www.nospamtoday.com/download/mime_validate.cf -O mime_validate.cf &amp;&gt; /dev/null /etc/init.d/amavis restart &amp;&gt; /dev/null exit 0</span></pre>
</td>
</tr>
</tbody>
</table>
<p><em><span style="font-family: Courier New,Courier,mono; font-size: x-small;">chmod 755 /usr/local/sbin/sa_rules_update.sh</span></em></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: x-small;">Then run that script once, it will fetch those rulesets and insert them into SpamAssassin:</span></p>
<p><span style="font-size: x-small;"><em><span style="font-family: Courier New,Courier,mono;">/usr/local/sbin/sa_rules_update.sh</span></em></span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: x-small;">We create a cron job so that those rulesets will be updated regularly. Run </span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: x-small;"><em><span style="font-family: Courier New,Courier,mono;">crontab -e</span></em></span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: x-small;">to open the cron job editor. Create following cron job:</span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: x-small;"><em><span style="font-family: Courier New,Courier,mono;">23 4 */2 * * /usr/local/sbin/sa_rules_update.sh &amp;&gt; /dev/null</span></em></span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: x-small;">This will update the rulesets every second day at 4.23h.</span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: x-small;">(Note (a little off-topic): on Debian Sarge<em><span style="font-family: Courier New,Courier,mono;"> crontab -e</span></em> will automatically open the editor <em><span style="font-family: Courier New,Courier,mono;">nano</span></em>. If you are used to working with the editor <em><span style="font-family: Courier New,Courier,mono;">vi</span></em> (like me), run the following commands:</span></p>
<p><em><span style="font-family: Courier New,Courier,mono; font-size: x-small;">rm -f /etc/alternatives/editor<br />
ln -s /usr/bin/vi /etc/alternatives/editor</span></em></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: x-small;">Afterwards, run <span style="font-family: Courier New,Courier,mono;"> <em>crontab -e</em></span>, and <em><span style="font-family: Courier New,Courier,mono;">vi</span></em> will come up.)</span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: x-small;"><strong>9 Quota Exceedance Notifications</strong></span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: x-small;">If you want to get notifications about all the email accounts that are over quota, then do this:</span></p>
<p><em><span style="font-family: Courier New,Courier,mono; font-size: x-small;">cd /usr/local/sbin/<br />
wget http://puuhis.net/vhcs/quota.txt<br />
mv quota.txt quota_notify<br />
chmod 755 quota_notify</span></em></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: x-small;">Open </span><em><span style="font-family: Courier New,Courier,mono; font-size: x-small;">/usr/local/sbin/quota_notify</span></em><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: x-small;"> and edit the variables at the top:</span></p>
<table width="90%" border="1" cellspacing="0" cellpadding="2" align="center" bgcolor="#cccccc">
<tbody>
<tr>
<td>
<pre>my $POSTFIX_CF = "/etc/postfix/main.cf";
my $MAILPROG = "/usr/sbin/sendmail -t";
my $WARNPERCENT = 80;
my @POSTMASTERS = ('postmaster@isp.tld');
my $CONAME = 'ISP.tld';
my $COADDR = 'postmaster@isp.tld';
my $SUADDR = 'postmaster@isp.tld';
my $MAIL_REPORT = 1;
my $MAIL_WARNING = 1;</pre>
</td>
</tr>
</tbody>
</table>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: x-small;">Run</span></p>
<p><em><span style="font-family: Courier New,Courier,mono; font-size: x-small;">crontab -e</span></em></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: x-small;">to create a cron job for that script:</span></p>
<p><span style="font-family: Courier New,Courier,mono; font-size: x-small;"><em>0 0 * * * /usr/local/sbin/quota_notify &amp;&gt; /dev/null</em></span></p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/os/linux/virtual-users-and-domains-with-postfix-courier-and-mysql-smtp-auth-quota-spamassassin-clamav-part-4.html" title="virtual users and domains with postfix courier and mysql ( smtp-auth quota spamassassin clamav)">virtual users and domains with postfix courier and mysql ( smtp-auth quota spamassassin clamav)</a> (2)</li><li><a href="http://thegioinguonmo.com/os/linux/virtual-users-and-domains-with-postfix-courier-and-mysql-smtp-auth-quota-spamassassin-clamav-part-4.html" title="install postfix on directadmin">install postfix on directadmin</a> (2)</li><li><a href="http://thegioinguonmo.com/os/linux/virtual-users-and-domains-with-postfix-courier-and-mysql-smtp-auth-quota-spamassassin-clamav-part-4.html" title="centos plesk postfix">centos plesk postfix</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/virtual-users-and-domains-with-postfix-courier-and-mysql-smtp-auth-quota-spamassassin-clamav-part-4.html" title="postfix spamassassin clamav centos">postfix spamassassin clamav centos</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/virtual-users-and-domains-with-postfix-courier-and-mysql-smtp-auth-quota-spamassassin-clamav-part-4.html" title="quota txt postfix">quota txt postfix</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/virtual-users-and-domains-with-postfix-courier-and-mysql-smtp-auth-quota-spamassassin-clamav-part-4.html" title="quota txt postfix mysql">quota txt postfix mysql</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/virtual-users-and-domains-with-postfix-courier-and-mysql-smtp-auth-quota-spamassassin-clamav-part-4.html" title="smtp postfix plesk 10">smtp postfix plesk 10</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/virtual-users-and-domains-with-postfix-courier-and-mysql-smtp-auth-quota-spamassassin-clamav-part-4.html" title="spamassassin mysql">spamassassin mysql</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/virtual-users-and-domains-with-postfix-courier-and-mysql-smtp-auth-quota-spamassassin-clamav-part-4.html" title="vhcs2 centos smtp auth">vhcs2 centos smtp auth</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/virtual-users-and-domains-with-postfix-courier-and-mysql-smtp-auth-quota-spamassassin-clamav-part-4.html" title="postfix icinga configuration">postfix icinga configuration</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/os/linux/virtual-users-and-domains-with-postfix-courier-and-mysql-smtp-auth-quota-spamassassin-clamav-part-4.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Virtual Users And Domains With Postfix, Courier And MySQL (+ SMTP-AUTH, Quota, SpamAssassin, ClamAV) part1</title>
		<link>http://thegioinguonmo.com/security/virtual-users-and-domains-with-postfix-courier-and-mysql-smtp-auth-quota-spamassassin-clamav-part1.html</link>
		<comments>http://thegioinguonmo.com/security/virtual-users-and-domains-with-postfix-courier-and-mysql-smtp-auth-quota-spamassassin-clamav-part1.html#comments</comments>
		<pubDate>Wed, 21 Dec 2011 04:39:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[clamav]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[Postfix]]></category>
		<category><![CDATA[Quota]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=23</guid>
		<description><![CDATA[Virtual Users And Domains With Postfix, Courier And MySQL (+ SMTP-AUTH, Quota, SpamAssassin, ClamAV) Version 1.0 Author: Falko Timme &#60;ft [at] falkotimme [dot] com&#62; Last edited 10/05/2005 This tutorial is Copyright (c) 2005 by Falko Timme. It is derived from a tutorial from Christoph Haas which you can find at http://workaround.org. You are free to [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: small;"><strong>Virtual Users And Domains With Postfix, Courier And MySQL (+ SMTP-AUTH, Quota, SpamAssassin, ClamAV) </strong></span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">Version 1.0<br />
Author: Falko Timme &lt;ft [at] falkotimme [dot] com&gt;<br />
Last edited 10/05/2005</span></p>
<p><span style="font-size: small;"><em><span style="font-family: Times New Roman;">This tutorial is Copyright (c) 2005 by Falko Timme. It is derived from a tutorial from Christoph Haas which you can find at <a rel="nofollow" target="_blank" href="http://workaround.org/" target="_blank">http://workaround.org</a>. You are free to use this tutorial under the Creative Commons license 2.5 or any later version. </span></em></span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">This document describes how to install a mail server based on Postfix that is based on virtual users and domains, i.e. users and domains that are in a MySQL database. I&#8217;ll also demonstrate the installation and configuration of Courier (Courier-POP3, Courier-IMAP), so that Courier can authenticate against the same MySQL database Postfix uses.</span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">The resulting Postfix server is capable of <strong>SMTP-AUTH</strong> and <strong>TLS</strong> and <strong>quota</strong> (quota is not built into Postfix by default, I&#8217;ll show how to patch your Postfix appropriately). Passwords are stored in <strong>encrypted</strong> form in the database (most documents I found were dealing with plain text passwords which is a security risk). In addition to that, this tutorial covers the installation of <strong>Amavisd</strong>, <strong>SpamAssassin</strong> and <strong>ClamAV</strong> so that emails will be scanned for spam and viruses.</span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">The advantage of such a &#8220;virtual&#8221; setup (virtual users and domains in a MySQL database) is that it is far more performant than a setup that is based on &#8220;real&#8221; system users. With this virtual setup your mail server can handle thousands of domains and users. Besides, it is easier to administrate because you only have to deal with the MySQL database when you add new users/domains or edit existing ones. No more <em><span style="font-family: Courier New,Courier,mono;">postmap</span></em> commands to create db files, no more reloading of Postfix, etc. For the administration of the MySQL database you can use web based tools like <strong>phpMyAdmin</strong> which will also be installed in this howto. The third advantage is that users have an email address as user name (instead of a user name + an email address) which is easier to understand and keep in mind.</span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">This tutorial is based on <strong>Debian Sarge</strong> (Debian 3.1). You should already have set up a basic Debian system, as described here: <a rel="nofollow" target="_blank" href="http://www.howtoforge.com/perfect_setup_debian_sarge" target="_blank">http://www.howtoforge.com/perfect_setup_debian_sarge</a> and <a rel="nofollow" target="_blank" href="http://www.howtoforge.com/perfect_setup_debian_sarge_p2" target="_blank">http://www.howtoforge.com/perfect_setup_debian_sarge_p2</a>.</span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">This howto is meant as a practical guide; it does not cover the theoretical backgrounds. They are treated in a lot of other documents in the web.</span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">This document comes without warranty of any kind! I want to say that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!</span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;"><strong>1 Install Postfix, Courier, Saslauthd, MySQL, phpMyAdmin</strong></span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">This can all be installed with one single command:</span></p>
<blockquote><p><span style="font-size: small;"><em><span style="font-family: Courier New,Courier,mono;">apt-get install postfix postfix-mysql postfix-doc mysql-client mysql-server courier-authdaemon courier-authmysql courier-pop courier-pop-ssl courier-imap courier-imap-ssl postfix-tls libsasl2 libsasl2-modules libsasl2-modules-sql sasl2-bin libpam-mysql openssl phpmyadmin </span></em><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><strong>(1 line!)</strong></span></span></p></blockquote>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">You will be asked a few questions:</span></p>
<blockquote><p><span style="font-size: small;"><em><span style="font-family: Courier New,Courier,mono;">Enable suExec? &lt;&#8211; Yes<br />
Create directories for web-based administration ? &lt;&#8211; No<br />
General type of configuration? &lt;&#8211; Internet site<br />
Where should mail for root go? &lt;&#8211; NONE<br />
Mail name? &lt;&#8211; server1.example.com<br />
Other destinations to accept mail for? (blank for none) &lt;&#8211; server1.example.com, localhost, localhost.localdomain<br />
Force synchronous updates on mail queue? &lt;&#8211; No<br />
SSL certificate required &lt;&#8211; Ok<br />
Install Hints &lt;&#8211; Ok<br />
Which web server would you like to reconfigure automatically? &lt;&#8211; apache, apache2<br />
Do you want me to restart apache now? &lt;&#8211; Yes</span></em></span></p></blockquote>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;"><strong>2 Apply Quota Patch To Postfix</strong></span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">We have to get the Postfix sources, patch it with the quota patch, build new Postfix <em><span style="font-family: Courier New,Courier,mono;">.deb</span></em> packages and install those <em><span style="font-family: Courier New,Courier,mono;">.deb</span></em> packages:</span></p>
<blockquote><p><span style="font-family: Courier New,Courier,mono; font-size: small;"><em>apt-get install build-essential dpkg-dev fakeroot debhelper libdb4.2-dev libgdbm-dev libldap2-dev libpcre3-dev libmysqlclient10-dev libssl-dev libsasl2-dev postgresql-dev po-debconf dpatch </em><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><strong>(1 line!)</strong></span><em><br />
cd /usr/src<br />
apt-get source postfix<br />
wget http://web.onda.com.br/nadal/postfix/VDA/postfix-2.1.5-trash.patch.gz<br />
gunzip postfix-2.1.5-trash.patch.gz<br />
cd postfix-2.1.5<br />
patch -p1 &lt; ../postfix-2.1.5-trash.patch<br />
dpkg-buildpackage<br />
cd ..<br />
dpkg -i postfix_2.1.5-9_i386.deb<br />
dpkg -i postfix-mysql_2.1.5-9_i386.deb<br />
dpkg -i postfix-tls_2.1.5-9_i386.deb</em></span></p></blockquote>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;"><strong>3 Create The MySQL Database For Postfix/Courier</strong></span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">By default, MySQL is installed without a root password, which we change immediately (replace <em><span style="font-family: Courier New,Courier,mono;">yourrootsqlpassword</span></em> with the password you want to use):</span></p>
<p><span style="font-size: small;"><em><span style="font-family: Courier New,Courier,mono;">mysqladmin -u root password yourrootsqlpassword</span></em></span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">Now we create a database called <em><span style="font-family: Courier New,Courier,mono;">mail</span></em>:</span></p>
<p><span style="font-size: small;"><em><span style="font-family: Courier New,Courier,mono;">mysqladmin -u root -p create mail</span></em></span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">Next, we go to the MySQL shell:</span></p>
<p><span style="font-size: small;"><em><span style="font-family: Courier New,Courier,mono;">mysql -u root -p</span></em></span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">On the MySQL shell, we create the user <em><span style="font-family: Courier New,Courier,mono;">mail_admin</span></em> with the passwort <em><span style="font-family: Courier New,Courier,mono;">mail_admin_password</span></em> (replace it with your own password) who has <em><span style="font-family: Courier New,Courier,mono;">SELECT</span><span style="font-family: Courier New,Courier,mono;">,INSERT,UPDATE,DELETE</span></em> privileges on the <em><span style="font-family: Courier New,Courier,mono;">mail</span></em> database. This user will be used by Postfix and Courier to connect to the <em><span style="font-family: Courier New,Courier,mono;">mail</span></em> database:</span></p>
<blockquote><p><span style="font-size: small;"><em><span style="font-family: Courier New,Courier,mono;">GRANT SELECT, INSERT, UPDATE, DELETE ON mail.* TO &#8216;mail_admin&#8217;@'localhost&#8217; IDENTIFIED BY &#8216;mail_admin_password&#8217;;<br />
GRANT SELECT, INSERT, UPDATE, DELETE ON mail.* TO &#8216;mail_admin&#8217;@'localhost.localdomain&#8217; IDENTIFIED BY &#8216;mail_admin_password&#8217;;<br />
FLUSH PRIVILEGES;</span></em></span></p></blockquote>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">Still on the MySQL shell, we create the tables Postfix and Courier need:</span></p>
<blockquote><p><span style="font-size: small;"><em><span style="font-family: Courier New,Courier,mono;">USE mail;</span></em></span></p>
<p><span style="font-family: Courier New,Courier,mono; font-size: small;"><em>CREATE TABLE domains (<br />
domain varchar(50) NOT NULL,<br />
PRIMARY KEY (domain) )<br />
TYPE=MyISAM;</em></span></p>
<p><span style="font-family: Courier New,Courier,mono; font-size: small;"><em>CREATE TABLE forwardings (<br />
source varchar(80) NOT NULL,<br />
destination TEXT NOT NULL,<br />
PRIMARY KEY (source) )<br />
TYPE=MyISAM;</em></span></p>
<p><span style="font-family: Courier New,Courier,mono; font-size: small;"><em>CREATE TABLE users (<br />
email varchar(80) NOT NULL,<br />
password varchar(20) NOT NULL,<br />
quota INT(10) DEFAULT &#8217;10485760&#8242;,<br />
PRIMARY KEY (email)<br />
) TYPE=MyISAM;</em></span></p>
<p><span style="font-family: Courier New,Courier,mono; font-size: small;"><em>CREATE TABLE transport (<br />
domain varchar(128) NOT NULL default &#8221;,<br />
transport varchar(128) NOT NULL default &#8221;,<br />
UNIQUE KEY domain (domain)<br />
) TYPE=MyISAM;</em></span></p>
<p><span style="font-family: Courier New,Courier,mono; font-size: small;"><em>quit;</em></span></p></blockquote>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">As you may have noticed, with the <em><span style="font-family: Courier New,Courier,mono;">quit;</span></em> command we have left the MySQL shell and are back on the Linux shell. </span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">The <em><span style="font-family: Courier New,Courier,mono;">domains</span></em> table will store each virtual domain that Postfix should receive emails for (e.g. <span style="font-family: Courier New,Courier,mono;"> <em>example.com</em></span>). </span></p>
<table width="15%" border="1" cellspacing="0" cellpadding="5">
<tbody>
<tr>
<td><span style="font-size: small;"><em><strong><span style="font-family: Courier New,Courier,mono;">domain</span></strong></em></span></td>
</tr>
<tr>
<td><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">example.com</span></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">The <span style="font-family: Courier New,Courier,mono;"> <em>forwardings</em></span> table is for aliasing one email address to another, e.g. forward emails for <em><span style="font-family: Courier New,Courier,mono;">info@example.com</span></em> to <em><span style="font-family: Courier New,Courier,mono;">sales@example.com</span></em>.</span></p>
<table width="30%" border="1" cellspacing="0" cellpadding="5">
<tbody>
<tr>
<td><span style="font-size: small;"><em><strong><span style="font-family: Courier New,Courier,mono;">source</span></strong></em></span></td>
<td><span style="font-size: small;"><em><strong><span style="font-family: Courier New,Courier,mono;">destination</span></strong></em></span></td>
</tr>
<tr>
<td><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">info@example.com</span></td>
<td><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">sales@example.com</span></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><span style="font-size: small;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"> The <em><span style="font-family: Courier New,Courier,mono;">users</span></em> table stores all virtual users (i.e. email addresses, because theemail address and user name is the same) and passwords (in <strong>encrypted</strong> form!) and a quota value for each mail box (in this example the default value is </span><span style="font-family: Courier New,Courier,mono;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">10485760</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"> bytes which means 10MB).</span></span></p>
<table width="45%" border="1" cellspacing="0" cellpadding="5">
<tbody>
<tr>
<td><span style="font-size: small;"><strong><em><span style="font-family: Courier New,Courier,mono;">email</span></em></strong></span></td>
<td><span style="font-size: small;"><strong><em><span style="font-family: Courier New,Courier,mono;">password</span></em></strong></span></td>
<td><span style="font-size: small;"><strong><em><span style="font-family: Courier New,Courier,mono;">quota</span></em></strong></span></td>
</tr>
<tr>
<td><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">sales@example.com</span></td>
<td><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">No9.E4skNvGa. (&#8220;secret&#8221; in encrypted form)</span></td>
<td><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">10485760</span></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">The <em><span style="font-family: Courier New,Courier,mono;">transport</span></em> table is optional, it is for advanced users. It allows to forward mails for single users, whole domains or all mails to another server. For example,</span></p>
<table width="30%" border="1" cellspacing="0" cellpadding="5">
<tbody>
<tr>
<td><span style="font-size: small;"><strong><em><span style="font-family: Courier New,Courier,mono;">domain</span></em></strong></span></td>
<td><span style="font-size: small;"><strong><span style="font-family: Courier New,Courier,mono;"><em>transport</em></span></strong></span></td>
</tr>
<tr>
<td><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">example.com</span></td>
<td><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">smtp:[1.2.3.4]</span></td>
</tr>
</tbody>
</table>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">would forward all emails for <em><span style="font-family: Courier New,Courier,mono;">example.com</span></em> via the smtp protocol to the server with the IP address <em><span style="font-family: Courier New,Courier,mono;">1.2.3.4</span></em> (the square brackets <em><span style="font-family: Courier New,Courier,mono;">[]</span></em> mean &#8220;do not make a lookup of the MX DNS record&#8221; (which makes sense for IP addresses&#8230;). If you use a fully qualified domain name (FQDN) instead you would not use the square brackets.).</span></p>
<p>&nbsp;</p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">BTW, (I&#8217;m suggesting that the IP address of your mail server system is <em><span style="font-family: Courier New,Courier,mono;">192.168.0.100</span></em>) you can access <em><span style="font-family: Courier New,Courier,mono;">phpMyAdmin</span></em> over <em><span style="font-family: Courier New,Courier,mono;">http://192.168.0.100/phpmyadmin/</span></em> in a browser and log in as <em><span style="font-family: Courier New,Courier,mono;">mail_admin</span></em>. Then you can have a look at the database. Later on you can use <em><span style="font-family: Courier New,Courier,mono;">phpMyAdmin</span></em> to administrate your mail server.</span></p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/security/virtual-users-and-domains-with-postfix-courier-and-mysql-smtp-auth-quota-spamassassin-clamav-part1.html" title="postfix authenticated smtp">postfix authenticated smtp</a> (1)</li><li><a href="http://thegioinguonmo.com/security/virtual-users-and-domains-with-postfix-courier-and-mysql-smtp-auth-quota-spamassassin-clamav-part1.html" title="postfix courier mysql debian">postfix courier mysql debian</a> (1)</li><li><a href="http://thegioinguonmo.com/security/virtual-users-and-domains-with-postfix-courier-and-mysql-smtp-auth-quota-spamassassin-clamav-part1.html" title="postfix-mysql postfix-tls libsasl2-modules-sql libsasl2-modules in centos">postfix-mysql postfix-tls libsasl2-modules-sql libsasl2-modules in centos</a> (1)</li><li><a href="http://thegioinguonmo.com/security/virtual-users-and-domains-with-postfix-courier-and-mysql-smtp-auth-quota-spamassassin-clamav-part1.html" title="spamassassin postfix plesk without key">spamassassin postfix plesk without key</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/security/virtual-users-and-domains-with-postfix-courier-and-mysql-smtp-auth-quota-spamassassin-clamav-part1.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Install A Complete LEMP (Linux &#8211; EngineX (Nginx HTTP SERVER) &#8211; Mysql &#8211; PHP) Server (Not LAMP&#8230;) On Ubuntu/Debian</title>
		<link>http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html</link>
		<comments>http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html#comments</comments>
		<pubDate>Tue, 20 Dec 2011 16:39:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[nginx]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[Postfix]]></category>
		<category><![CDATA[yourdomain]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=17</guid>
		<description><![CDATA[This HowTo will describe the setup of an efficient http server and mail server for small or medium configurations (as low as 96 mb). So this config is ideal for a small VPS. You can find a good choice of cheap and performant VPS (XEN) at x&#124;encon, a german hosting company. they provide many scalable [...]]]></description>
			<content:encoded><![CDATA[<p>This HowTo will describe the setup of an efficient http server and mail server for small or medium configurations (as low as 96 mb). So this config is ideal for a small VPS. You can find a good choice of cheap and performant VPS (XEN) at <a rel="nofollow" target="_blank" href="http://www.xencon.net/" target="_blank">x|encon</a>, a german hosting company. they provide many scalable VPS solutions with pre-installed Debian and Ubuntu disc images.</p>
<p>Why LEMP instead of LAMP? NGINX is a great replacement for Apache with very low memory footprint and great stability.</p>
<p>Note: i will use the name yourdomain.com for all configurations on a fresh minimal installation of Ubuntu Feisty Fawn server edition.</p>
<p>We will have to install first Postfix to deal with emails and then Dovecot to deliver them with pop3 only (imap uses too much memory). But before that, let&#8217;s install some useful tools we need:</p>
<p>apt-get install wget telnet build-essential</p>
<h3>1. Installation of Postfix</h3>
<p>apt-get install postfix libsasl2 sasl2-bin libsasl2-modules libdb3-util procmail</p>
<p>Now the beautiful blue screen will appear and Postfix will ask you some questions. Answer as follow:</p>
<p>General type of configuration? &lt;&#8211; Internet Site<br />
Mail name? &lt;&#8211; yourdomain.com</p>
<p>Then run:</p>
<p>dpkg-reconfigure postfix</p>
<p>Again, you&#8217;ll be asked some questions:</p>
<p>General type of configuration? &lt;&#8211; Internet Site<br />
Where should mail for root go &lt;&#8211; [blank]<br />
Mail name? &lt;&#8211; yourdomain.com<br />
Other destinations to accept mail for? (blank for none) &lt;&#8211; yourdomain.com, localhost.yourdomain.com, localhost.localdomain, localhost<br />
Force synchronous updates on mail queue? &lt;&#8211; No<br />
Local networks? &lt;&#8211; 127.0.0.0/8<br />
Use procmail for local delivery? &lt;&#8211; Yes<br />
Mailbox size limit &lt;&#8211; 0<br />
Local address extension character? &lt;&#8211; +<br />
Internet protocols to use? &lt;&#8211; all</p>
<p>Type then the following commands (you can copy everything below and paste it in your terminal in one row, it will work but don&#8217;t forget to hit enter to validate the last command):</p>
<p>postconf -e &#8216;smtpd_sasl_local_domain =&#8217;<br />
postconf -e &#8216;smtpd_sasl_auth_enable = yes&#8217;<br />
postconf -e &#8216;smtpd_sasl_security_options = noanonymous&#8217;<br />
postconf -e &#8216;broken_sasl_auth_clients = yes&#8217;<br />
postconf -e &#8216;smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination&#8217;<br />
postconf -e &#8216;inet_interfaces = all&#8217;<br />
echo &#8216;pwcheck_method: saslauthd&#8217; &gt;&gt; /etc/postfix/sasl/smtpd.conf<br />
echo &#8216;mech_list: plain login&#8217; &gt;&gt; /etc/postfix/sasl/smtpd.conf</p>
<p>Now we have to create the certificates for TLS that will be available both for Postfix and Dovecot:</p>
<p>mkdir /etc/ssl/yourdomain (the folder name can be of course anything such as the name of your mother&#8230;)<br />
cd /etc/ssl/yourdomain<br />
openssl genrsa -des3 -rand /etc/hosts -out yourdomain.key 1024</p>
<p>chmod 600 yourdomain.key<br />
openssl req -new -key yourdomain.key -out yourdomain.csr</p>
<p>openssl x509 -req -days 3650 -in yourdomain.csr -signkey yourdomain.key -out yourdomain.crt</p>
<p>openssl rsa -in yourdomain.key -out yourdomain.key.unencrypted</p>
<p>mv -f yourdomain.key.unencrypted yourdomain.key<br />
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650</p>
<p>Next we configure Postfix for TLS:</p>
<p>postconf -e &#8216;smtpd_tls_auth_only = no&#8217;<br />
postconf -e &#8216;smtp_use_tls = yes&#8217;<br />
postconf -e &#8216;smtpd_use_tls = yes&#8217;<br />
postconf -e &#8216;smtp_tls_note_starttls_offer = yes&#8217;<br />
postconf -e &#8216;smtpd_tls_key_file = /etc/ssl/yourdomain/yourdomain.key&#8217;<br />
postconf -e &#8216;smtpd_tls_cert_file = /etc/ssl/yourdomain/yourdomain.crt&#8217;<br />
postconf -e &#8216;smtpd_tls_CAfile = /etc/ssl/yourdomain/cacert.pem&#8217;<br />
postconf -e &#8216;smtpd_tls_loglevel = 1&#8242;<br />
postconf -e &#8216;smtpd_tls_received_header = yes&#8217;<br />
postconf -e &#8216;smtpd_tls_session_cache_timeout = 3600s&#8217;<br />
postconf -e &#8216;tls_random_source = dev:/dev/urandom&#8217;<br />
postconf -e &#8216;myhostname = yourdomain.com&#8217;</p>
<p>Restart Postfix:</p>
<p>/etc/init.d/postfix restart</p>
<p>Authentication will be done by saslauthd. We have to change a few things to make it work properly. Because Postfix runs chrooted in /var/spool/postfix we have to do the following:</p>
<p>mkdir -p /var/spool/postfix/var/run/saslauthd</p>
<p>Now we have to edit /etc/default/saslauthd in order to activate saslauthd. Set START to yes and change the line OPTIONS=&#8221;-c&#8221; to OPTIONS=&#8221;-c -m /var/spool/postfix/var/run/saslauthd -r&#8221;:</p>
<p>vi /etc/default/saslauthd</p>
<pre>#
# Settings for saslauthd daemon
#
# Should saslauthd run automatically on startup? (default: no)
START=yes
# Which authentication mechanisms should saslauthd use? (default: pam)
#
# Available options in this Debian package:
# getpwent  -- use the getpwent() library function
# kerberos5 -- use Kerberos 5
# pam       -- use PAM
# rimap     -- use a remote IMAP server
# shadow    -- use the local shadow password file
# sasldb    -- use the local sasldb database file
# ldap      -- use LDAP (configuration is in /etc/saslauthd.conf)
#
# Only one option may be used at a time. See the saslauthd man page
# for more information.
#
# Example: MECHANISMS="pam"
MECHANISMS="pam"
# Additional options for this mechanism. (default: none)
# See the saslauthd man page for information about mech-specific options.
MECH_OPTIONS=""
# How many saslauthd processes should we run? (default: 5)
# A value of 0 will fork a new process for each connection.
THREADS=5
# Other options (default: -c)
# See the saslauthd man page for information about these options.
#
# Example for postfix users: "-c -m /var/spool/postfix/var/run/saslauthd"
# Note: See /usr/share/doc/sasl2-bin/README.Debian
OPTIONS="-c  -m /var/spool/postfix/var/run/saslauthd -</pre>
<p>Start then saslauthd:</p>
<p>/etc/init.d/saslauthd start</p>
<p>To see if SMTP-AUTH and TLS work properly now run the following command:</p>
<p>telnet yourdomain.com 25</p>
<p>After you have established the connection to your Postfix mail server type</p>
<p>ehlo yourdomain.com</p>
<p>The output should look something like:</p>
<p>250-yourdomain.com<br />
250-PIPELINING<br />
250-SIZE 10240000<br />
250-VRFY<br />
250-ETRN<br />
250-STARTTLS<br />
250-AUTH PLAIN LOGIN<br />
250-AUTH=PLAIN LOGIN<br />
250-ENHANCEDSTATUSCODES<br />
250-8BITMIME<br />
250 DSN</p>
<p>We have now Postfix running. If you add users (adduser command) Postfix will deliver then directly emails in users mail box located in the home folder.</p>
<h3>2. Installation of Dovecot</h3>
<p>Dovecot configuration is pretty straight forward (remember we will use only pop3 protocol to save memory):</p>
<p>apt-get install dovecot-common dovecot-pop3d</p>
<p>Open then dovecot conf situated in /etc/dovecot/. You have to add manually the protocol you want to use (pop3 pop3s</p>
<pre># Protocols we want to be serving: imap imaps pop3 pop3s
# If you only want to use dovecot-auth, you can set this to "none".
#protocols = imap imaps
protocols = pop3s pop3</pre>
<p>And uncomment the two following lines to tell Dovecot where to fint the certificate you have creted earlier</p>
<pre>ssl_cert_file = /etc/ssl/yourdomain/yourdomain.crt
ssl_key_file = /etc/ssl/yourdomain/yourdomain.key</pre>
<p>You have then to restart Dovecot</p>
<p>/etc/init.d/dovecot restart</p>
<p>and we have now a functionnal mail server.</p>
<h3>3. Installation of PHP5 (along with xcache)</h3>
<p>apt-get install php5-cli php5-cgi php5-mysql php5-xcache</p>
<p>Note that xcache has to be implemented manually by adding the following lines in the php.ini located in /etc/php5/cgi/ (please tune this config according to your system).</p>
<pre>[xcache-common]
extension = xcache.so
[xcache.admin]
xcache.admin.user = "mOo"
; xcache.admin.pass = md5($your_password)
xcache.admin.pass = ""
[xcache]
; ini only settings, all the values here is default unless explained
; select low level shm/allocator scheme implemenation
xcache.shm_scheme =        "mmap"
; to disable: xcache.size=0
; to enable : xcache.size=64M etc (any size &gt; 0) and your system mmap allows
xcache.size  =                32M
; set to cpu count (cat /proc/cpuinfo |grep -c processor)
xcache.count =                 1
; just a hash hints, you can always store count(items) &gt; slots
xcache.slots =                8K
; ttl of the cache item, 0=forever
xcache.ttl   =                 0
; interval of gc scanning expired items, 0=no scan, other values is in seconds
xcache.gc_interval =           0
; same as aboves but for variable cache
xcache.var_size  =            32M
xcache.var_count =             1
xcache.var_slots =            8K
; default ttl
xcache.var_ttl   =             0
xcache.var_maxttl   =          0
xcache.var_gc_interval =     300
xcache.test =                Off
; N/A for /dev/zero
xcache.readonly_protection = Off
; for *nix, xcache.mmap_path is a file path, not directory.
; Use something like "/tmp/xcache" if you want to turn on ReadonlyProtection
; 2 group of php won't share the same /tmp/xcache
; for win32, xcache.mmap_path=anonymous map name, not file path
xcache.mmap_path =    "/dev/zero"
; leave it blank(disabled) or "/tmp/phpcore/"
; make sure it's writable by php (without checking open_basedir)
xcache.coredump_directory =   ""
; per request settings
xcache.cacher =               On
xcache.stat   =               On
xcache.optimizer =            On
[xcache.coverager]
; per request settings
; enable coverage data collecting for xcache.coveragedump_directory and xcache_coverager_start/stop/get/clean() functions (will hurt executing performance)
xcache.coverager =          Off
; ini only settings
; make sure it's readable (care open_basedir) by coverage viewer script
; requires xcache.coverager=On
xcache.coveragedump_directory = ""</pre>
<p>Note: you have to adjust manually the xcache.size and xcache.var_size according to your server (it&#8217;s on 0 by default, meaning that xcache isn&#8217;t enabled at all). One other thing is the xcache.count variable. If you have a vps that takes advantage of 2 processors, you can put 2 instead of one.</p>
<p>You can do that right now even if your php configuration isn&#8217;t loaded yet so everything will be in good order when Nginx and fcgi process will be started.</p>
<h3>4. Installation of Mysql and PhpMyAdmin</h3>
<p>apt-get install mysql mysql-server</p>
<p>There is often a problem with mysql to setup the root password. So the best thing to do is first stopping mysql:</p>
<p>/etc/init.d/mysql stop</p>
<p>Then update the user table</p>
<p>mysqld &#8211;skip-grant-tables &#8211;skip-networking &amp;</p>
<p>mysql mysql</p>
<p>UPDATE user SET password=PASSWORD(&#8216;yourrootpassword&#8217;) WHERE User=&#8221;root&#8221; AND Host=&#8221;localhost&#8221;;</p>
<p>quit</p>
<p>/etc/init.d/mysql restart</p>
<h3>5. Installation of NGINX (Ubuntu only, see below for Debian users)</h3>
<p>The nginx version proposed by Feisty is a prehistoric one (not to mention drapper). Fortunately, there&#8217;s a place you can get the latest stable version, or if you are adventurous, the latest dev version.</p>
<p>Note for Debian users: I didn&#8217;t find a recent .deb package so you have either the choice to compile from sources or to do a apt-get install nginx to have a not so new version. For more informations about Nginx please go to the <a rel="nofollow" target="_blank" href="http://wiki.codemongers.com/" target="_blank">Nginx Wiki</a> website. You can find there the sources and a good doc about all the modules (ssl, auth_basic and so on).</p>
<p>wget http://technokracy.net/nginx/nginx_0.5.32~grrr-1_i386.deb</p>
<p>(Note that if you are running on AMD replace i386 by amd64.)</p>
<p>Then type:</p>
<p>dpkg -i nginx_0.5.32~grrr-1_i386.deb</p>
<p>Nginx is now up and running on default port 8000 (just in case you already have Apache or anything else on port 80).</p>
<p>The default root folder is Nginx-default and is located in /var/www/</p>
<p>To change that and to start to listen to the fast-cgi we will launch next, you have to open /etc/nginx/sites-available/default.</p>
<p>vi /etc/nginx/sites-available/default</p>
<p>You can find there all the obvious options to change and add (or uncomment the original php paragraph):</p>
<pre>        location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  /var/www/nginx-default$fastcgi_script_name;
    }</pre>
<p>We&#8217;ve just asked Nginx to listen to fcgi on port 9000. So we have to start now the fcgi process. I&#8217;ve chosen to use spawn-fcgi and to make my own init script of it (so the process will start after reboot). To have spawn-fcgi you have to get lighttpd configured but without the need to install it. Let&#8217;s grab the latest version:</p>
<p>wget http://www.lighttpd.net/download/lighttpd-1.4.18.tar.bz2</p>
<p>tar -xvjf lighttpd-1.4.18.tar.bz2</p>
<p>cd lighttpd-1.4.18</p>
<p>./configure</p>
<p>make</p>
<p>cp src/spawn-fcgi /usr/bin/spawn-fcgi</p>
<p>Note that we did not type make install so lighttpd is not running!</p>
<p>Then we create a shell script we can call php-fastcgi or whatever you want and place that file in /usr/bin/ to make it simple (as php5-cgi and spawn-fcgi are already there&#8230;).</p>
<p>touch /usr/bin/php-fastcgi</p>
<p>Then edit it:</p>
<p>vi /usr/bin/php-fastcgi</p>
<p>and add the following:</p>
<pre>#!/bin/sh
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -f /usr/bin/php5-cgi</pre>
<p>That means every time this script will be called, fcgi will be spawned on port 9000 for user www-data (default user).</p>
<p>To make it work at startup we need now to create an init script:</p>
<p>touch /etc/init.d/init-fastcgi</p>
<p>Edit and add:</p>
<p>vi /etc/init.d/init-fastcgi</p>
<pre>#!/bin/bash
PHP_SCRIPT=/usr/bin/php-fastcgi
RETVAL=0
case "$1" in
    start)
      $PHP_SCRIPT
      RETVAL=$?
  ;;
    stop)
      killall -9 php
      RETVAL=$?
  ;;
    restart)
      killall -9 php
      $PHP_SCRIPT
      RETVAL=$?
  ;;
    *)
      echo "Usage: php-fastcgi {start|stop|restart}"
      exit 1
  ;;
esac
exit $RETVAL</pre>
<p>You may have to change the permissions there by typing:</p>
<p>chmod 755 /etc/init.d/init-fastcgi</p>
<p>Check then if it works by typing:</p>
<p>/etc/init.d/init-fastcgi start</p>
<p>You should have an answer from spawn-fcgi attributing a PID process. To make now everything working after reboot type:</p>
<p>update-rc.d init-fastcgi defaults</p>
<p>And we are done. To check if php is working as fast-cgi you can first type:</p>
<p>ps ax | grep php</p>
<p>To check then if Nginx is listening to php, create an echo command in an empty php file:</p>
<pre>&lt;? echo phpinfo(); ?&gt;</pre>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="nginx directadmin">nginx directadmin</a> (7)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="lemp howto">lemp howto</a> (3)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="centos appliance vmware lamp optimize">centos appliance vmware lamp optimize</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="linux install lemp">linux install lemp</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="nginx fcgi php $_REQUEST is empty">nginx fcgi php $_REQUEST is empty</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="nginx installation on sles">nginx installation on sles</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="nginx lamp windows">nginx lamp windows</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="nginx postfix mysql pipe mail to php">nginx postfix mysql pipe mail to php</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="plesk change setting saslauthd">plesk change setting saslauthd</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="preinstalled lemp">preinstalled lemp</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: thegioinguonmo.com @ 2012-02-07 10:52:37 -->
