<?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>Cpanel中文教程使用指南</title>
	<atom:link href="http://www.cpanelcn.info/feed" rel="self" type="application/rss+xml" />
	<link>http://www.cpanelcn.info</link>
	<description>Cpanel中文教程使用指南</description>
	<lastBuildDate>Mon, 05 Mar 2012 09:23:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>2台WHM/CPANEL服务器互相备份教程</title>
		<link>http://www.cpanelcn.info/2%e5%8f%b0whmcpanel%e6%9c%8d%e5%8a%a1%e5%99%a8%e4%ba%92%e7%9b%b8%e5%a4%87%e4%bb%bd%e6%95%99%e7%a8%8b.html</link>
		<comments>http://www.cpanelcn.info/2%e5%8f%b0whmcpanel%e6%9c%8d%e5%8a%a1%e5%99%a8%e4%ba%92%e7%9b%b8%e5%a4%87%e4%bb%bd%e6%95%99%e7%a8%8b.html#comments</comments>
		<pubDate>Mon, 05 Mar 2012 08:30:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cpanel使用技巧]]></category>

		<guid isPermaLink="false">http://www.cpanelcn.info/?p=108</guid>
		<description><![CDATA[1台服务器, 一旦挂掉网站就都挂了很不安全. 因此我们搞了2台服务器. 1台挂了另外一台可以及时将网站恢复.&#62; 为了负载均衡, 同时保持2台服务器运转. 我们把5个网站放到服务器A, 5个网站放到服务器B. A5备份到B. B5备份到A. 首先要在2台服务器建立SSH直连. 服务器A和B都要分别重复以下步骤. # ssh-keygen -t dsa You will be prompted for a file in which the key and a passphrase will be saved. You may press Enter through each of these prompts. If you do so, the key generation program will assume that you wish [...]]]></description>
			<content:encoded><![CDATA[<p>1台服务器, 一旦挂掉网站就都挂了很不安全. 因此我们搞了2台服务器. 1台挂了另外一台可以及时将网站恢复.&gt;<br />
为了负载均衡, 同时保持2台服务器运转. 我们把5个网站放到服务器A, 5个网站放到服务器B.<br />
A5备份到B. B5备份到A.</p>
<p>首先要在2台服务器建立SSH直连.<br />
服务器A和B都要分别重复以下步骤.<br />
#</p>
<pre class="brush: bash; gutter: true; first-line: 1; highlight: []; html-script: false">ssh-keygen -t dsa</pre>
<p>You will be prompted for a file in which the key and a passphrase will be saved. You may press Enter through each of these prompts. If you do so, the key generation program will assume that you wish to use the default file name of id_dsa and your private key will not be protected by a password.<br />
#</p>
<pre class="brush: bash; gutter: true; first-line: 1; highlight: []; html-script: false">scp ~/.ssh/id_rsa.pub remote_host:/</pre>
<p>3. Login to the remote host and check if you already have authorized_keys file in .ssh dir. If this doesn’t exist, create it with the following commands.</p>
<p>#</p>
<pre class="brush: bash; gutter: true; first-line: 1; highlight: []; html-script: false">touch ~/.ssh/authorized_keys</pre>
<p>4. On the remote host where you are in step 3, copy your public key to the authorized_keys file, with the following command.</p>
<p>#</p>
<pre class="brush: shell; gutter: true; first-line: 1; highlight: []; html-script: false">cat /id_dsa.pub &amp;gt;&amp;gt; ~/.ssh/authorized_keys</pre>
<p>5. You are set to use SSH authentication without password now. If you want you can delete or move id_rsa.pub file.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cpanelcn.info/2%e5%8f%b0whmcpanel%e6%9c%8d%e5%8a%a1%e5%99%a8%e4%ba%92%e7%9b%b8%e5%a4%87%e4%bb%bd%e6%95%99%e7%a8%8b.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cpanel服务器初始配置</title>
		<link>http://www.cpanelcn.info/cpanel-whm-initial.html</link>
		<comments>http://www.cpanelcn.info/cpanel-whm-initial.html#comments</comments>
		<pubDate>Wed, 29 Feb 2012 14:28:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cpanel中文教程]]></category>

		<guid isPermaLink="false">http://www.cpanelcn.info/?p=102</guid>
		<description><![CDATA[PHP: DSO， 256M memory Apache: use prebuilt cutom profile .yml If its running SUPHP on the server then public_html should be user.nobody (mode 750) , files under public_html will be user.user and everything under public_html is world readable (mode 644).]]></description>
			<content:encoded><![CDATA[<p>PHP: DSO， 256M memory<br />
Apache: use prebuilt cutom profile .yml<br />
If its running SUPHP on the server then public_html should be user.nobody (mode 750) , files under public_html will be user.user and everything under public_html is world readable (mode 644). </p>
]]></content:encoded>
			<wfw:commentRss>http://www.cpanelcn.info/cpanel-whm-initial.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>创建符号链接从/var/lib/mysql到/home/mysql当/var空间被占满的时候</title>
		<link>http://www.cpanelcn.info/var-lib-mysql-full-symlink-to-home-mysql.html</link>
		<comments>http://www.cpanelcn.info/var-lib-mysql-full-symlink-to-home-mysql.html#comments</comments>
		<pubDate>Sun, 26 Feb 2012 13:37:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cpanel使用技巧]]></category>
		<category><![CDATA[var lib mysql 太大]]></category>

		<guid isPermaLink="false">http://www.cpanelcn.info/?p=98</guid>
		<description><![CDATA[今天收到了邮件Drive Warning: /dev/sda3 (/var/named/chroot/var/run/dbus) is 81% full， 原来是/var/lib/mysql数据库文件太大导致/var快满了。 真不明白为什么要把MYSQL默认放到这么个小盘里， 在网上搜索了下发现可以把/var/lib/mysql映射到/home/mysql以解决磁盘占满问题。 Most of you may already know how to do this, so forgive if this is too simple, but this may be helpful for some dedicated server owners whose /var mount (some hosts use separate partitions for /usr, /var, /home etc) has become full, which is [...]]]></description>
			<content:encoded><![CDATA[<p>今天收到了邮件Drive Warning: /dev/sda3 (/var/named/chroot/var/run/dbus) is 81% full， 原来是/var/lib/mysql数据库文件太大导致/var快满了。 真不明白为什么要把MYSQL默认放到这么个小盘里， 在网上搜索了下发现可以把/var/lib/mysql映射到/home/mysql以解决磁盘占满问题。</p>
<p>Most of you may already know how to do this, so forgive if this is too simple, but this may be helpful for some dedicated server owners whose /var mount (some hosts use separate partitions for /usr, /var, /home etc) has become full, which is usually do to large databases in /var/lib/mysql. There is usually plenty of room in /the /home partition. This will work on cPanel servers as well.</p>
<p>This simple tutorial lays out the steps involved to copy contents of /var/lib/mysql to /home and then symlink /var/lib/mysql to /home/mysql. Of course adjust accordingly if moving/symlinking to a different mount or directory.</p>
<p>1) Go to webpage that uses mysql to verify working pre-copy</p>
<p>2) Stop mysql service (I will usually also stop cpanel &#038; http service just to be safe).</p>
<p>/etc/init.d/mysql stop<br />
/etc/init.d/httpd stop<br />
/etc/init.d/cpanel stop</p>
<p>3) Do the copy:</p>
<p>rsync -av /var/lib/mysql /home/</p>
<p>4) Verify copied folder same size as source with du:</p>
<p>du -sh /var/lib/mysql<br />
du -sh /home/mysql</p>
<p>5) Move /var/lib/mysql to /home/mysql-bak (essentially removing /var/lib/mysql because the folder must not exist when symlink is created)</p>
<p>mkdir /home/mysql-bak<br />
mv /var/lib/mysql /home/mysql-bak/</p>
<p>6) Create symlink:</p>
<p>ln -s /home/mysql /var/lib/mysql</p>
<p>7) Verify the symlink is correct when listing the contents of new symlinked /var/lib/mysql (you can refer to the rsync copy to make sure the paths are the same &#8211; they should be)</p>
<p> <img src='http://www.cpanelcn.info/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> Restart mysql, httpd, cpanel<br />
/etc/init.d/mysql start<br />
/etc/init.d/httpd start<br />
/etc/init.d/cpanel start</p>
<p>9) Verify mysql-reliant webpage is loading without issue</p>
<p>10) You should now have freed up space on /var. Verify with &#8216;df -h&#8217;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cpanelcn.info/var-lib-mysql-full-symlink-to-home-mysql.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux 文件操作常用命令</title>
		<link>http://www.cpanelcn.info/linux-commands.html</link>
		<comments>http://www.cpanelcn.info/linux-commands.html#comments</comments>
		<pubDate>Thu, 02 Feb 2012 08:27:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux服务器优化]]></category>
		<category><![CDATA[文件命令]]></category>

		<guid isPermaLink="false">http://www.cpanelcn.info/?p=96</guid>
		<description><![CDATA[Use this command to find the directories taking up the most space: 查找占空间最大的目录 du -k &#124; sort -nr &#124; more The du command along with the -k switch lists all directories and their respective size in kilobytes. The sort command sorts the output so that the largest directory is shown first in the list. The [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Use this command to find the directories taking up the most space:</strong><br />
<strong>查找占空间最大的目录</strong></p>
<p> <code>du -k | sort -nr | more</code></p>
<p>The du command along with the -k switch lists all directories and their respective size in kilobytes.<br />
The sort command sorts the output so that the largest directory is shown first in the list. The -nr switch reverses the list and uses only numbers when sorting.</p>
<p>Here’s an example of the output:</p>
<p> 12939451  .<br />
 1814892  ./abcdef<br />
 1219582  ./abcde<br />
 839586  ./abcd<br />
 718330  ./abc<br />
 695610  ./ab<br />
 690380  ./a</p>
<p>For human-readable output use the following command:</p>
<p> <code>du -sh /*</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cpanelcn.info/linux-commands.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>安装Selft signed SSL WHM Cpanel</title>
		<link>http://www.cpanelcn.info/installselft-signed-ssl-whm-cpanel.html</link>
		<comments>http://www.cpanelcn.info/installselft-signed-ssl-whm-cpanel.html#comments</comments>
		<pubDate>Thu, 02 Feb 2012 07:32:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cpanel中文教程]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://www.cpanelcn.info/?p=92</guid>
		<description><![CDATA[Installing a self-signed SSL certificate on a cPanel server To install on a cPanel server, you need a reseller or VPS hosting account. You’ll also need a dedicated IP address, to separate the site from others on the shared hosting server. Here at WebHostingBuzz, reseller accounts include dedicated IP address, and you may use one [...]]]></description>
			<content:encoded><![CDATA[<p>Installing a self-signed SSL certificate on a cPanel server</p>
<p>To install on a cPanel server, you need a reseller or VPS hosting account. You’ll also need a dedicated IP address, to separate the site from others on the shared hosting server. Here at WebHostingBuzz, reseller accounts include dedicated IP address, and you may use one of those for your certificate.</p>
<p>Create a self-signed SSL certificate</p>
<p>    Login to WHM.<br />
    Click “Generate a SSL Certificate &#038; Signing Request”.<br />
    Enter “Contact info” with a valid e-mail address.<br />
    Enter or generate a password, making sure it is sufficiently long with a mixture of letters, numbers and symbols.<br />
    Under “Host to make cert for”, enter the domain on which you want the SSL.<br />
    Click “Create”.<br />
    Copy the text displayed for the .key and .crt, and paste them into a text file on your computer. You may need that text in the next steps.</code></p>
<p>Install a self-signed SSL certificate</p>
<p>    In WHM, click “Install an SSL Certificate and Setup the Domain”.<br />
    Enter the domain name, account user name, and IP address for the certificate in the Domain, User, and IP Address fields.<br />
    Click “Fetch” to paste the .key and .crt files for the domain into the available display spaces, if they are currently on your server. (The first time I did this, clicking Fetch automatically pasted the required data into the fields. When I created later certs, the I had to manually paste in the information.)<br />
    Don’t enter anything in CA bundle: there is no Certificate Authority because you are installing a self-signed cert.<br />
    Click “Submit”, then wait for all processes to complete. WHM will display various lines of information and finally display “Finished Install Process.. “<br />
    Point your web browser to https:// followed by the domain, to see your new SSL connection working.</p>
<p>If you don’t see the SSL commands in your WHM, it may be because you don’t have a dedicated IP on your account. Once you have a dedicated IP assigned to a domain, the SSL Certificate links/commands will appear in WHM.</p>
<p>Since I began using self-signed SSL certificates a few years ago, several free and public domain certificate authorities have appeared. They issue certificates similar to those from the large commercial certificate authorities. The drawback is that most of them are not yet automatically trusted by major web browsers, meaning that users would see the same warning as when using a self-signed certificate. If these free issuers eventually get approval from the major web browsers, they would be a good alternative</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cpanelcn.info/installselft-signed-ssl-whm-cpanel.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>安装了Selft signed SSL后WHM Cpanel Restart apache Failed</title>
		<link>http://www.cpanelcn.info/%e5%ae%89%e8%a3%85%e4%ba%86selft-signed-ssl%e5%90%8ewhm-cpanel-restart-apache-failed.html</link>
		<comments>http://www.cpanelcn.info/%e5%ae%89%e8%a3%85%e4%ba%86selft-signed-ssl%e5%90%8ewhm-cpanel-restart-apache-failed.html#comments</comments>
		<pubDate>Thu, 29 Dec 2011 07:22:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cpanel中文教程]]></category>
		<category><![CDATA[SSLCACertificateFile]]></category>

		<guid isPermaLink="false">http://www.cpanelcn.info/?p=88</guid>
		<description><![CDATA[安装了Selft signed SSL后WHM Cpanel Restart apache Failed Apache restart failed. Unable to load pid from pid file and no httpd process found in process list. If apache restart reported success but it failed soon after, it may be caused by oddities with mod_ssl. You should run /usr/local/cpanel/scripts/ssl_crt_status as part of your troubleshooting process. Pass it [...]]]></description>
			<content:encoded><![CDATA[<p>安装了Selft signed SSL后WHM Cpanel Restart apache Failed<br />
<code>Apache restart failed. Unable to load pid from pid file and no httpd process found in process list.<br />
If apache restart reported success but it failed soon after, it may be caused by oddities with mod_ssl.<br />
You should run /usr/local/cpanel/scripts/ssl_crt_status as part of your troubleshooting process. Pass it --help for more details.</code></p>
<p>解决办法：<br />
Commented out the <strong>SSLCACertificateFile</strong> line<br />
最好的办法是在CABUNDLE那里也填写上信息</p>
<p>restart httpd in whm</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cpanelcn.info/%e5%ae%89%e8%a3%85%e4%ba%86selft-signed-ssl%e5%90%8ewhm-cpanel-restart-apache-failed.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>怎样查看Linux/Centos Raid状态？ Adaptec RAID array Status</title>
		<link>http://www.cpanelcn.info/how-do-i-check-the-health-of-my-adaptec-raid-array-linux.html</link>
		<comments>http://www.cpanelcn.info/how-do-i-check-the-health-of-my-adaptec-raid-array-linux.html#comments</comments>
		<pubDate>Sun, 23 Oct 2011 03:12:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux服务器优化]]></category>
		<category><![CDATA[Linux/Centos Raid状态]]></category>

		<guid isPermaLink="false">http://www.cpanelcn.info/?p=86</guid>
		<description><![CDATA[How do I check the health of my Adaptec RAID array? (LINUX) 怎样查看Linux/Centos Raid状态？ First, you will need the Linux version of Adaptec Storage Manager on your system. Normally, this will install the agent and the manager. On your SoftLayer server it will only install the agent, as this is all that is needed. Please [...]]]></description>
			<content:encoded><![CDATA[<p>How do I check the health of my Adaptec RAID array? (LINUX)<br />
怎样查看Linux/Centos Raid状态？<br />
<span>First, you will need the Linux version of Adaptec Storage Manager on your system. Normally, this will install the agent and the manager. On your SoftLayer server it will only install the agent, as this is all that is needed.</span></p>
<p><span>Please check <a href="http://downloads.service.softlayer.com">http://downloads.service.softlayer.com</a> for the latest 32bit or 64bit version of the Adaptec Storage Manager. VPN&nbsp;access is required to download from that page. </span></p>
</p>
<p><a href="http://downloads.service.softlayer.com/adaptectools/linux/64/asm_linux_x64_v5_20_17414.rpm"><span></span></a></p>
<p>Next you will need to download and install the rpm on your server if it isn’t already installed. (If you used SoftLayer’s install and are not running a custom install, chances are it is already installed, though we will run through it just for the ones that do not have it installed)
</p>
<p>First download the rpm from the link above using wget</p>
<p>At the command prompt type</p>
<p>wget **Link to RPM**<span><br /></span></p>
<p><img title="" alt="" src="http://knowledgelayer.softlayer.com/images/how_do_I_check_the_health_of_my_adaptec_raid_linux/1-wget-asm.JPG" width="764" height="429" align="bottom" border="0"></p>
<p>Next install the rpm,at the command prompt type:</p>
<p>rpm –Uvf asm_linux_v4.30-16038.rpm</p>
<p><img title="" alt="" src="http://knowledgelayer.softlayer.com/images/how_do_I_check_the_health_of_my_adaptec_raid_linux/2-asm-install.JPG" width="764" height="429" align="bottom" border="0"></p>
<p>After the application has been installed and started correctly, from the command prompt you will want to run the <b>arcconf</b> program in order to view the health of your array. </p>
<p><span>/usr/StorMan/arcconf getconfig 1 </span></p>
<p><img title="" alt="" src="http://knowledgelayer.softlayer.com/images/how_do_I_check_the_health_of_my_adaptec_raid_linux/1-degraded.JPG" width="938" height="1005" align="bottom" border="0"></p>
<p>Here you will noticed that Device #1 is Online, while Device #2 is Failed, thus meaning we have a degraded array and a hard disk will need to be replaced. </p>
<p><img title="" alt="" src="http://knowledgelayer.softlayer.com/images/how_do_I_check_the_health_of_my_adaptec_raid_linux/2-degraded.JPG" width="938" height="1037" align="bottom" border="0"></p>
<p>Just open up a SoftLayer support ticket to schedule a maintenance window for the drive replacement.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cpanelcn.info/how-do-i-check-the-health-of-my-adaptec-raid-array-linux.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache基础优化</title>
		<link>http://www.cpanelcn.info/apache%e5%9f%ba%e7%a1%80%e4%bc%98%e5%8c%96.html</link>
		<comments>http://www.cpanelcn.info/apache%e5%9f%ba%e7%a1%80%e4%bc%98%e5%8c%96.html#comments</comments>
		<pubDate>Sun, 31 Jul 2011 04:35:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cpanel使用技巧]]></category>
		<category><![CDATA[apache 基础优化， 负载]]></category>

		<guid isPermaLink="false">http://www.cpanelcn.info/?p=84</guid>
		<description><![CDATA[在WHM 后台可对Apacke进行基础优化。 Service Configuration >> Apache Configuration >> Global Configuration ServerSignature On MaxClients 256 StartServers 5 Timeout 120 KeepAlive On MaxKeepAliveRequests 9999 KeepAliveTimeout 10 StartServers 5 ServerLimit 512 MinSpareServers 10 MaxRequestsPerChild 9999 Keep alive on The Keep-Alive extension to HTTP/1.0 and the persistent connection feature of HTTP/1.1 provide long-lived HTTP sessions which allow multiple requests [...]]]></description>
			<content:encoded><![CDATA[<p>在WHM 后台可对Apacke进行基础优化。<br />
Service Configuration >> Apache Configuration >> Global Configuration</p>
<p><code><br />
ServerSignature On</p>
<p><IfModule prefork.c></p>
<p>MaxClients 256<br />
StartServers 5<br />
Timeout 120</p>
<p>KeepAlive On<br />
MaxKeepAliveRequests 9999<br />
KeepAliveTimeout 10<br />
StartServers 5<br />
ServerLimit 512<br />
MinSpareServers 10<br />
MaxRequestsPerChild 9999</p>
<p></IfModule> </code><br />
Keep alive on<br />
The Keep-Alive extension to HTTP/1.0 and the persistent connection feature of HTTP/1.1 provide long-lived HTTP sessions which allow multiple requests to be sent over the same TCP connection. In some cases this has been shown to result in an almost 50% speedup in latency times for HTML documents with many images. To enable Keep-Alive connections, set KeepAlive On.</p>
<p>For HTTP/1.0 clients, Keep-Alive connections will only be used if they are specifically requested by a client. In addition, a Keep-Alive connection with an HTTP/1.0 client can only be used when the length of the content is known in advance. This implies that dynamic content such as CGI output, SSI pages, and server-generated directory listings will generally not use Keep-Alive connections to HTTP/1.0 clients. For HTTP/1.1 clients, persistent connections are the default unless otherwise specified. If the client requests it, chunked encoding will be used in order to send content of unknown length over persistent connections.</p>
<p>When a client uses a Keep-Alive connection it will be counted as a single &#8220;request&#8221; for the MaxRequestsPerChild directive, regardless of how many requests are sent using the connection.</p>
<p>根据PageSpeed的规则，我们可以从KeepAlive，浏览器缓存，Gzip等方面对Apache进行些调整，从而提高网站性能。</p>
<h2>1. 开启Keep-Alive</h2>
<p>开启Keep-Alive后，可以保证浏览器和服务器之间的连接持久存在，这样如果同一个域名请求很多资源的情况下可以省去建立连接的时间和资源消耗。所以对于静态服务器来说，由于一个域名会请求N多资源，比较宜开启Keep-Alive，但是对于动态服务器，不宜开启Keep-Alive，因为这样会造成很多的空闲进程，浪费内存空间。<br />
配置：</p>
<pre class="brush: plain;">
KeepAlive On #开启KeepAlive
KeepAliveTimeout 5 #保持连接5秒
</pre>
<p><span id="more-24"></span></p>
<h2>2. HTTP缓存设置</h2>
<p>当直接在浏览器中输入一个URL，或者点击一个链接的时候，那么浏览器缓存就会起作用，如果缓存没有过期，那么浏览器会从本地读取资源，不会发起HTTP请求，如果缓存过期，那么浏览器会发起新的浏览器请求。按ctrl+F5，浏览器会情况本地缓存，重新请求资源。<br />
Expires是HTTP/1.0的缓存头， Cache-Control: max-age 是HTTP/1.1是用来进行HTTP缓存的头。Expires指定了资源过期的绝对时间，GMT格式，Cache-Control: max-age指定了资源过期的相对时间，单位是秒。在支持HTTP/1.1的浏览器上，如果发送两个头，那么Cache-Control: max-age会覆盖掉Expires；在支持HTTP/1.0的浏览器上，即使发送了两个头，但是只有Expires会起作用，所以为了兼容老的浏览器，还是要同时发送这两个头。设置HTTP缓存，需要安装expires_module，其会发送Expires和Cache-Control: max-age两个HTTP头。<br />
配置：</p>
<pre class="brush: plain;">
&lt;IfModule expires_module&gt;
ExpiresActive On
ExpiresByType application/x-javascript  &quot;access plus 30 days&quot;

ExpiresByType text/css  &quot;access plus 30 days&quot;
ExpiresByType image/gif  &quot;access plus 30 days&quot;
ExpiresByType image/jpeg  &quot;access plus 30 days&quot;
ExpiresByType image/png  &quot;access plus 30 days&quot;
&lt;/IfModule&gt;
</pre>
<p>ExpiresByType application/x-javascript  &#8220;access plus 30 days&#8221; 表示对js资源设置Expires和Cache-Control: max-age头，其中Expires的值是以客户端访问资源的时间为基准的后30天，Cache-Control: max-age的值是3600x24x30秒。</p>
<p>ExpiresByType application/x-javascript  &#8220;modification plus 30 days&#8221;和上面效果一样，只是Expires的时间是以资源最后修改的时间作为计算的基准。</p>
<h2>3. 开启Gzip压缩，并设置vary头</h2>
<p>Gzip会对文本资源进行压缩，一般能节省40%的大小，二进制内容不需要开启Gzip压缩，因为这些文件是已经压缩过的，如果再进行Gzip压缩反而会增加其大小。静态资源一般都会在代理服务器上进行缓存，而有的浏览器支持Gzip，但是也有不支持Gzip的老旧浏览器，所以需要设置Vary: Accept-Encoding 头，这个头告诉代理缓存服务器要对资源缓存两份，一份压缩过的，一份没有压缩过，然后根据浏览器发送的Accept-Encoding头来返回压缩或者不压缩的内容。设置Gzip压缩，需要安装deflate_module。<br />
配置：</p>
<pre class="brush: plain;">
&lt;IfModule deflate_module&gt;
#对js,html,xml,css,普通文本开启Gzip压缩
AddOutputFilterByType DEFLATE application/x-javascript text/html text/plain text/xml text/css
&lt;/IfModule&gt;
</pre>
<h2>4. 关掉ETag</h2>
<p>Last-Modified与ETag是同样的功能，都是用来标识一个资源是否更改过，Last-Modified的值是资源的时间戳，如果按F5或者刷新按钮则If-Modified-Since头会带着时间戳发送到服务器，如果服务器上资源的最后修改时间&lt;=这个时间，那么返回304 Not Modified，否则返回200 OK 以及新的资源；ETag的值是通过资源的信息（一般为inode，大小，时间戳）而计算出来的一个字符串，如果按F5或者刷新按钮则If-None-Match头会带着这个值发送到服务器，服务器用这个值来和当前资源的值进行比对，如果相等，则返回304 Not Modified，否则返回200 OK 以及新的资源。默认情况下Apache对静态资源会发送Last-Modified和ETage，但是由于ETage的计算会耗费服务器的CPU资源，所以选择关掉，只开启Last-Modified。</p>
<p>配置：</p>
<pre class="brush: plain;">
FileETag None
Header unset ETag
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.cpanelcn.info/apache%e5%9f%ba%e7%a1%80%e4%bc%98%e5%8c%96.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux 内存不足的解决办法 &#8211; 增加虚拟内存 Swap Space</title>
		<link>http://www.cpanelcn.info/linux-%e5%86%85%e5%ad%98%e4%b8%8d%e8%b6%b3%e7%9a%84%e8%a7%a3%e5%86%b3%e5%8a%9e%e6%b3%95-%e5%a2%9e%e5%8a%a0%e8%99%9a%e6%8b%9f%e5%86%85%e5%ad%98-swap-space.html</link>
		<comments>http://www.cpanelcn.info/linux-%e5%86%85%e5%ad%98%e4%b8%8d%e8%b6%b3%e7%9a%84%e8%a7%a3%e5%86%b3%e5%8a%9e%e6%b3%95-%e5%a2%9e%e5%8a%a0%e8%99%9a%e6%8b%9f%e5%86%85%e5%ad%98-swap-space.html#comments</comments>
		<pubDate>Sun, 31 Jul 2011 02:47:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux服务器优化]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[LINUX 内存太低]]></category>

		<guid isPermaLink="false">http://www.cpanelcn.info/?p=79</guid>
		<description><![CDATA[Q. Linux 内存不足， 服务器负载高会导致服务器当机。 在经过被当机多次后， 发现可以通过增加虚拟内存Swap Space的办法来缓解。 I need additional swap space to improve my system performance. How do I add a swap file to Linux system? A. In Linux, as in most other Unix-like operating systems, it is common to use a whole partition of a hard disk for swapping. However, with the 2.6 [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: rgb(255, 0, 0);">Q</span>. Linux 内存不足， 服务器负载高会导致服务器当机。 在经过被当机多次后， 发现可以通过增加虚拟内存Swap Space的办法来缓解。 I need additional swap space to improve my system performance. How do I add a swap file to Linux system?</p>
<p><span style="color: rgb(0, 153, 0);">A.</span> In Linux, as in most other Unix-like operating systems, it is common to use a whole partition of a hard disk for swapping. However, with the 2.6 Linux kernel, swap files are just as fast[7] as swap partitions, although Red Hat recommends using a swap partition. The administrative flexibility of swap files outweighs that of partitions; since modern high capacity hard drives can remap physical sectors, no partition is guaranteed to be contiguous. You can add swap file as a dedicated partition or use following instructions to create a swap file.</p>
<h3>Procedure to add a swap file</h3>
<p>You need to use dd command to create swapfile. Next you need to use mkswap command to set up a Linux swap area on a device or in a file.</p>
<p>a) Login as the root user SSH登录root 账户</p>
<p>b) Type following command to create 2G swap file (1024 * 2048MB =  2097152 block size):</p>
<p><code># dd if=/dev/zero of=/swapfile1 bs=1024 count=2097152</code></p>
<p>c) Set up a Linux swap area:<br />
<code># mkswap /swapfile1</code></p>
<p>d) Activate /swapfile1 swap space immediately:<br />
<code># swapon /swapfile1</code></p>
<p>e) To activate /swapfile1 after Linux system reboot, add entry to /etc/fstab file. Open this file using text editor such as vi:<br />
<code># vi /etc/fstab</code></p>
<p>Append following line:<br />
<code>/swapfile1    swap    swap   defaults 0 0</code></p>
<p>So next time Linux comes up after reboot, it enables the new swap file for you automatically.</p>
<p>g) How do I verify swap is activated or not?<br />
Simply use free command:<br />
<code>$ free -m</code></p>
<p>如果想关闭虚拟内存或者向扩大， 要先disable<br />
<code>swapoff /swapfile1</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cpanelcn.info/linux-%e5%86%85%e5%ad%98%e4%b8%8d%e8%b6%b3%e7%9a%84%e8%a7%a3%e5%86%b3%e5%8a%9e%e6%b3%95-%e5%a2%9e%e5%8a%a0%e8%99%9a%e6%8b%9f%e5%86%85%e5%ad%98-swap-space.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>怎样将大Mysql文件导入到远程服务器</title>
		<link>http://www.cpanelcn.info/transer-large-mysql-to-remote-server.html</link>
		<comments>http://www.cpanelcn.info/transer-large-mysql-to-remote-server.html#comments</comments>
		<pubDate>Wed, 16 Mar 2011 03:53:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mysql 教程]]></category>
		<category><![CDATA[大Mysql文件导入]]></category>

		<guid isPermaLink="false">http://www.cpanelcn.info/?p=74</guid>
		<description><![CDATA[首先创建数据库备份 mysqldump -v -u databaseuser -p databasename > db-name.out 然后将备份传送到远程服务器 scp db-name.out root@yourserver.com:/home/user 最后导入数据到新的数据库里 mysql -u newdatabaseuser-p newdatabasename < /home/user/db-name.out]]></description>
			<content:encoded><![CDATA[<p>首先创建数据库备份<br />
<code>mysqldump -v -u databaseuser -p  databasename > db-name.out</code><br />
然后将备份传送到远程服务器<br />
<code>scp db-name.out root@yourserver.com:/home/user</code><br />
最后导入数据到新的数据库里<br />
<code>mysql -u newdatabaseuser-p newdatabasename < /home/user/db-name.out</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cpanelcn.info/transer-large-mysql-to-remote-server.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

