<?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>PT Ubuntu Blog &#187; Nginx</title>
	<atom:link href="http://www.ptubuntu.com/tag/nginx/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ptubuntu.com</link>
	<description>Ruijin to linux 生活中的每一点点滴滴……</description>
	<lastBuildDate>Mon, 30 Jan 2012 09:17:42 +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>《在 Debian 上源码编译和安装 Nginx+PHP+FastCGI+MySQL</title>
		<link>http://www.ptubuntu.com/2010/08/3798.html</link>
		<comments>http://www.ptubuntu.com/2010/08/3798.html#comments</comments>
		<pubDate>Tue, 31 Aug 2010 06:46:01 +0000</pubDate>
		<dc:creator>ptubuntu</dc:creator>
				<category><![CDATA[Linux Server]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[fastcgi]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.ptubuntu.com/?p=3798</guid>
		<description><![CDATA[&#160; 操作基于 &#160;Debian 5.0 VPS&#160;256MB上测试通过，Nginx/PHP/MySQL 都采用当前最新稳定源代码版本。 安装必备软件包 # aptitude install libtidy-dev curl libcurl4-openssl-dev libcurl3 \ libcurl3-gnutls zlib1g zlib1g-dev libxslt1-dev libzip-dev libzip1 \ libxml2 libsnmp-base libsnmp15 libxml2-dev libsnmp-dev libjpeg62 \ libjpeg62-dev libpng12-0 libpng12-dev zlib1g zlib1g-dev libfreetype6 \ libfreetype6-dev libbz2-dev libxpm-dev libmcrypt-dev libmcrypt4 \ sqlite3 bzip2 build-essential libreadline5-dev libedit-dev autoconf 编译和安装 MySQL 下载和编译 MySQL，但是先不要安装： # wget http://mysql.mirror.rafal.ca/Downloads/MySQL-5.1/mysql-5.1.50.tar.gz [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.8em; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size: 13px; line-height: 20px; ">操作基于 &nbsp;<a href="http://www.ptubuntu.com/tag/debian" class="st_tag internal_tag" rel="tag" title="标签 Debian 下的日志">Debian</a> 5.0 VPS&nbsp;256MB上测试通过，<a href="http://www.ptubuntu.com/tag/nginx" class="st_tag internal_tag" rel="tag" title="标签 Nginx 下的日志">Nginx</a>/<a href="http://www.ptubuntu.com/tag/php" class="st_tag internal_tag" rel="tag" title="标签 php 下的日志">PHP</a>/<a href="http://www.ptubuntu.com/tag/mysql" class="st_tag internal_tag" rel="tag" title="标签 mysql 下的日志">MySQL</a> 都采用当前最新稳定源代码版本。</span></p>
<h2><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size: 13px; line-height: 20px; ">安装必备软件包</span></h2>
<blockquote><p># aptitude install libtidy-dev curl libcurl4-openssl-dev libcurl3 \ libcurl3-gnutls zlib1g zlib1g-dev libxslt1-dev libzip-dev libzip1 \ libxml2 libsnmp-base libsnmp15 libxml2-dev libsnmp-dev libjpeg62 \ libjpeg62-dev libpng12-0 libpng12-dev zlib1g zlib1g-dev libfreetype6 \ libfreetype6-dev libbz2-dev libxpm-dev libmcrypt-dev libmcrypt4 \ sqlite3 bzip2 build-essential libreadline5-dev libedit-dev autoconf</p>
</blockquote>
<h2><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size: 13px; line-height: 20px; ">编译和安装 MySQL</span></h2>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.8em; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size: 13px; line-height: 20px; ">下载和编译 MySQL，但是先不要安装：</span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.8em; margin-left: 0px; "><span id="more-3798"></span><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size: 13px; line-height: 20px; "><br />
	</span></p>
<blockquote><p># wget <a href="http://www.ptubuntu.com/tag/http" class="st_tag internal_tag" rel="tag" title="标签 http 下的日志">http</a>://mysql.mirror.rafal.ca/Downloads/MySQL-5.1/mysql-5.1.50.tar.gz <br />
		# tar zxvf mysql-5.1.50.tar.gz <br />
		# cd mysql-5.1.50 <br />
		# ./configure \ &#8211;prefix=&quot;/usr/local/mysql-5.1.50&quot; \ &#8211;enable-thread-safe-client \ &#8211;with-extra-charsets=all <br />
		# make</p>
</blockquote>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.8em; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size: 13px; line-height: 20px; ">需要改几个权限问题才能安装 MySQL，否则会出现 Access denied for user &lsquo;root&rsquo;@&#39;localhost&rsquo; (using password: NO) 经典问题：</span></p>
<blockquote><p># groupadd mysql <br />
		# useradd -g mysql mysql <br />
		# cp support-files/my-small.cnf /etc/my.cnf <br />
		# vi /etc/my.conf &#8230; [mysqld] user = mysql &#8230; <br />
		# chown -R mysql:mysql /usr/local/mysql-5.1.50/ <br />
		# chmod 777 /tmp</p>
</blockquote>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.8em; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size: 13px; line-height: 20px; ">安装和启动 MySQl，修改 root 密码，登录 MySQL：</span></p>
<blockquote><p># cd mysql-5.1.50 <br />
		# make install <br />
		# /usr/local/mysql-5.1.50/bin/mysql_install_db &#8211;user=mysql <br />
		# /usr/local/mysql-5.1.50/bin/mysqld_safe &amp; <br />
		# /usr/local/mysql-5.1.50/bin/mysqladmin -u root password &#39;new-password&#39; <br />
		# /usr/local/mysql-5.1.50/bin/mysql -u root -p</p>
</blockquote>
<h2><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size: 13px; line-height: 20px; ">编译和安装 PHP</span></h2>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.8em; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size: 13px; line-height: 20px; ">先下载 PHP 软件包，然后配置、编译，这里采用 php 5.2 分支的最新稳定代码：</span></p>
<blockquote><p># wget http://www.php.net/get/php-5.2.13.tar.bz2/from/us.php.net/mirror <br />
		# tar jxvf php-5.2.13.tar.bz2 <br />
		# cd php-5.2.13 <br />
		# ./configure \ &#8211;prefix=&quot;/usr/local/php-5.2.13&quot; \ &#8211;with-mysql=&quot;/usr/local/mysql-5.1.50&quot; \ &#8211;with-gd \ &#8211;with-ttf \ &#8211;with-openssl \ &#8211;enable-mbstring \ &#8211;enable-<a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a> <br />
		# make &amp;&amp; make install</p>
</blockquote>
<h2><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size: 13px; line-height: 20px; ">编译和安装 Nginx</span></h2>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.8em; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size: 13px; line-height: 20px; ">下载、配置和编译安装 nginx，注意编译 nginx 需要额外安装几个软件包：</span></p>
<blockquote><p># wget http://nginx.org/download/nginx-0.7.67.tar.gz <br />
		# tar zxvf nginx-0.7.67.tar.gz <br />
		# aptitude install libgcrypt11-dev libpcre3 libpcre3-dev libssl-dev <br />
		# cd nginx-0.7.67 <br />
		# ./configure &#8211;prefix=&quot;/usr/local/nginx-0.7.67&quot; &#8211;with-http_ssl_module # make &amp;&amp; make install</p>
</blockquote>
<h2><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size: 13px; line-height: 20px; ">编译和安装 FastCGI</span></h2>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.8em; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size: 13px; line-height: 20px; ">Nginx 需要 FastCGI 的支持才能运行 PHP 脚本，从 lighttpd 下载、编译和安装 spawn-fcgi：</span></p>
<blockquote><p># wget http://www.lighttpd.net/download/spawn-fcgi-1.6.2.tar.bz2 <br />
		# tar jxvf spawn-fcgi-1.6.2.tar.bz2 <br />
		# cd spawn-fcgi-1.6.2 <br />
		# ./configure &#8211;prefix=&quot;/usr/local/php-5.2.13&quot; <br />
		# make &amp;&amp; make install</p>
</blockquote>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.8em; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size: 13px; line-height: 20px; ">启动 FastCGI：</span></p>
<blockquote><p># /usr/local/php-5.2.13/bin/spawn-fcgi -a 127.0.0.1 -p 9000 \ -u www-data -g www-data -f /usr/local/php-5.2.13/bin/php-cgi \ -P /var/run/fastcgi-php.pid</p>
</blockquote>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.8em; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size: 13px; line-height: 20px; ">编辑 Nginx 的配置文件，让 php 脚本被发送到 FastCGI 服务器由 FastCGI 处理，然后启动 nginx：</span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.8em; margin-left: 0px; ">&nbsp;</p>
<blockquote><p># vi /usr/local/nginx-0.7.67/conf/nginx.conf &#8230;<br />
		# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 <br />
		# location ~ \.php$ { <br />
		#root html; root /usr/local/nginx-0.7.67/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/local/nginx-0.7.67/html$fastcgi_script_name; include fastcgi_params; } &#8230; <br />
		# /usr/local/nginx-0.7.67/sbin/nginx -c /usr/local/nginx-0.7.67/conf/nginx.conf</p>
</blockquote>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.8em; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size: 13px; line-height: 20px; ">安装 Nginx+FastCGI+PHP 完后测试一下是否 PHP 页面能否被正确解析，在 html 下创建一个含有 phpinfo(); 函数的文件，最后打开浏览器检查下面的 index.php 能否被正确执行。：</span></p>
<blockquote><p># vi /usr/local/nginx-0.7.67/html/index.php phpinfo();</p>
</blockquote>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.8em; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size: 13px; line-height: 20px; ">编译源代码需要消耗大量内存，我们只建议 256MB 或以上 VPS 用户使用源码方式安装。</span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.8em; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size: 13px; line-height: 20px; ">via{<a href="http://www.vpsee.com/2010/08/compile-and-install-nginx-php-fastcgi-mysql-on-debian-from-source/">vpsee.com</a>}</span></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ptubuntu.com%2F2010%2F08%2F3798.html&amp;title=%E3%80%8A%E5%9C%A8%20Debian%20%E4%B8%8A%E6%BA%90%E7%A0%81%E7%BC%96%E8%AF%91%E5%92%8C%E5%AE%89%E8%A3%85%20Nginx%2BPHP%2BFastCGI%2BMySQL" id="wpa2a_2"><img src="http://www.ptubuntu.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ptubuntu.com/2010/08/3798.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>安装Nginx 的 PHP 5.3 和 PHP-FPM 在 Ubuntu(10.04)</title>
		<link>http://www.ptubuntu.com/2010/06/3487.html</link>
		<comments>http://www.ptubuntu.com/2010/06/3487.html#comments</comments>
		<pubDate>Mon, 21 Jun 2010 16:18:47 +0000</pubDate>
		<dc:creator>ptubuntu</dc:creator>
				<category><![CDATA[Linux Server]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php-fpm]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.ptubuntu.com/?p=3487</guid>
		<description><![CDATA[安装PHP在nginx的平台上.基于ubuntu10.04的版本之上安装.安装过程看下面. 安装环境 0 在安装nginx之前必须有一个平台.下面是选择Ubuntu Lucid (10.04). 安装 nginx+php 安装Nginx 1 要先安装nginx. sudo apt-get install nginx 修改默认的配置文件. sudo vim /etc/nginx/sites-available/default 修改内容如下: server { listen 80; server_name localhost; access_log /var/log/nginx/localhost.access.log; ## Default location location / { root /var/www; index index.php; } ## Images and static content is treated different location ~* ^.+.(jpg&#124;jpeg&#124;gif&#124;css&#124;png&#124;js&#124;ico&#124;xml)$ { access_log off; expires 30d; [...]]]></description>
			<content:encoded><![CDATA[<div id="defer-adrectangleb">
<div>
<div id="defer-adrectangleb">
<div>
<p>安装PHP在nginx的平台上.基于ubuntu10.04的版本之上安装.安装过程看下面.</p>
<h3>安装环境 0</h3>
<p>在安装nginx之前必须有一个平台.下面是选择Ubuntu Lucid (10.04). 安装 <a href="http://www.ptubuntu.com/tag/nginx" class="st_tag internal_tag" rel="tag" title="标签 Nginx 下的日志">nginx</a>+<a href="http://www.ptubuntu.com/tag/php" class="st_tag internal_tag" rel="tag" title="标签 php 下的日志">php</a></p>
<h3>安装Nginx 1</h3>
<p>要先安装nginx.</p>
<blockquote><p>sudo apt-get install nginx</p></blockquote>
<p>修改默认的配置文件.</p>
<blockquote><p>sudo vim /etc/nginx/sites-available/default</p></blockquote>
<p><span id="more-3487"></span></p>
<p>修改内容如下:</p>
<blockquote>
<pre>server {
    listen   80;
    server_name  localhost;
    access_log  /var/log/nginx/localhost.access.log;

## Default location
    location / {
        root   /var/www;
        index  index.php;
    }

## Images and static content is treated different
    location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
      access_log        off;
      expires           30d;
      root /var/www;
    }

## Parse all .php file in the /var/www directory
    location ~ .php$ {
        <a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a>_split_path_info ^(.+\.php)(.*)$;
        <a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a>_pass   backend;
        <a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a>_index  index.php;
        <a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a>_param  SCRIPT_FILENAME  /var/www$<a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a>_script_name;
        include <a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a>_params;
        <a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a>_param  QUERY_STRING     $query_string;
        <a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a>_param  REQUEST_METHOD   $request_method;
        <a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a>_param  CONTENT_TYPE     $content_type;
        <a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a>_param  CONTENT_LENGTH   $content_length;
        <a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a>_intercept_errors        on;
        <a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a>_ignore_client_abort     off;
        <a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a>_connect_timeout 60;
        <a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a>_send_timeout 180;
        <a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a>_read_timeout 180;
        <a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a>_buffer_size 128k;
        <a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a>_buffers 4 256k;
        <a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a>_busy_buffers_size 256k;
        <a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a>_temp_file_write_size 256k;
    }

## Disable viewing .htaccess &amp; .htpassword
    location ~ /\.ht {
        deny  all;
    }
}
upstream backend {
        server 127.0.0.1:9000;
}</pre>
</blockquote>
<p>Ok, 安装好上面的Nginx那么现在可以安装 PHP.</p>
</div>
</div>
<h3>安装PHP 2</h3>
<p>我们现在需要安装PHP程序.使用apt-get来安装.安装php5.3和dotdeb在ubuntu10.04的系统之上.</p>
<blockquote><p>sudo apt-get update</p></blockquote>
<p>安装 dotdeb.</p>
<p>现在我们安装 PHP (part 1):</p>
<blockquote><p>sudo apt-get install php5-cli php5-common php5-suhosin</p></blockquote>
<p>安装 cli 之前需要先安装 安装 <a href="http://www.ptubuntu.com/tag/php-fpm" class="st_tag internal_tag" rel="tag" title="标签 php-fpm 下的日志">PHP-FPM</a>, 我们添加 PPA 因为他不会被支持安装.所以需要添加上去.</p>
<blockquote><p>add-apt-repository ppa:brianmercer/php</p></blockquote>
<blockquote><p>sudo apt-get update &amp;&amp; sudo apt-get install php5-fpm php5-cgi</p></blockquote>
<p>如果你打算使用一个数据库或要求（mcrypt，的LDAP，SNMP的等），你可以安装它们以及具体的模块。</p>
<div>好了，现在我们已经和PHP  nginx的安装和准备就绪。</div>
<p><strong>安装Finalizing 3 </strong></p>
<p>重装Nginx.c 以便我们修乞讨的配置才会生效.</p>
<blockquote><p>sudo /etc/init.d/nginx restart</p></blockquote>
<p>重新启动后应该没有什么大的问题.</p>
<p>php5-fpm安装后, 它应该可以正常工作. 如果你的php.ini 文件没有变动, 那么你重启一下 php5-fpm.</p>
<blockquote><p>sudo /etc/init.d/php5-fpm restart</p></blockquote>
<p>那么就可以正常运行.</p>
<h3>测试 4</h3>
<div>为了测试是否是PHP的执行工作, 创建 index.php 文件在 /var/www 内容如下:</div>
<blockquote>
<pre>&lt;?php phpinfo(); ?&gt;</pre>
</blockquote>
<h3>
<div>故障排除及最后附注 5</div>
</h3>
<div>如果您没有看到的phpinfo，有可能是一个错误.为了追查出了什么错，你可以检查nginx的错误日志:</div>
<blockquote><p>sudo tail /var/log/nginx/error.log</p></blockquote>
<div>请记住，如果你没有改变你的php.ini你必须重新启动的php5  &#8211; fpm的。重新启动nginx是不必要的。</div>
<p>In my example config I&#8217;ve enabled the fastcgi error interception. If a serious error occurs (for instance a “cannot redeclare class xyz”), nginx can catch this page and show a “nice” error page that something went wrong. This way, there is less information given out in case something is going seriously wrong.</p>
<p>If you do not like this, you can turn it off.</p>
<p>If php5-fpm is not running, your PHP files cannot be parsed and nginx will show the user an error page.</p>
<p>Well, I guess we&#8217;re done and you are now able to serve PHP with your new nginx based webserver. Nginx is pretty nice and you can configure a lot. If you need rewrites, be aware that nginx does not work with .htaccess files. You will need to change your vhost settings in order for the rewrites to work.</p>
</div>
</div>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ptubuntu.com%2F2010%2F06%2F3487.html&amp;title=%E5%AE%89%E8%A3%85Nginx%20%E7%9A%84%20PHP%205.3%20%E5%92%8C%20PHP-FPM%20%E5%9C%A8%20Ubuntu%2810.04%29" id="wpa2a_4"><img src="http://www.ptubuntu.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ptubuntu.com/2010/06/3487.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cherokee  真的比 Nginx 要牛？答案是一半一半！！</title>
		<link>http://www.ptubuntu.com/2010/03/3393.html</link>
		<comments>http://www.ptubuntu.com/2010/03/3393.html#comments</comments>
		<pubDate>Mon, 08 Mar 2010 01:13:21 +0000</pubDate>
		<dc:creator>ptubuntu</dc:creator>
				<category><![CDATA[Apache&php&Ftp]]></category>
		<category><![CDATA[技术类]]></category>
		<category><![CDATA[cherookee]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nginx]]></category>

		<guid isPermaLink="false">http://www.ptubuntu.com/?p=3393</guid>
		<description><![CDATA[Cherokee  号称是世界上处理速度最快的httpd server 甚至比 Nginx 要牛！ 很多人都抱有怀疑的态度，网上也纷纷展开了不通类型的测试，而我也是其中一个。 但撇开速度性能江湖中谁是老大这一论，就 Cherokee  本身，是有它自己相当的亮点。 最令我欣赏的，是它自带的管理工具，也可以说是管理后台了，以网页方式做配置。在里头除了可以调配系统中各项数值，还能配置虚拟主机，缓存，系统状态&#8230;.. 现在 Cherokee 连 1.0 版本都还没到，截止本文发表，最新版本是  Cherokee 0.99.14 。 可以说各方面的Bug都有相当的存在。所以在这个时候比性能，稳定&#8230;退一步说，给点面子吧&#8230;毕竟人家还没成熟。 我这么说，可并不是否认了 Cherokee 所号称的性能第一。的确，在用 apache 自带的 ab 压力测试成绩中看来。Cherokee 在并发量 100 的时候，确确实实是比 nginx 还要快!!! 再加上全功能相当讨人喜欢的管理后台，相比起 Nginx 单单只有一个 NginxStatus 我觉得 Cherokee 在这个点子的想法将会不同凡响。因为图形化的配置相当明了，省去了好多记忆配置语法的功夫。尤其对于新手来说，入门槛很低。 源码包解tar，编译，安装完成后。使用指定配置，端口等参数启用单独的管理后台进程，打开浏览器，输入账号自动生成的管理密码就能进入管理界面。如上图所示，可以直接启动以及关闭 Cherokee 的httpd 服务。 上图是http虚拟服务器(虚拟主机)的配置页，在此，你可以直接添加，修改，删除虚拟主机的操作。 高级配置，包括修改超时时限，http 端口，Cache 缓存&#8230;等各项 Cherokee  运作的参数。 相信这就是 Cherokee  为什么比 Nginx 快的原因之一。具有类似squid 这样的 Cache功能。 如果日后 Cherokee 更能加入均衡负载的状态，日志阅读，流量&#8230;.等更进一步强化后台的功能，这我看占有一定的市场可不是难事了。 好了，上边是简单介绍了一下，说到最认真的，性能。下边是用 [...]]]></description>
			<content:encoded><![CDATA[<p>Cherokee  号称是世界上处理速度最快的httpd server 甚至比 <a href="http://www.ptubuntu.com/tag/nginx" class="st_tag internal_tag" rel="tag" title="标签 Nginx 下的日志">Nginx</a> 要牛！<br />
很多人都抱有怀疑的态度，网上也纷纷展开了不通类型的测试，而我也是其中一个。</p>
<p>但撇开速度性能江湖中谁是老大这一论，就 Cherokee  本身，是有它自己相当的亮点。</p>
<p>最令我欣赏的，是它自带的管理工具，也可以说是管理后台了，以网页方式做配置。在里头除了可以调配系统中各项数值，还能配置虚拟主机，缓存，系统状态&#8230;..</p>
<p>现在 Cherokee 连 1.0 版本都还没到，截止本文发表，最新版本是 <a href="http://www.oschina.net/news/1651"> Cherokee 0.99.14 </a>。<br />
可以说各方面的Bug都有相当的存在。所以在这个时候比性能，稳定&#8230;退一步说，给点面子吧&#8230;毕竟人家还没成熟。</p>
<p>我这么说，可并不是否认了 Cherokee 所号称的性能第一。的确，在用 apache 自带的 ab 压力测试成绩中看来。Cherokee 在并发量 100 的时候，确确实实是比 nginx 还要快!!!</p>
<p>再加上全功能相当讨人喜欢的管理后台，相比起 Nginx 单单只有一个 NginxStatus 我觉得 Cherokee 在这个点子的想法将会不同凡响。因为图形化的配置相当明了，省去了好多记忆配置语法的功夫。尤其对于新手来说，入门槛很低。</p>
<p><img src="http://www.oschina.net/uploads/bbs/2009/0511/102324_c0bx_0.gif" alt="" /></p>
<p>源码包解tar，编译，安装完成后。使用指定配置，端口等参数启用单独的管理后台进程，打开浏览器，输入账号自动生成的管理密码就能进入管理界面。如上图所示，可以直接启动以及关闭 Cherokee 的httpd 服务。<br />
<span id="more-3393"></span></p>
<p><img src="http://www.oschina.net/uploads/bbs/2009/0511/102747_T3AY_0.gif" alt="" /></p>
<p>上图是http虚拟服务器(虚拟主机)的配置页，在此，你可以直接添加，修改，删除虚拟主机的操作。</p>
<p><img src="http://www.oschina.net/uploads/bbs/2009/0511/102717_UMJM_0.gif" alt="" /></p>
<p>高级配置，包括修改超时时限，<a href="http://www.ptubuntu.com/tag/http" class="st_tag internal_tag" rel="tag" title="标签 http 下的日志">http</a> 端口，Cache 缓存&#8230;等各项 Cherokee  运作的参数。</p>
<p><img src="http://www.oschina.net/uploads/bbs/2009/0511/103114_MmT6_0.gif" alt="" /></p>
<p>相信这就是 Cherokee  为什么比 Nginx 快的原因之一。具有类似squid 这样的 Cache功能。<br />
如果日后 Cherokee 更能加入均衡负载的状态，日志阅读，流量&#8230;.等更进一步强化后台的功能，这我看占有一定的市场可不是难事了。</p>
<p>好了，上边是简单介绍了一下，说到最认真的，性能。下边是用 Ngnx 0.6.31 与 Cherokee 0.99.13 所做对比测试的数据。</p>
<p>我们用2台服务器，一台负责发起ab请求，另一台安装 Cherokee。</p>
<p>被测试服务器配置：<br />
PowerEdge 1950<br />
CPU: Xeon E5110 X2<br />
内存: 1G,DDR2-667MHz ECC FBD X8<br />
硬盘: 146G SAS X2 (raid0)</p>
<p>HTML 测试结果：</p>
<table border="0" cellspacing="0" cellpadding="0" width="940">
<colgroup span="1">
<col span="1" width="185"></col>
<col span="1" width="145"></col>
<col span="1" width="285"></col>
<col span="1" width="325"></col>
</colgroup>
<tbody>
<tr height="18">
<td width="185" height="18"></td>
<td width="145"></td>
<td width="285"><strong>Nginx</strong></td>
<td width="325"><strong>Cherokee</strong></td>
</tr>
<tr height="18">
<td height="18"><strong> </strong></td>
<td><strong> </strong></td>
<td><strong> </strong></td>
<td><strong> </strong></td>
</tr>
<tr height="18">
<td height="18">1000/10W html 4K</td>
<td>所需时间</td>
<td>75.729</td>
<td>72.611</td>
</tr>
<tr height="18">
<td height="18">1000/10W html 48K</td>
<td>所需时间</td>
<td width="285">401.458</td>
<td>无法完成测试</td>
</tr>
<tr height="18">
<td height="18">1000/10W html 4K</td>
<td>每秒完成请求</td>
<td>13205.03</td>
<td>13772.03</td>
</tr>
<tr height="18">
<td height="18">1000/10W html 48K</td>
<td>每秒完成请求</td>
<td width="285">2490.92</td>
<td>无法完成测试</td>
</tr>
<tr height="18">
<td height="18"></td>
<td></td>
<td width="285"></td>
<td></td>
</tr>
<tr height="18">
<td height="18">500/10W html 4K</td>
<td>所需时间</td>
<td>67.179</td>
<td>65.286</td>
</tr>
<tr height="18">
<td height="18">500/10W html 48K</td>
<td>所需时间</td>
<td>401.438</td>
<td>401.147</td>
</tr>
<tr height="18">
<td height="18">500/10W html 4K</td>
<td>每秒完成请求</td>
<td>14885.62</td>
<td>15317.32</td>
</tr>
<tr height="18">
<td height="18">500/10W html 48K</td>
<td>每秒完成请求</td>
<td>2491.04</td>
<td>2492.85</td>
</tr>
<tr height="18">
<td height="18"></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr height="18">
<td height="18">100/10W html 4K</td>
<td>所需时间</td>
<td>65.801</td>
<td>58.057</td>
</tr>
<tr height="18">
<td height="18">100/10W html 48K</td>
<td>所需时间</td>
<td>401.458</td>
<td>401.024</td>
</tr>
<tr height="18">
<td height="18">100/10W html 4K</td>
<td>每秒完成请求</td>
<td>15197.24</td>
<td>17224.54</td>
</tr>
<tr height="18">
<td height="18">100/10W html 48K</td>
<td>每秒完成请求</td>
<td>2490</td>
<td>2493</td>
</tr>
</tbody>
</table>
<p><img src="http://www.oschina.net/uploads/bbs/2009/0511/112642_pPbz_0.gif" alt="" /></p>
<p><img src="http://www.oschina.net/uploads/bbs/2009/0511/112655_j3iO_0.gif" alt="" /></p>
<p>测试得出结果，在 ab 进行 100 个线程压力测试的时候，Cherokee 的完成测试时间要比Nginx少，原因是 Cherokee  每秒所处理的请求数要比 Nginx 多！</p>
<p>但当 ab 线程提高到 500 甚至一千的话，Cherokee  的优势变得很少，虽然还是轻微领先Nginx。但确相当不稳定。AB 会经常因httpd服务关闭而退出，能连续完成3次平均测试的几率不大，好像 1000 并发，10W请求的 48K html 静态文件就已经令Cherokee无法完成了。更糟糕的是，如果连续进行多次100次并发，到某一次的时候，ab测试也会频繁退出。需把被测试机的网络重启 service network restart ，测试才能继续。也就是说在高负载的情况下！Cherokee 不大行啊.</p>
<p>而作对比的 Nginx 确从然应对！100，500，1000 都一律通吃！而且完全没有Failed requests。(请求失败)</p>
<p>若然说 Cherokee 如他名字一样是一辆吉普车的话，这么我觉得 Nginx 更像一辆悍马。能够承载极端环境的考验。</p>
<p>而 Cherokee 只能单单从低端的并发数中胜出，这只能说是一件意义，而不能算是真正能跟 Nginx 做出较量。因为人家虽然开得较为慢点，不会掉链条。而 Cherokee 虽然开得快！确会掉链条&#8230;</p>
<p>继续努力吧 Cherokee ，我们大家都期待1.0 版本发布的那天。</p>
<p>顺带来个备注，在我进行 Cherokee 0.99.13 测试的第二天，Cherokee 0.99.14 发布了，据说改进了高并发时会退出的BUG，但我测试的时候效果依然。程序不会推出，可ab确依然被关闭了请求而未能完成测试就弹了出来。</p>
<p>除了进行 html 文件的测试，也进行了 JPG，GIF 的测试，成绩如下：</p>
<table border="0" cellspacing="0" cellpadding="0" width="612">
<colgroup span="1">
<col span="1" width="187"></col>
<col span="1" width="165"></col>
<col span="1" width="131"></col>
<col span="1" width="129"></col>
</colgroup>
<tbody>
<tr height="18">
<td width="187" height="18"></td>
<td width="165"></td>
<td width="131"><strong>Nginx</strong></td>
<td width="129"><strong>Cherokee</strong></td>
</tr>
<tr height="18">
<td height="18"><strong></strong></td>
<td><strong></strong></td>
<td><strong></strong></td>
<td><strong></strong></td>
</tr>
<tr height="18">
<td height="18">1000/10W GIF 1K</td>
<td>所需时间</td>
<td>80.114</td>
<td>74.687</td>
</tr>
<tr height="18">
<td height="18">1000/10W JPG 100K</td>
<td>所需时间</td>
<td width="131">836.834</td>
<td>无法完成测试</td>
</tr>
<tr height="18">
<td height="18">1000/10W GIF 1K</td>
<td>每秒完成请求</td>
<td>12482.28</td>
<td>13389.26</td>
</tr>
<tr height="18">
<td height="18">1000/10W JPG 100K</td>
<td>每秒完成请求</td>
<td width="131">1194.98</td>
<td>无法完成测试</td>
</tr>
<tr height="18">
<td height="18"></td>
<td></td>
<td width="131"></td>
<td></td>
</tr>
<tr height="18">
<td height="18">500/10W GIF 1K</td>
<td>所需时间</td>
<td>68.02</td>
<td>64.672</td>
</tr>
<tr height="18">
<td height="18">500/10W JPG 100K</td>
<td>所需时间</td>
<td>852.585</td>
<td>无法完成测试</td>
</tr>
<tr height="18">
<td height="18">500/10W GIF 1K</td>
<td>每秒完成请求</td>
<td>14701.45</td>
<td>15462.76</td>
</tr>
<tr height="18">
<td height="18">500/10W JPG 100K</td>
<td>每秒完成请求</td>
<td>1172.9</td>
<td>无法完成测试</td>
</tr>
<tr height="18">
<td height="18"></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr height="18">
<td height="18">100/10W GIF 1K</td>
<td>所需时间</td>
<td>66.602</td>
<td>61.43</td>
</tr>
<tr height="18">
<td height="18">100/10W JPG 100K</td>
<td>所需时间</td>
<td>852.389</td>
<td>851.014</td>
</tr>
<tr height="18">
<td height="18">100/10W GIF 1K</td>
<td>每秒完成请求</td>
<td>15014.5</td>
<td>16278.7</td>
</tr>
<tr height="18">
<td height="18">100/10W JPG 100K</td>
<td>每秒完成请求</td>
<td>1173.17</td>
<td>1175.07</td>
</tr>
</tbody>
</table>
<p>来处:http://www.oschina.net/bbs/thread/482</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ptubuntu.com%2F2010%2F03%2F3393.html&amp;title=Cherokee%20%20%E7%9C%9F%E7%9A%84%E6%AF%94%20Nginx%20%E8%A6%81%E7%89%9B%EF%BC%9F%E7%AD%94%E6%A1%88%E6%98%AF%E4%B8%80%E5%8D%8A%E4%B8%80%E5%8D%8A%EF%BC%81%EF%BC%81" id="wpa2a_6"><img src="http://www.ptubuntu.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ptubuntu.com/2010/03/3393.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Nginx + MySQL + FastCGI + PHP + eAccelerator 简易安装配置手册</title>
		<link>http://www.ptubuntu.com/2009/08/3039.html</link>
		<comments>http://www.ptubuntu.com/2009/08/3039.html#comments</comments>
		<pubDate>Tue, 18 Aug 2009 09:33:42 +0000</pubDate>
		<dc:creator>ptubuntu</dc:creator>
				<category><![CDATA[Apache&php&Ftp]]></category>
		<category><![CDATA[Linux Server]]></category>
		<category><![CDATA[技术类]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.ptubuntu.com/?p=3039</guid>
		<description><![CDATA[作者：Hily 原始链接：http://hily.me/blog/2008/11/nginx-mysql-fastcgi-php-eaccelerator/ 版权声明：可以转载，转载时务必以超链接形式标明文章原始出处和作者信息及版权声明 (本文所介绍的安装方法在 Debian 下进行，主要介绍用编译方式进行安装的方法，使用 package 安装较为简单，本文不做介绍。) 第一部分 安装指南   基本步骤： a. 解压源码包： tar zxf foobar.tar.gz b. 运行配置脚本： cd foobar/ ./configure –option=xxx …. c. 编译源码： make d. 安装： make install 具体编译安装步骤请参考以下安装脚本（点此下载）： # install script for mysql, php, nginx # writed by hilyjiang 20080718 # mysql apt-get install -y libncurses5-dev tar zxf mysql-5.0.51b.tar.gz cd mysql-5.0.51b/ [...]]]></description>
			<content:encoded><![CDATA[<p style="font-size: 12px; color: gray;">作者：<a style="color: gray;" href="http://hily.me/">Hily</a> 原始链接：<a style="color: gray;" href="http://hily.me/blog/2008/11/nginx-mysql-fastcgi-php-eaccelerator/">http://hily.me/blog/2008/11/nginx-mysql-fastcgi-php-eaccelerator/</a><br />
版权声明：可以转载，转载时务必以超链接形式标明文章<a style="color: gray;" href="http://hily.me/blog/2008/11/nginx-mysql-fastcgi-php-eaccelerator/">原始出处</a>和<a style="color: gray;" href="http://hily.me/blog/about/">作者信息</a>及<a style="color: gray;" href="http://creativecommons.org/licenses/by/3.0/deed.zh">版权声明</a></p>
<p><em>(本文所介绍的安装方法在 <a href="http://www.ptubuntu.com/tag/debian" class="st_tag internal_tag" rel="tag" title="标签 Debian 下的日志">Debian</a> 下进行，主要介绍用编译方式进行安装的方法，使用 package 安装较为简单，本文不做介绍。)</em></p>
<p><strong>第一部分 安装指南</strong></p>
<p><strong> </strong></p>
<p><strong>基本步骤：</strong></p>
<p>a. 解压源码包：</p>
<blockquote><p>tar zxf foobar.tar.gz</p></blockquote>
<p>b. 运行配置脚本：</p>
<blockquote><p>cd foobar/</p>
<p>./configure –option=xxx ….</p></blockquote>
<p>c. 编译源码：</p>
<blockquote><p>make</p></blockquote>
<p>d. 安装：</p>
<p><span id="more-3039"></span></p>
<blockquote><p>make install</p></blockquote>
<p>具体编译安装步骤请参考以下安装脚本（<a href="http://hily.me/blog/wp-content/uploads/2008/11/install.sh">点此下载</a>）：</p>
<blockquote><p># install script for <a href="http://www.ptubuntu.com/tag/mysql" class="st_tag internal_tag" rel="tag" title="标签 mysql 下的日志">mysql</a>, <a href="http://www.ptubuntu.com/tag/php" class="st_tag internal_tag" rel="tag" title="标签 php 下的日志">php</a>, <a href="http://www.ptubuntu.com/tag/nginx" class="st_tag internal_tag" rel="tag" title="标签 Nginx 下的日志">nginx</a><br />
# writed by hilyjiang 20080718</p>
<p># mysql<br />
apt-get install -y libncurses5-dev<br />
tar zxf mysql-5.0.51b.tar.gz<br />
cd mysql-5.0.51b/<br />
./configure –prefix=/usr/local/mysql –without-debug –with-client-ldflags=-all-static –with-mysqld-ldflags=-all-static –enable-assembler –with-extra-charsets=gbk,gb2312,utf8 –with-pthread –enable-thread-safe-client<br />
make<br />
make install<br />
cp support-files/my-medium.cnf /usr/local/mysql/my.cnf<br />
cd ../</p>
<p># php lib<br />
cd php<br />
tar zxvf libiconv-1.12.tar.gz<br />
cd libiconv-1.12/<br />
./configure –prefix=/usr/local<br />
make<br />
make install<br />
cd ../</p>
<p>tar zxvf freetype-2.3.7.tar.gz<br />
cd freetype-2.3.7/<br />
./configure<br />
make<br />
make install<br />
cd ../</p>
<p>tar zxvf libpng-1.2.29.tar.gz<br />
cd libpng-1.2.29/<br />
./configure<br />
make<br />
make install<br />
cd ../</p>
<p>tar zxvf jpegsrc.v6b.tar.gz<br />
cd jpeg-6b/<br />
./configure –enable-static –enable-shared<br />
make<br />
make install<br />
make install-lib<br />
cd ../</p>
<p>tar zxvf libxml2-2.6.32.tar.gz<br />
cd libxml2-2.6.32/<br />
./configure<br />
make<br />
make install<br />
cd ../</p>
<p>tar zxvf libmcrypt-2.5.8.tar.gz<br />
cd libmcrypt-2.5.8/<br />
./configure<br />
make<br />
make install<br />
/sbin/ldconfig<br />
cd libltdl/<br />
./configure –enable-ltdl-install<br />
make<br />
make install<br />
cd ../../</p>
<p>tar zxvf mhash-0.9.9.tar.gz<br />
cd mhash-0.9.9/<br />
./configure<br />
make<br />
make install<br />
cd ../</p>
<p>cp /usr/local/lib/libmcrypt.* /usr/lib<br />
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2</p>
<p>tar zxvf mcrypt-2.6.6.tar.gz<br />
cd mcrypt-2.6.6/<br />
./configure<br />
make<br />
make install<br />
cd ../</p>
<p>tar zxf gd-2.0.35.tar.gz<br />
cd gd-2.0.35/<br />
./configure<br />
make<br />
make install<br />
cd ../</p>
<p>tar zxf libssh2-0.12.tar.gz<br />
cd libssh2-0.12/<br />
./configure<br />
make<br />
make install<br />
cd ../</p>
<p># php<br />
apt-get install -y libcurl3-dev<br />
apt-get install -y bzip2<br />
tar jxf php-5.2.6.tar.bz2<br />
gzip -cd php-5.2.6-fpm-0.5.8.diff.gz | patch -d php-5.2.6 -p1<br />
cd php-5.2.6/<br />
./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –with-iconv-dir=/usr/local –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir –enable-xml –disable-debug –disable-rpath –enable-discard-path –enable-safe-mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-<a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a> –enable-fpm –enable-force-cgi-redirect –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –enable-ftp<br />
make<br />
make install<br />
mkdir /usr/local/php/etc<br />
cp php.ini-recommended /usr/local/php/etc/php.ini<br />
cd ../</p>
<p># php extensions<br />
# memcache<br />
apt-get -y install autoconf<br />
tar zxf memcache-2.2.3.tgz<br />
cd memcache-2.2.3/<br />
/usr/local/php/bin/phpize<br />
./configure –with-php-config=/usr/local/php/bin/php-config<br />
make<br />
make install<br />
cd ../</p>
<p># ssh2<br />
tar zxf ssh2-0.10.tgz<br />
cd ssh2-0.10/<br />
/usr/local/php/bin/phpize<br />
./configure –with-php-config=/usr/local/php/bin/php-config<br />
make<br />
make install<br />
cd ../</p>
<p># eaccelerator<br />
tar jxf eaccelerator-0.9.5.3.tar.bz2<br />
cd eaccelerator-0.9.5.3/<br />
/usr/local/php/bin/phpize<br />
./configure –with-php-config=/usr/local/php/bin/php-config<br />
make<br />
make install<br />
cd ../<br />
cd ../</p>
<p># nginx<br />
cd nginx<br />
dpkg -i libgoogle-perftools0_0.98-1_i386.deb<br />
dpkg -i libgoogle-perftools-dev_0.98-1_i386.deb</p>
<p>tar zxf pcre-7.7.tar.gz<br />
cd pcre-7.7<br />
./configure<br />
make<br />
make install<br />
cd ../</p>
<p>tar zxf nginx-0.6.32.tar.gz<br />
cd nginx-0.6.32/<br />
./configure –prefix=/usr/local/nginx –with-<a href="http://www.ptubuntu.com/tag/http" class="st_tag internal_tag" rel="tag" title="标签 http 下的日志">http</a>_stub_status_module –with-google_perftools_module<br />
make<br />
make install<br />
mkdir /usr/local/nginx/logs/logbydate/<br />
cd ../<br />
cd ../</p></blockquote>
<p><strong>维护要点：</strong></p>
<p>a. 编译软件或库时，最好在 configure 时配置使用默认的安装路径如 –prefix=/usr/local，以避免和使用包安装的软件冲突。也可以专门建立一个独立的目录，如 /usr/local/mysql 或 /home/apache。</p>
<p>b. 对冗繁的安装操作，最好写个安装脚本以便日后在多个服务器上自动部署。</p>
<p><strong>第二部分 </strong><strong>配置和维护</strong></p>
<p>主要配置文件打包于此：<a href="http://hily.me/blog/wp-content/uploads/2008/11/etc.zip">etc.zip</a>。</p>
<p><strong>1. Nginx</strong></p>
<p>·主要配置文件路径：</p>
<blockquote><p>/usr/local/nginx/conf/nginx.conf</p>
<p>/usr/local/nginx/conf/fastcgi_params</p>
<p>/usr/local/nginx/conf/sites/*</p></blockquote>
<p>·启动 nginx：</p>
<blockquote><p>/usr/local/nginx/sbin/nginx</p></blockquote>
<p>·停止 nginx：</p>
<blockquote><p>kill -TERM `cat /usr/local/nginx/logs/nginx.pid`</p></blockquote>
<p>·测试配置：</p>
<blockquote><p>/usr/local/nginx/sbin/nginx –t</p></blockquote>
<p>·重新加载配置：</p>
<blockquote><p>kill –HUP `cat /usr/local/nginx/logs/nginx.pid`</p></blockquote>
<p>·增加新站点：</p>
<p>在 conf/sites/ 下为新站点建立一个配置文件，命名规则为 sitename.enable。</p>
<p>（在 nginx.conf中设置只有以.enable结尾的配置文件才会被加载）</p>
<p>测试配置：</p>
<blockquote><p>/usr/local/nginx/sbin/nginx –t</p></blockquote>
<p>重新加载配置：</p>
<blockquote><p>kill –HUP `cat /usr/local/nginx/logs/nginx.pid`</p></blockquote>
<p>·按日切分日志：</p>
<p>使用以下脚本按日切分Nginx的日志：</p>
<blockquote><p>#! /bin/sh</p>
<p>log_dir=”/usr/local/nginx/logs”</p>
<p>date_postfix=`date +%Y%m%d`</p>
<p>src_log=${log_dir}/test.access.log</p>
<p>tmp_log=${log_dir}/test.access.log.tmp</p>
<p>des_log=${log_dir}/logbydate/test.access.${date_postfix}.log</p>
<p>if [ ! -f ${des_log} ]; then</p>
<p>mv ${src_log} ${des_log}</p>
<p>else</p>
<p>mv ${src_log} ${tmp_log}</p>
<p>cat ${tmp_log} &gt;&gt; ${des_log}</p>
<p>rm ${tmp_log}</p>
<p>fi</p>
<p>kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`</p></blockquote>
<p>cron中设置每天 23:59 分执行该脚本：</p>
<blockquote><p>$ crontab -uroot -e</p>
<p># m h dom mon dow command</p>
<p>59 23 * * * /usr/local/nginx/logs/cronlog.sh</p></blockquote>
<p><strong>2. MySQL</strong></p>
<p>·新建数据库服务器：</p>
<p>建立数据存放目录：</p>
<blockquote><p>mkdir /home/db/testdb</p>
<p>chown mysql /home/db/testdb</p></blockquote>
<p>安装 mysql 数据目录：</p>
<blockquote><p>/usr/local/mysql/bin/mysql_install_db –basedir=/usr/local/mysql –datadir=/home/db/testdb/data –user=mysql</p></blockquote>
<p>·拷贝并修改配置：</p>
<blockquote><p>cp /usr/local/mysql/my.cnf /home/db/testdb/</p></blockquote>
<p>/home/db/testdb/my.cnf：</p>
<blockquote><p>[client]</p>
<p>port = 3306</p>
<p>socket = /home/db/testdb/mysql.sock</p>
<p>[mysqld]</p>
<p>port = 3306</p>
<p>socket = /home/db/testdb/mysql.sock</p>
<p>datadir = /home/db/testdb/data</p>
<p>pid-file = /home/db/testdb/mysql.pid</p></blockquote>
<p>·建立启动和停止脚本：</p>
<p>/home/db/testdb/start.sh：</p>
<blockquote><p>#! /bin/sh</p>
<p>/usr/local/mysql/bin/mysqld_safe –defaults-file=/home/db/testdb/my.cnf &amp;</p></blockquote>
<p>/home/db/testdb/stop.sh：</p>
<blockquote><p>#! /bin/sh</p>
<p>/usr/local/mysql/bin/mysqladmin –defaults-file=/home/db/testdb/my.cnf -uroot -p shutdown</p></blockquote>
<p>添加执行权限：</p>
<blockquote><p>chmod +x /home/db/testdb/start.sh /home/db/testdb/stop.sh</p></blockquote>
<p>·启动服务：</p>
<blockquote><p>/home/db/testdb/start.sh</p></blockquote>
<p>·停止服务：</p>
<blockquote><p>/home/db/testdb/stop.sh</p></blockquote>
<p><strong>3. FastCGI-PHP</strong><strong>（<a href="http://www.ptubuntu.com/tag/php-fpm" class="st_tag internal_tag" rel="tag" title="标签 php-fpm 下的日志">PHP-FPM</a></strong><strong>）</strong></p>
<p>·主要配置文件路径：</p>
<blockquote><p>/usr/local/php/etc/php.ini</p>
<p>/usr/local/php/etc/php-fpm.ini</p></blockquote>
<p>·查看已加载PHP模块：</p>
<blockquote><p>/usr/local/php/bin/php-cgi –m</p></blockquote>
<p>·增加新的PHP模块：</p>
<p>编译安装：</p>
<blockquote><p>tar zxf php-ext.tar.gz</p>
<p>cd php-ext/</p>
<p>/usr/local/php/bin/phpize</p>
<p>./configure –with-php-config=/usr/local/php/bin/php-config</p>
<p>make</p>
<p>make install</p></blockquote>
<p>修改 /usr/local/php/etc/php.ini 的配置，在尾部加上 extension=”php-ext.so”。</p>
<p>·启动FastCGI：</p>
<blockquote><p>/usr/local/php/sbin/php-fpm start</p></blockquote>
<p>·停止FastCGI：</p>
<blockquote><p>/usr/local/php/sbin/php-fpm stop</p></blockquote>
<p>·重启FastCGI：</p>
<blockquote><p>/usr/local/php/sbin/php-fpm restart</p></blockquote>
<p>·重新加载 FPM 配置：</p>
<blockquote><p>/usr/local/php/sbin/php-fpm reload</p></blockquote>
<p><strong>4. 修改启动脚本</strong></p>
<p>使用Tarball安装的程序，如果需要在系统启动时自动启动，需要在系统的启动脚本 /etc/rc.local 中增加相应项，如：</p>
<blockquote><p>mkdir /tmp/eaccelerator/</p>
<p>chmod 777 /tmp/eaccelerator/</p>
<p>/home/db/testdb/start.sh</p>
<p>/usr/local/php/sbin/php-fpm start</p>
<p>/usr/local/nginx/sbin/nginx</p></blockquote>
<p>– EOF –<!--more--></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ptubuntu.com%2F2009%2F08%2F3039.html&amp;title=Nginx%20%2B%20MySQL%20%2B%20FastCGI%20%2B%20PHP%20%2B%20eAccelerator%20%E7%AE%80%E6%98%93%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE%E6%89%8B%E5%86%8C" id="wpa2a_8"><img src="http://www.ptubuntu.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ptubuntu.com/2009/08/3039.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>nginx 添加虚拟主机</title>
		<link>http://www.ptubuntu.com/2009/05/2467.html</link>
		<comments>http://www.ptubuntu.com/2009/05/2467.html#comments</comments>
		<pubDate>Fri, 15 May 2009 06:09:36 +0000</pubDate>
		<dc:creator>ptubuntu</dc:creator>
				<category><![CDATA[Linux Server]]></category>
		<category><![CDATA[Nginx]]></category>

		<guid isPermaLink="false">http://www.ptubuntu.com/?p=2467</guid>
		<description><![CDATA[如果你是在使用nginx做为你的主机.那么你要添加一个虚拟主机.如下添加红色为例.这个现在用的人还不是很多.但也为了自己以后留下一个笔记. 如果你的自动安装的程序那么这个配置文件是在. root@ptubuntu:/etc/nginx/sites-available#vi default # You may add here your # server { #       &#8230; # } # statements for each of your virtual hosts server {         listen   80;         server_name  ls.ptubuntu.com localhost;         access_log  /var/log/nginx/localhost.access.log;         location / {                 root   /var/www/nginx-default;                 index  index.php index.html index.htm;         }         location /doc { [...]]]></description>
			<content:encoded><![CDATA[<p>如果你是在使用nginx做为你的主机.那么你要添加一个虚拟主机.如下添加红色为例.这个现在用的人还不是很多.但也为了自己以后留下一个笔记.</p>
<p>如果你的自动安装的程序那么这个配置文件是在.<br />
<a href="mailto:root@ptubuntu:/etc/nginx/sites-available#vi">root@ptubuntu:/etc/nginx/sites-available#vi</a> default<br />
<span id="more-2467"></span></p>
<blockquote><p># You may add here your<br />
# server {<br />
#       &#8230;<br />
# }<br />
# statements for each of your virtual hosts</p>
<p>server {<br />
        listen   80;<br />
        server_name  ls.ptubuntu.com localhost;</p>
<p>        access_log  /var/log/<a href="http://www.ptubuntu.com/tag/nginx" class="st_tag internal_tag" rel="tag" title="标签 Nginx 下的日志">nginx</a>/localhost.access.log;</p>
<p>        location / {<br />
                root   /var/www/nginx-default;<br />
                index  index.<a href="http://www.ptubuntu.com/tag/php" class="st_tag internal_tag" rel="tag" title="标签 php 下的日志">php</a> index.html index.htm;<br />
        }</p>
<p>        location /doc {<br />
                root   /usr/share;<br />
                autoindex on;<br />
                allow 127.0.0.1;<br />
                deny all;<br />
        }</p>
<p>        location /images {<br />
                root   /usr/share;<br />
                autoindex on;<br />
        }</p>
<p>        #error_page  404  /404.html;</p>
<p>        # redirect server error pages to the static page /50x.html<br />
        #<br />
        error_page   500 502 503 504  /50x.html;<br />
        location = /50x.html {<br />
                root   /var/www/nginx-default;<br />
        }</p>
<p>        # proxy the PHP scripts to Apache listening on 127.0.0.1:80<br />
        #<br />
        #location ~ \.php$ {<br />
                #proxy_pass   <a href="http://127.0.0.1">http://127.0.0.1</a>;<br />
        #}<br />
 #location ~ \.php$ {<br />
                #proxy_pass   <a href="http://127.0.0.1">http://127.0.0.1</a>;<br />
        #}</p>
<p>        # pass the PHP scripts to <a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">FastCGI</a> server listening on 127.0.0.1:9000<br />
        location ~ \.php$ {<br />
        include /etc/nginx/fastcgi_params;<br />
        fastcgi_pass  127.0.0.1:9000;<br />
        fastcgi_index index.php;<br />
        fastcgi_param  SCRIPT_FILENAME  /var/www/nginx-default$fastcgi_script_name;<br />
    }</p>
<p>#<br />
        #location ~ \.php$ {<br />
                #fastcgi_pass   127.0.0.1:9000;<br />
                #fastcgi_index  index.php;<br />
                #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;<br />
                #includefastcgi_params;<br />
        #}</p>
<p>        # deny access to .htaccess files, if Apache&#8217;s document root<br />
        # concurs with nginx&#8217;s one<br />
        #<br />
        #location ~ /\.ht {<br />
                #deny  all;<br />
        #}<br />
}</p>
<p><span style="color: #ff0000;">server {<br />
                listen 80;<br />
                server_name     nginx.ptubuntu.comcn;</span></p>
<p><span style="color: #ff0000;">                location / {<br />
                        root /var/www/nginx-default/ptubuntu;<br />
                        index index.php index.html index.shtml;<br />
                }<br />
        }</span><br />
#}</p></blockquote>
<p>所要添加的就是上面这个nginx.ptubuntu.com为你的域名.<!--more--></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ptubuntu.com%2F2009%2F05%2F2467.html&amp;title=nginx%20%E6%B7%BB%E5%8A%A0%E8%99%9A%E6%8B%9F%E4%B8%BB%E6%9C%BA" id="wpa2a_10"><img src="http://www.ptubuntu.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ptubuntu.com/2009/05/2467.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu+Nginx+PHP5+FastCGI</title>
		<link>http://www.ptubuntu.com/2009/04/2172.html</link>
		<comments>http://www.ptubuntu.com/2009/04/2172.html#comments</comments>
		<pubDate>Fri, 10 Apr 2009 06:18:10 +0000</pubDate>
		<dc:creator>ptubuntu</dc:creator>
				<category><![CDATA[Apache&php&Ftp]]></category>
		<category><![CDATA[Linux Server]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[技术类]]></category>
		<category><![CDATA[fastcgi]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.ptubuntu.com/?p=2172</guid>
		<description><![CDATA[基于平台ubuntu的基础上安装nging,php5,FastCGI, MySQL. 1.安装 MySQL: root@ptubuntu:~#aptitude install mysql-server mysql-client libmysqlclient15-dev 2.安装 PHP5 root@ptubuntu:~#aptitude install php5-common php5-cgi php5-mysql php5-cli 3.安装gcgi程序 有几个不同的做法在这里使用安装 lighttpd 提取spawn-fcgi所以我们编辑它但不安装. root@ptubuntu:~#wget http://www.lighttpd.net/download/lighttpd-1.4.19.tar.gz root@ptubuntu:~#tar xvzf lighttpd-1.4.19.tar.gz root@ptubuntu:~#cd lighttpd-1.4.18.tar.gz root@ptubuntu:~#./configure root@ptubuntu:~#make root@ptubuntu:~#cp src/spawn-fcgi /usr/bin/spawn-fcgi 接下来要配置 FastCGI 设置端口号 listen on 127.0.0.1 port 9000, 配置文档 /usr/bin/php5-fastcgi root@ptubuntu:~#/usr/bin/php5-fastcgi #!/bin/sh /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -C [...]]]></description>
			<content:encoded><![CDATA[<p>基于平台ubuntu的基础上安装nging,<a href="http://www.ptubuntu.com/tag/php" class="st_tag internal_tag" rel="tag" title="标签 php 下的日志">php</a>5,<a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">FastCGI</a>, <a href="http://www.ptubuntu.com/tag/mysql" class="st_tag internal_tag" rel="tag" title="标签 mysql 下的日志">MySQL</a>.</p>
<p><strong>1.安装 MySQL:</strong></p>
<div class="wp_syntax">
<div class="code">
<blockquote>
<pre class="bash bash" style="font-family: monospace;"><span style="color: #008000;"><span style="font-weight: bold;">root@ptubuntu:~#aptitude install</span> mysql-server mysql-client libmysqlclient15-dev</span></pre>
</blockquote>
</div>
</div>
<p><strong>2.安装 PHP5</strong><span style="font-weight: bold;"><br />
</span></p>
<blockquote>
<pre><span style="color: #008000;"><span style="font-weight: bold;">root@ptubuntu:~#</span><span style="font-weight: bold;">aptitude</span> <span style="font-weight: bold;">install</span> php5-common php5-cgi php5-mysql php5-cli
</span></pre>
</blockquote>
<p><strong>3.安装gcgi程序</strong></p>
<p><strong></strong>有几个不同的做法在这里使用安装 lighttpd 提取spawn-fcgi所以我们编辑它但不安装.</p>
<blockquote><p><span style="color: #008000;">root@ptubuntu:~#wget <a href="http://www.ptubuntu.com/tag/http" class="st_tag internal_tag" rel="tag" title="标签 http 下的日志">http</a>://www.lighttpd.net/download/lighttpd-1.4.19.tar.gz<br />
root@ptubuntu:~#tar xvzf lighttpd-1.4.19.tar.gz<br />
root@ptubuntu:~#cd lighttpd-1.4.18.tar.gz<br />
root@ptubuntu:~#./configure<br />
root@ptubuntu:~#make<br />
root@ptubuntu:~#cp src/spawn-fcgi /usr/bin/spawn-fcgi</span></p></blockquote>
<p>接下来要配置 FastCGI 设置端口号 listen on 127.0.0.1 port 9000, 配置文档 /usr/bin/php5-fastcgi</p>
<blockquote><p><span style="color: #008000;">root@ptubuntu:~#/usr/bin/php5-fastcgi</span></p></blockquote>
<div class="wp_syntax">
<div class="code">
<pre class="bash bash" style="font-family: monospace;"><span style="color: #008080;"><span style="font-style: italic;">#!/bin/sh</span>
<span style="font-weight: bold;">/</span>usr<span style="font-weight: bold;">/</span>bin<span style="font-weight: bold;">/</span>spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -C 2 -f <span style="font-weight: bold;">/</span>usr<span style="font-weight: bold;">/</span>bin<span style="font-weight: bold;">/</span>php5-cgi</span></pre>
</div>
</div>
<p>设置php5-fastcgi权限:</p>
<div class="wp_syntax">
<div class="code">
<blockquote>
<pre class="bash bash" style="font-family: monospace;"><span style="color: #008000;">root@ptubuntu:~#</span><span style="color: #c20cb9; font-weight: bold;">chmod</span> +x <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php5-fastcgi</pre>
</blockquote>
</div>
</div>
<p>创建连接使用(ln -s)  php-fastcgi:</p>
<div class="wp_syntax">
<div class="code">
<blockquote>
<pre class="bash bash" style="font-family: monospace;"><span style="color: #008000;">root@ptubuntu:~#</span><span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php5-fastcgi <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php-fastcgi</pre>
</blockquote>
</div>
</div>
<p>现在打开init.d 目录修改 /etc/init.d/fastcgi文档:</p>
<blockquote><p><span style="color: #008000;">root@ptubuntu:~#</span>/etc/init.d/fastcgi</p></blockquote>
<div class="wp_syntax">
<div class="code">
<blockquote>
<pre class="bash bash" style="font-family: monospace; text-align: left;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;">PHP_SCRIPT</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php-fastcgi
<span style="color: #007800;">RETVAL</span>=0
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">"$1"</span> <span style="color: #000000; font-weight: bold;">in</span>
	start<span style="color: #7a0874; font-weight: bold;">)</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">"Starting fastcgi"</span>
		<span style="color: #007800;">$PHP_SCRIPT</span>
		<span style="color: #007800;">RETVAL</span>=<span style="color: #007800;">$?</span>
  ;;
	stop<span style="color: #7a0874; font-weight: bold;">)</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">"Stopping fastcgi"</span>
		<span style="color: #c20cb9; font-weight: bold;">killall</span> <span style="color: #660033;">-9</span> php5-cgi
		<span style="color: #007800;">RETVAL</span>=<span style="color: #007800;">$?</span>
  ;;
	restart<span style="color: #7a0874; font-weight: bold;">)</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">"Restarting fastcgi"</span>
		<span style="color: #c20cb9; font-weight: bold;">killall</span> <span style="color: #660033;">-9</span> php5-cgi
		<span style="color: #007800;">$PHP_SCRIPT</span>
		<span style="color: #007800;">RETVAL</span>=<span style="color: #007800;">$?</span>
  ;;
	<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">)</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">"Usage: php-fastcgi {start|stop|restart}"</span>
		<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
  ;;
<span style="color: #000000; font-weight: bold;">esac</span>
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #007800;">$RETVAL</span></pre>
</blockquote>
</div>
</div>
<p>修改fastcgi权限:</p>
<div class="wp_syntax">
<div class="code">
<blockquote>
<pre class="bash bash" style="font-family: monospace;"><span style="color: #008000;">root@ptubuntu:~#<span style="font-weight: bold;">chmod</span> 755 <span style="font-weight: bold;">/</span>etc<span style="font-weight: bold;">/</span>init.d<span style="font-weight: bold;">/</span>fastcgi</span></pre>
</blockquote>
</div>
</div>
<p>启动Fastcgi:</p>
<div class="wp_syntax">
<div class="code">
<blockquote>
<pre class="bash bash" style="font-family: monospace;"><span style="color: #008000;">root@ptubuntu:~#<span style="font-weight: bold;">/</span>etc<span style="font-weight: bold;">/</span>init.d<span style="font-weight: bold;">/</span>fastcgi start</span></pre>
</blockquote>
</div>
</div>
<p>你应该会看到下面这个:</p>
<blockquote><p><span style="color: #008080;">Starting fastcgi<br />
spawn-fcgi.c.197: child spawned successfully: PID: 19026</span></p></blockquote>
<p>设置系统开机启动:</p>
<blockquote><p><span style="color: #008000;">root@ptubuntu:~#update-rc.d fastcgi defaults</span></p></blockquote>
<p>创建FastCGI配置文件nginx /usr/local/<a href="http://www.ptubuntu.com/tag/nginx" class="st_tag internal_tag" rel="tag" title="标签 Nginx 下的日志">nginx</a>/fastcgi.conf</p>
<blockquote><p><span style="color: #008000;">root@ptubuntu:~#vi /usr/local/nginx/fastcgi.conf</span></p></blockquote>
<blockquote><p><span style="color: #008080;">fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;<br />
fastcgi_param  SERVER_SOFTWARE    nginx;<br />
fastcgi_param  QUERY_STRING       $query_string;<br />
fastcgi_param  REQUEST_METHOD     $request_method;<br />
fastcgi_param  CONTENT_TYPE       $content_type;<br />
fastcgi_param  CONTENT_LENGTH     $content_length;<br />
fastcgi_param  REQUEST_URI        $request_uri;<br />
fastcgi_param  DOCUMENT_URI       $document_uri;<br />
fastcgi_param  DOCUMENT_ROOT      $document_root;<br />
fastcgi_param  SERVER_PROTOCOL    $server_protocol;<br />
fastcgi_param  REMOTE_ADDR        $remote_addr;<br />
fastcgi_param  REMOTE_PORT        $remote_port;<br />
fastcgi_param  SERVER_ADDR        $server_addr;<br />
fastcgi_param  SERVER_PORT        $server_port;<br />
fastcgi_param  SERVER_NAME        $server_name;</span></p></blockquote>
<p>修改 nginx文档</p>
<blockquote><p><span style="color: #008000;">root@ptubuntu:~# vi /etc/nginx/sites-available/default</span></p></blockquote>
<p>添加下面这几行使得nginx可以支持PHP FastCGI socket:</p>
<blockquote><p><span style="color: #008080;">location ~ \.php$ {</span></p>
<p><span style="color: #008080;"> fastcgi_pass   127.0.0.1:9000;<br />
fastcgi_index  index.php;<br />
fastcgi_param  SCRIPT_FILENAME  /var/www/ptubuntu.com/public_html$fastcgi_script_name;<br />
include        /usr/local/nginx/fastcgi.conf;</span></p>
<p><span style="color: #008080;"> }</span></p></blockquote>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ptubuntu.com%2F2009%2F04%2F2172.html&amp;title=Ubuntu%2BNginx%2BPHP5%2BFastCGI" id="wpa2a_12"><img src="http://www.ptubuntu.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ptubuntu.com/2009/04/2172.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu9.04+Nginx+MySQL5+PHP5+Wordress</title>
		<link>http://www.ptubuntu.com/2009/04/2168.html</link>
		<comments>http://www.ptubuntu.com/2009/04/2168.html#comments</comments>
		<pubDate>Fri, 10 Apr 2009 02:47:07 +0000</pubDate>
		<dc:creator>ptubuntu</dc:creator>
				<category><![CDATA[Apache&php&Ftp]]></category>
		<category><![CDATA[Linux Server]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.ptubuntu.com/?p=2168</guid>
		<description><![CDATA[The Perfect Setup: Ubuntu Server 8.04.1 LTS Hardy + EngineX (NGINX) Web Server built from sources + MySQL 5 + PHP 5. (Or LEMP ) 测试机器基于256MB VPS slice at SliceHost. Should work for other hardware. 在这机器上安装Ubuntu Server. WordPress 基于 WP Super Cache plugin. 安装 NGinx WEB Server. 这里用户 &#8216;jsmith&#8217; 替换为你的域名 &#8216;mydomain.com&#8217;. 现在就让我们开始来执行下面的操作! 在服务器Ubuntu Server 要这安装的: [...]]]></description>
			<content:encoded><![CDATA[<p>The Perfect Setup:</p>
<p><strong><a href="http://www.ubuntu.com/getubuntu/download">Ubuntu Server 8.04.1 LTS Hardy</a> + EngineX (<a href="http://www.ptubuntu.com/tag/nginx" class="st_tag internal_tag" rel="tag" title="标签 Nginx 下的日志">NGINX</a>) Web Server built from sources + <a href="http://www.ptubuntu.com/tag/mysql" class="st_tag internal_tag" rel="tag" title="标签 mysql 下的日志">MySQL</a> 5 + <a href="http://www.ptubuntu.com/tag/php" class="st_tag internal_tag" rel="tag" title="标签 php 下的日志">PHP</a> 5.</strong><br />
(Or <strong><em>LEMP</em></strong> )</p>
<p>测试机器基于<a href="http://www.slicehost.com/">256MB VPS slice at SliceHost</a>. Should work for other hardware.</p>
<p>在这机器上安装Ubuntu Server. WordPress 基于 <a href="http://wordpress.org/extend/plugins/wp-super-cache/">WP Super Cache plugin</a>.<br />
安装 <a href="http://nginx.net/">NGinx WEB Server</a>.<br />
这里用户 &#8216;jsmith&#8217; 替换为你的域名 &#8216;mydomain.com&#8217;.</p>
<p>现在就让我们开始来执行下面的操作!</p>
<p><span class="sub_heading">在服务器Ubuntu Server 要这安装的:<br />
</span></p>
<ul>
<li>登录 root.</li>
<li>修改 root password:<br />
<span style="color: #008000;"><span class="code_tag">#sudo passwd</span></span></li>
<li>添加新用户  yourself:<br />
<span style="color: #008000;"><span class="code_tag">#adduser jsmith<br />
#visudo</span></span></li>
<li>Append this line to end of file (to navigate within &#8216;vi&#8217; editor to create next line &#8211; use these: <strong>L</strong>, <strong>$</strong>, <strong>a</strong>, &lt;ENTER&gt;):<br />
<span style="color: #008000;"><span class="in_editor_tag">jsmith ALL=(ALL) ALL</span></span><br />
保存退出: &lt;ESC&gt;, :wq, &lt;ENTER&gt;</li>
<li>配置 SSH:<br />
<span style="color: #008000;"><span class="code_tag">#vi /etc/ssh/sshd_config</span></span><br />
<span class="in_editor_tag">修改下面:<br />
<span style="color: #ff0000;">Port 22</span></span> &#8211; 这个设置ssh连接端口,默认值是22.<br />
- Set these to:<br />
<span style="color: #ff0000;"><span class="in_editor_tag">PermitRootLogin no   阻止root用户登录</span><br />
<span class="in_editor_tag">X11Forwarding no</span><br />
<span class="in_editor_tag">UsePAM no</span></span><br />
-设置可以登录的用户:<br />
<span style="color: #ff0000;"><span class="in_editor_tag">UseDNS no</span><br />
<span class="in_editor_tag">AllowUsers jsmith</span></span></li>
</ul>
<p>更多的资料请移到.<a href="http://www.ptubuntu.com/tag/http" class="st_tag internal_tag" rel="tag" title="标签 http 下的日志">http</a>://www.mensk.com/webmaster-toolbox/perfect-<a href="http://www.ptubuntu.com/tag/ubuntu" class="st_tag internal_tag" rel="tag" title="标签 Ubuntu 下的日志">ubuntu</a>-hardy-nginx-mysql5-php5-wordpress/</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ptubuntu.com%2F2009%2F04%2F2168.html&amp;title=Ubuntu9.04%2BNginx%2BMySQL5%2BPHP5%2BWordress" id="wpa2a_14"><img src="http://www.ptubuntu.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ptubuntu.com/2009/04/2168.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ubuntu9.04 install nginx+mysql+php+phpmyadmin</title>
		<link>http://www.ptubuntu.com/2009/04/2157.html</link>
		<comments>http://www.ptubuntu.com/2009/04/2157.html#comments</comments>
		<pubDate>Thu, 09 Apr 2009 10:46:55 +0000</pubDate>
		<dc:creator>ptubuntu</dc:creator>
				<category><![CDATA[Apache&php&Ftp]]></category>
		<category><![CDATA[Linux Server]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.ptubuntu.com/?p=2157</guid>
		<description><![CDATA[安装平台基于ubuntu 9.04.使用apt-get简单安装.在安装之前你要准备好源.还有安装库g++ vim ssh links因为你要用到这些功具. 下面这个就是我配置成功图. 1 Install Tools #apt-get install g++ vim links ssh 2 安装 MySQL 5.0 #apt-get install mysql-server mysql-client 在安装这个过程中会提示让你输入MYSQL数据库的密码: New password for the MySQL “root” user: &#60;&#8211; yourrootsqlpassword 你的MYSQL密码 Repeat password for the MySQL “root” user: &#60;&#8211; yourrootsqlpassword 你的MYSQL密码 3 安装 Nginx #apt-get install nginx 启动nginx: #/etc/init.d/nginx start 在IE浏览器输入你的IP地址:http://myip root@ptubuntu:~# [...]]]></description>
			<content:encoded><![CDATA[<p>安装平台基于ubuntu 9.04.使用apt-get简单安装.在安装之前你要准备好源.还有安装库g++ vim ssh links因为你要用到这些功具.</p>
<p>下面这个就是我配置成功图.</p>
<p><a href="http://www.ptubuntu.com/wp-content/uploads/2009/04/nginx04.jpeg" rel="shadowbox[sbpost-2157];player=img;"><img class="alignnone size-medium wp-image-2160" title="nginx04" src="http://www.ptubuntu.com/wp-content/uploads/2009/04/nginx04-500x273.jpg" alt="nginx04" width="500" height="273" /></a></p>
<p><strong>1</strong><strong> Install Tools</strong></p>
<blockquote><p><span style="color: #008000;">#apt-get install g++ vim links ssh</span></p></blockquote>
<h3>2 安装 <a href="http://www.ptubuntu.com/tag/mysql" class="st_tag internal_tag" rel="tag" title="标签 mysql 下的日志">MySQL</a> 5.0</h3>
<blockquote>
<p class="command"><span style="color: #008000;">#apt-get install mysql-server mysql-client</span></p>
</blockquote>
<p>在安装这个过程中会提示让你输入MYSQL数据库的密码:<br />
<span class="system">New password for the MySQL “root” user:</span> <span class="highlight">&lt;&#8211; yourrootsqlpassword 你的MYSQL密码</span><br />
<span class="system">Repeat password for the MySQL “root” user:</span> <span class="highlight">&lt;&#8211; yourrootsqlpassword </span><span class="highlight">你的MYSQL密码</span></p>
<p><span id="more-2157"></span></p>
<h3>3 安装 <a href="http://www.ptubuntu.com/tag/nginx" class="st_tag internal_tag" rel="tag" title="标签 Nginx 下的日志">Nginx</a></h3>
<blockquote>
<p class="command"><span style="color: #008000;">#apt-get install nginx</span><br />
启动nginx:<br />
<span style="color: #008000;">#/etc/init.d/nginx start</span></p>
</blockquote>
<p class="command">在IE浏览器输入你的IP地址:<a href="http://www.ptubuntu.com/tag/http" class="st_tag internal_tag" rel="tag" title="标签 http 下的日志">http</a>://myip</p>
<blockquote>
<p class="command"><span style="color: #008000;">root@ptubuntu:~# links ls.ptubuntu.com</span></p>
</blockquote>
<p class="command"><a href="http://www.ptubuntu.com/wp-content/uploads/2009/04/nginx01.jpeg" rel="shadowbox[sbpost-2157];player=img;"><img class="alignnone size-full wp-image-2158" title="nginx01" src="http://www.ptubuntu.com/wp-content/uploads/2009/04/nginx01.jpeg" alt="nginx01" width="417" height="121" /></a></p>
<p class="command">看到这里,说明你已安装上了nginx了.接下来我们要来配置它.设置启动系统时会自动启动它.</p>
<blockquote>
<p class="command"><span style="color: #008000;">root@ptubuntu:~# update-rc.d nginx defaults</span></p>
<p class="command">提示:System startup links for /etc/init.d/nginx already exist.</p>
</blockquote>
<h3>4 安装 <a href="http://www.ptubuntu.com/tag/php" class="st_tag internal_tag" rel="tag" title="标签 php 下的日志">PHP</a>5</h3>
<blockquote><p><span style="color: #008000;">root@ptubuntu:~# apt-get install php5-cgi php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl</span></p></blockquote>
<p>接下来要配置php.ini这个文件,在做一些配置文件之前最好你要做一个备份.</p>
<blockquote><p><span style="color: #008000;">root@ptubuntu:~# cd /etc/php5/cgi/<br />
root@ptubuntu:/etc/php5/cgi# ls</span><br />
conf.d  php.ini<br />
<span style="color: #008000;">root@ptubuntu:/etc/php5/cgi# cp php.ini php.ini.bak<br />
root@ptubuntu:/etc/php5/cgi# vi php.ini</span><br />
在php.ini这个文件里添加下一行</p>
<p><span style="color: #ff0000;">cgi.fix_pathinfo = 1</span></p></blockquote>
<p><strong>安装lighttpd</strong></p>
<blockquote><p><span style="color: #008000;">root@ptubuntu:# apt-get install lighttpd</span></p></blockquote>
<p>安装完接下来要移除它的自动启动程序让它不自动启动.</p>
<blockquote><p><span style="color: #008000;">root@ptubuntu:# update-rc.d -f lighttpd remove</span><br />
Removing any system startup links for /etc/init.d/lighttpd &#8230;<br />
/etc/rc0.d/K09lighttpd<br />
/etc/rc1.d/K09lighttpd<br />
/etc/rc2.d/S91lighttpd<br />
/etc/rc3.d/S91lighttpd<br />
/etc/rc4.d/S91lighttpd<br />
/etc/rc5.d/S91lighttpd<br />
/etc/rc6.d/K09lighttpd</p></blockquote>
<p>开启PHP <a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">FastCGI</a> 设置听的端口9000上运行的本地用户和<span class="system">www-data</span>, 运行下面程序:</p>
<blockquote><p><span style="color: #008000;">root@ptubuntu:# /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid</span></p></blockquote>
<p>显示 spawn-fcgi.c.197: child spawned successfully: PID: 29470</p>
<p>修改rc.local 这个文件.先备份一个.</p>
<blockquote><p><span style="color: #008000;">root@ptubuntu:~# cp /etc/rc.local .<br />
root@ptubuntu:~# vi /etc/rc.local</span><br />
添加<br />
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid</p></blockquote>
<p><strong>5 配置Nginx</strong></p>
<blockquote><p><span style="color: #008000;">root@ptubuntu:/etc/nginx# cp nginx.conf nginx.conf.bak<br />
root@ptubuntu:/etc/nginx# vi nginx.conf<br />
修改如下<br />
</span>[...]<br />
worker_processes  5;<br />
[...]<br />
keepalive_timeout  2;<br />
[...]</p></blockquote>
<h3>配置sites-available/default</h3>
<blockquote><p><span style="color: #008000;">root@ptubuntu:/etc/nginx/sites-available# cp default default.bak<br />
root@ptubuntu:/etc/nginx/sites-available# vi default</span></p></blockquote>
<p>下面这个就是我的配置文档,红色是添加修改:</p>
<blockquote><p><em><span style="color: #008000;">root@ptubuntu:/etc/nginx/sites-available# vi default</span></em></p></blockquote>
<blockquote><p><em><br />
# You may add here your<br />
# server {<br />
#    &#8230;<br />
# }<br />
# statements for each of your virtual hosts</em></p>
<p><em>server {<br />
listen   80;<br />
server_name  <span style="color: #ff0000;">ls.ptubuntu.com</span> localhost;</em></p>
<p><em>access_log  /var/log/nginx/localhost.access.log;</em></p>
<p><em>location / {<br />
root   /var/www/nginx-default;<br />
index  <span style="color: #ff0000;">index.php</span> index.html index.htm;<br />
}</em></p>
<p><em>location /doc {<br />
root   /usr/share;<br />
autoindex on;<br />
allow 127.0.0.1;<br />
deny all;<br />
}</em></p>
<p><em>location /images {<br />
root   /usr/share;<br />
autoindex on;<br />
}</em></p>
<p><em>#error_page  404  /404.html;</em></p>
<p><em># redirect server error pages to the static page /50x.html<br />
#<br />
error_page   500 502 503 504  /50x.html;<br />
location = /50x.html {<br />
root   /var/www/nginx-default;<br />
}</em></p>
<p><em># proxy the PHP scripts to Apache listening on 127.0.0.1:80<br />
#<br />
#location ~ \.php$ {<br />
#proxy_pass   http://127.0.0.1;<br />
#}</em></p>
<p><em># pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000<br />
</em><span style="color: #ff0000;"><em>location ~ \.php$ {<br />
fastcgi_pass   127.0.0.1:9000;<br />
fastcgi_index  index.php;<br />
fastcgi_param  SCRIPT_FILENAME  /var/www/nginx-default$fastcgi_script_name;<br />
include        fastcgi_params;<br />
}</em></span></p>
<p><em>#<br />
#location ~ \.php$ {<br />
#fastcgi_pass   127.0.0.1:9000;<br />
#fastcgi_index  index.php;<br />
#fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;<br />
#includefastcgi_params;<br />
#}</em></p>
<p><em># deny access to .htaccess files, if Apache&#8217;s document root<br />
# concurs with nginx&#8217;s one<br />
#<br />
#location ~ /\.ht {<br />
#deny  all;<br />
#}<br />
}</em></p>
<p><em># another virtual host using mix of IP-, name-, and port-based configuration<br />
#<br />
#server {<br />
#listen   8000;<br />
#listen   somename:8080;<br />
#server_name  somename  alias  another.alias;</em></p>
<p><em>#location / {<br />
#root   html;<br />
#index  index.html index.htm;<br />
#}<br />
#}</em></p>
<p><em># HTTPS server<br />
#<br />
#server {<br />
#listen   443;<br />
#server_name  localhost;</em></p>
<p><em>#ssl  on;<br />
#ssl_certificate  cert.pem;<br />
#ssl_certificate_key  cert.key;</em></p>
<p><em>#ssl_session_timeout  5m;</em></p>
<p><em>#ssl_protocols  SSLv2 SSLv3 TLSv1;<br />
#ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;<br />
#ssl_prefer_server_ciphers   on;</em></p>
<p><em>#location / {<br />
#root   html;<br />
#index  index.html index.htm;<br />
#}<br />
#}</em></p></blockquote>
<p>创建一个info.php页面.</p>
<blockquote><p><span style="color: #008000;">#vi /var/www/nginx-default/info.php</span></p>
<pre><span style="color: #808000;">&lt;?php
phpinfo();
?&gt;</span></pre>
</blockquote>
<p><strong>重启nginx</strong></p>
<blockquote><p><span style="color: #008000;">root@ptubuntu:/etc/nginx/sites-available# /etc/init.d/nginx restart<br />
root@ptubuntu:/var/www/nginx-default# /etc/init.d/lighttpd stop<br />
</span><span style="color: #99cc00;">这lighttp 要关了.要不然会网页显示会给跑到这里来.因为nginx &amp; ligttpd两个同时打开也会发生冲突的.而这里我们只是用到lighttp的插件所以没有必要开启.</span></p></blockquote>
<p>安装成功后的示图如下:</p>
<pre>
<a href="http://www.ptubuntu.com/wp-content/uploads/2009/04/nginx03.jpeg" rel="shadowbox[sbpost-2157];player=img;"><img class="alignnone size-medium wp-image-2159" title="nginx03" src="http://www.ptubuntu.com/wp-content/uploads/2009/04/nginx03-500x402.jpg" alt="nginx03" width="500" height="402" /></a></pre>
<p>接下来要安装的是支持PHP mysql</p>
<blockquote><p><span style="color: #008000;">root@ptubuntu:/usr/local/src# wget http://nchc.dl.sourceforge.net/sourceforge/phpmyadmin/phpMyAdmin-2.11.9.5-all-languages.tar.bz2<br />
root@ptubuntu:/usr/local/src#</span><span style="color: #008000;">cp phpMyAdmin-2.11.9.5-all-languages.tar.bz2 /var/www/nginx-default/<br />
</span><span style="color: #008000;">root@ptubuntu:/usr/local/src#c</span><span style="color: #008000;">d /var/www/nginx-default/<br />
</span><span style="color: #008000;">root@ptubuntu:/usr/local/src#</span><span style="color: #008000;">tar xvf phpMyAdmin-2.11.9.5-all-languages.tar.bz2<br />
</span><span style="color: #008000;">root@ptubuntu:/usr/local/src#</span><span style="color: #008000;">mv phpMyAdmin-2.11.9.5-all-languages phpmyadmin<br />
</span><span style="color: #008000;">root@ptubuntu:/usr/local/src#</span><span style="color: #008000;">cd phpmyadmin/<br />
</span></p></blockquote>
<p>接着修改配置文档.</p>
<blockquote><p><span style="color: #008000;">root@ptubuntu:/usr/local/src#cp config.sample.inc.php config.inc.php</p>
<p><span style="color: #33cccc;"> */<br />
<span style="color: #ff0000;"><span style="color: #33cccc;">$cfg['blowfish_secret'] = </span>&#8216;ptubuntu&#8217;;</span> /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */    <span style="color: #ff0000;">ptubuntu  改为你的mysql密码</span></p>
<p>/*<br />
其他地方也就不用改了就可以使用了.</span></span></p></blockquote>
<pre><a href="http://www.ptubuntu.com/wp-content/uploads/2009/04/phpmyadmin.jpeg" rel="shadowbox[sbpost-2157];player=img;"><img class="alignnone size-medium wp-image-2201" title="phpmyadmin" src="http://www.ptubuntu.com/wp-content/uploads/2009/04/phpmyadmin-500x500.jpg" alt="phpmyadmin" width="500" height="500" /></a>

参考外文:http://www.howtoforge.com/installing-nginx-with-php5-and-mysql-support-on-<a href="http://www.ptubuntu.com/tag/ubuntu" class="st_tag internal_tag" rel="tag" title="标签 Ubuntu 下的日志">ubuntu</a>-8.10

<!--more--></pre>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ptubuntu.com%2F2009%2F04%2F2157.html&amp;title=ubuntu9.04%20install%20nginx%2Bmysql%2Bphp%2Bphpmyadmin" id="wpa2a_16"><img src="http://www.ptubuntu.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ptubuntu.com/2009/04/2157.html/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>nginx+PHP+ mysql</title>
		<link>http://www.ptubuntu.com/2008/11/500.html</link>
		<comments>http://www.ptubuntu.com/2008/11/500.html#comments</comments>
		<pubDate>Thu, 20 Nov 2008 02:51:11 +0000</pubDate>
		<dc:creator>ruijin</dc:creator>
				<category><![CDATA[Apache&php&Ftp]]></category>
		<category><![CDATA[Linux Server]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[技术类]]></category>

		<guid isPermaLink="false">http://ptubuntu.com/?p=500</guid>
		<description><![CDATA[环境说明: nginx/0.5.33 +PHP 5.2.4-2  + mysql  5.0.51a 1. 安装Nginx.PHP和Mysql sudo apt-get install nginx sudo apt-get install php-pear php5-cli php5-common php5-xcache php5-cgi php5-mysql php5-gd sudo apt-get install mysql-server mysql-client 2. 从lighttpd中取得spawn-fcgi cd /home/hacder/ sudo apt-get install lighttpd sudo cp /usr/bin/spawn-fcgi ./ sudo apt-get remove lighttpd sudo mv spawn-fcgi /usr/bin/ 如果发现不能安装,可以通过: sudo apt-get install lighttpd &#8211;fix-missing 或者更新一下安装源: [...]]]></description>
			<content:encoded><![CDATA[<p>环境说明: <a href="http://www.ptubuntu.com/tag/nginx" class="st_tag internal_tag" rel="tag" title="标签 Nginx 下的日志">nginx</a>/0.5.33 +<a href="http://www.ptubuntu.com/tag/php" class="st_tag internal_tag" rel="tag" title="标签 php 下的日志">PHP</a> 5.2.4-2  + <a href="http://www.ptubuntu.com/tag/mysql" class="st_tag internal_tag" rel="tag" title="标签 mysql 下的日志">mysql</a>  5.0.51a</p>
<p>1. 安装Nginx.PHP和Mysql</p>
<div class="hl-surround">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)">
<li class="hl-firstline">sudo apt-get install nginx</li>
<li>sudo apt-get install php-pear php5-cli php5-common php5-xcache php5-cgi php5-mysql php5-gd</li>
<li>sudo apt-get install mysql-server mysql-client</li>
</ol>
</div>
<p>2. 从lighttpd中取得spawn-fcgi</p>
<div class="hl-surround">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)">
<li class="hl-firstline">cd /home/hacder/</li>
<li>sudo apt-get install lighttpd</li>
<li>sudo cp /usr/bin/spawn-fcgi ./</li>
<li>sudo apt-get remove lighttpd</li>
<li>sudo mv spawn-fcgi /usr/bin/</li>
</ol>
<p><span id="more-500"></span></div>
<p>如果发现不能安装,可以通过:</p>
<div class="hl-surround">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)">
<li class="hl-firstline">sudo apt-get install lighttpd &#8211;fix-missing</li>
</ol>
</div>
<p>或者更新一下安装源:</p>
<div class="hl-surround">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)">
<li class="hl-firstline"> apt-get update</li>
</ol>
</div>
<p>3. 添加php-cgi启动脚本:</p>
<div class="hl-surround">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)">
<li class="hl-firstline">vi /etc/init.d/php5-cgi</li>
</ol>
</div>
<p>输入:</p>
<div class="hl-surround">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)">
<li class="hl-firstline">#! /bin/sh</li>
<li></li>
<li>DESC=php5-cgi</li>
<li>NAME=php5-cgi</li>
<li></li>
<li>case “$1&#8243; in</li>
<li> start)</li>
<li> echo -n “Starting $DESC: “</li>
<li> /usr/bin/spawn-fcgi -a 127.0.0.1 -p 2222 -u www-data -f /usr/bin/php5-cgi -C 100</li>
<li> ;;</li>
<li> stop)</li>
<li> echo -n “Stopping $DESC: “</li>
<li> pkill php5-cgi</li>
<li> ;;</li>
<li> *)</li>
<li> N=/etc/init.d/$NAME</li>
<li> echo “Usage: $N {start|stop}” &amp;gt;&amp;amp;2</li>
<li> exit 1</li>
<li> ;;</li>
<li>esac</li>
<li></li>
<li>exit 0</li>
</ol>
</div>
<p>更改脚本权限为可以执行:</p>
<div class="hl-surround">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)">
<li class="hl-firstline">chmod +x /etc/init.d/php5-cgi</li>
</ol>
</div>
<p>启动php5-cgi:</p>
<div class="hl-surround">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)">
<li class="hl-firstline">/etc/init.d/php5-cgi start</li>
</ol>
</div>
<p>查看是否启动:</p>
<div class="hl-surround">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)">
<li class="hl-firstline">ps -ef |grep php</li>
</ol>
</div>
<p>4. 配置nginx:</p>
<div class="hl-surround">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)">
<li class="hl-firstline">vi /etc/nginx/nginx.conf</li>
</ol>
</div>
<p>修改内容为:</p>
<div class="hl-surround">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)">
<li class="hl-firstline">user www-data;</li>
<li>worker_processes  16;</li>
<li></li>
<li>error_log  /var/log/nginx/error.log;</li>
<li>pid        /var/run/nginx.pid;</li>
<li></li>
<li>events {</li>
<li> worker_connections  3060;</li>
<li>}</li>
<li></li>
<li><a href="http://www.ptubuntu.com/tag/http" class="st_tag internal_tag" rel="tag" title="标签 http 下的日志">http</a> {</li>
<li> include       /etc/nginx/mime.types;</li>
<li> default_type  application/octet-stream;</li>
<li></li>
<li> #access_log /var/log/nginx/access.log;</li>
<li> access_log  off;</li>
<li></li>
<li> sendfile        on;</li>
<li> #tcp_nopush     on;</li>
<li></li>
<li> #keepalive_timeout  0;</li>
<li> keepalive_timeout  65;</li>
<li> tcp_nodelay        on;</li>
<li></li>
<li> gzip  on;</li>
<li></li>
<li> include /etc/nginx/sites-enabled/*;</li>
<li>}</li>
</ol>
</div>
<p>添加站点配置文件:</p>
<div class="hl-surround">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)">
<li class="hl-firstline">vi /etc/nginx/sites-enabled/hacder.com</li>
</ol>
</div>
<div class="hl-surround">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)">
<li class="hl-firstline">server {</li>
<li> server_name hacder.com;</li>
<li> listen 80;</li>
<li></li>
<li>#    access_log /var/log/nginx/hacder.com.access.log;</li>
<li></li>
<li> gzip on;</li>
<li> gzip_comp_level 9;</li>
<li></li>
<li> client_max_body_size 10m;</li>
<li></li>
<li> index index.html index.php;</li>
<li> root /data/www/hacder.com;</li>
<li></li>
<li> location ~ .*\.php$ {</li>
<li> include /etc/nginx/<a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a>.conf;</li>
<li></li>
<li> fastcgi_hide_header X-Powered-By;</li>
<li>#        fastcgi_pass unix:/dev/shm/fcgi_php5.socket;</li>
<li> fastcgi_pass 127.0.0.1:2222;</li>
<li> fastcgi_index index.php;</li>
<li> fastcgi_param SCRIPT_FILENAME /data/www/hacder.com$fastcgi_script_name;</li>
<li> }</li>
<li></li>
<li> location ~ .+\.[gif|jpg|jpeg|png|ico|rar] {</li>
<li> expires 1M;</li>
<li> }</li>
<li></li>
<li>}</li>
</ol>
</div>
<p>启动nginx:</p>
<div class="hl-surround">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)">
<li class="hl-firstline">/etc/init.d/nginx start</li>
</ol>
</div>
<p>6 . 配置mysql</p>
<p>默认的msyql数据文件保存位置是: /var/lib/msyql/<br />
一般这个分区不会太大,也为了统一管理,我们需要更改msyql的位置:</p>
<div class="hl-surround">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)">
<li class="hl-firstline">vi /etc/msyql/my.cnf</li>
</ol>
</div>
<p>修改为:</p>
<div class="hl-surround">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)">
<li class="hl-firstline">datadir         = /data/mysql</li>
</ol>
</div>
<p>如果修改位置后,不能如常启动mysql的话,有可能是ubuntu的问题.这个问题我已经遇到两三次了,这个是找到的解决方案:</p>
<div class="hl-surround">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)">
<li class="hl-firstline">sudo touch /etc/apparmor.d/disable/usr.sbin.mysqld</li>
<li>sudo /etc/init.d/apparmor restart</li>
<li>sudo /etc/init.d/mysql restart</li>
</ol>
</div>
<p>稍微优化一下msyql:</p>
<div class="hl-surround">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)">
<li class="hl-firstline">#</li>
<li># * Fine Tuning</li>
<li>#</li>
<li>key_buffer              = 2048M</li>
<li>table_cache             = 2048</li>
<li>max_connections         = 300</li>
<li>tmp_table_size          = 512M</li>
<li>max_heap_table_size     = 512M</li>
<li>myisam_sort_buffer_size = 128M</li>
<li>sort_buffer_size        = 1M</li>
<li>record_buffer           = 16M</li>
<li>read_buffer_size        = 1M</li>
<li>read_rnd_buffer_size    = 8M</li>
<li>query_cache_size        = 1024M</li>
<li>thread_concurrency      = 8</li>
<li>wait_timeout            = 60</li>
<li>join_buffer_size        = 16M</li>
<li>#open_files_limit        = 1024</li>
<li>max_allowed_packet      = 16M</li>
<li>thread_cache_size       = 64</li>
<li>thread_stack            = 128K</li>
<li>#max_connections        = 100</li>
<li>#table_cache            = 64</li>
<li>#thread_concurrency     = 10</li>
</ol>
</div>
<p>启动msyql:</p>
<div class="hl-surround">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)">
<li class="hl-firstline">/etc/init.d/msyql start</li>
</ol>
</div>
<p>看来最近老是心神不定,以后还是得多加注意!做如何事情前都要多加考虑…<br />
原创文章如转载，请注明：转载自 Hacder’s Lab  [ http://www.hacder.cn ] <!--more--></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ptubuntu.com%2F2008%2F11%2F500.html&amp;title=nginx%2BPHP%2B%20mysql" id="wpa2a_18"><img src="http://www.ptubuntu.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ptubuntu.com/2008/11/500.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>在Linux平台上安装和配置Ruby on Rails详解</title>
		<link>http://www.ptubuntu.com/2008/11/494.html</link>
		<comments>http://www.ptubuntu.com/2008/11/494.html#comments</comments>
		<pubDate>Thu, 20 Nov 2008 02:21:52 +0000</pubDate>
		<dc:creator>ruijin</dc:creator>
				<category><![CDATA[Linux Server]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://ptubuntu.com/?p=494</guid>
		<description><![CDATA[ruby on rails推荐的生产运行环境是Linux/FreeBSD/Unix，即Unix系列的操作系统，采用lighttpd＋FCGI的解决方案。以下我将 以Linux操作系统，lighttpd＋FCGI，MySQL数据库为例，从源代码编译安装开始讲解。 在安装之前，应该确认Linux操作系统已经安装好gcc编译器，否则请用Linux安装光盘先行安装gcc编译器： gcc –v 如能返回gcc版本号，则gcc正确安装。 一、安装 Ruby 解析器 一些Linux发行版本，MacOSX操作系统都自带Ruby解析器，但是我仍然建议自行下载ruby源代码编译安装。因为一方面可以自己定制ruby安装的路径，另一方面可以在编译过程中自行添加更多的特性。 ruby的源代码可以从Ruby官方网站下载： http://www.ruby-lang.org/en/downloads/ 下载源代码包到本地Linux主机，然后解压缩，进入该目录，进行配置，编译和安装： tar xzvf ruby-1.8.5.tar.gz cd ruby-1.8.5 ./configure –prefix=/usr/local/ruby make &#38;&#38; make install 如果想浏览所有的configure参数，可以： ./configure –help &#124;more 如果不定制安装的目录，默认将安装到/usr/local目录下面。然而我建议自行定制一个ruby的安装目录，例如/usr/local/ruby，这样便于以后的升级，不会和操作系统其他软件混在一起。 安装好以后，修改操作系统PATH路径，加入/usr/local/ruby/bin： export PATH=/usr/local/ruby/bin:$PATH 将我们自己安装的ruby放在系统PATH前面，避免操作系统自带的ruby造成的干扰。在Linux上，一般将设置放在/etc/profile中，便于对全局生效。 二、安装 ruby on rails 在安装rails之前，要先安装rubygems。rubygems是ruby的在线包管理工具，可以从rubyforge下载rubygems： http://rubyforge.org/projects/rubygems/ 下载好源代码包，解压缩，安装： tar xzvf rubygems-0.9.0.tgz cd rubygems-0.9.0/ ruby setup.rb 然后就可以安装rails了，在确认服务器已经连接互联网的情况下执行： gem install rails –y 即通过gem从rubyforge网站下载rails所有依赖包安装。 [...]]]></description>
			<content:encoded><![CDATA[<div><a href="http://ptubuntu.com/wp-content/uploads/2008/11/ruby1.jpeg" rel="shadowbox[sbpost-494];player=img;"><img class="size-medium wp-image-497 alignnone" title="ruby1" src="http://ptubuntu.com/wp-content/uploads/2008/11/ruby1.jpeg" alt="" width="327" height="121" /></a></div>
<div>
<p><a href="http://www.ptubuntu.com/tag/ruby" class="st_tag internal_tag" rel="tag" title="标签 ruby 下的日志">ruby</a> on rails推荐的生产运行环境是Linux/FreeBSD/Unix，即Unix系列的操作系统，采用lighttpd＋FCGI的解决方案。以下我将 以Linux操作系统，lighttpd＋FCGI，MySQL数据库为例，从源代码编译安装开始讲解。</p></div>
<div>
<p>在安装之前，应该确认Linux操作系统已经安装好gcc编译器，否则请用Linux安装光盘先行安装gcc编译器：</p></div>
<div>
<p><span style="background-color: #e6e6e6;">gcc –v </span></div>
<div>
<p>如能返回gcc版本号，则gcc正确安装。</p></div>
<div><strong><span style="font-size: 12pt;">一、安装</span> </strong> <strong><span style="font-size: 12pt;">Ruby</span> </strong> <strong><span style="font-size: 12pt;">解析器</span> </strong></div>
<div>
<pre>一些Linux发行版本，MacOSX操作系统都自带Ruby解析器，但是我仍然建议自行下载ruby源代码编译安装。因为一方面可以自己定制ruby安装的路径，另一方面可以在编译过程中自行添加更多的特性。</pre>
</div>
<div>
<pre>ruby的源代码可以从Ruby官方网站下载：</pre>
</div>
<div>
<pre><a href="http://www.ruby-lang.org/en/downloads/">http://www.ruby-lang.org/en/downloads/</a></pre>
</div>
<div>
<pre>下载源代码包到本地Linux主机，然后解压缩，进入该目录，进行配置，编译和安装：</pre>
</div>
<div>
<pre><span style="background-color: #e6e6e6;">tar xzvf ruby-1.8.5.tar.gz</span></pre>
</div>
<div>
<pre><span style="background-color: #e6e6e6;">cd ruby-1.8.5</span></pre>
</div>
<div>
<pre><span style="background-color: #e6e6e6;">./configure –prefix=/usr/local/ruby</span></pre>
</div>
<div>
<pre><span style="background-color: #e6e6e6;">make &amp;&amp; make install</span></pre>
</div>
<div>
<pre>如果想浏览所有的configure参数，可以：</pre>
</div>
<div>
<pre><span style="background-color: #e6e6e6;">./configure –help |more</span></pre>
<div><span id="more-494"></span></div>
</div>
<div>如果不定制安装的目录，默认将安装到/usr/local目录下面。然而我建议自行定制一个ruby的安装目录，例如/usr/local/ruby，这样便于以后的升级，不会和操作系统其他软件混在一起。</div>
<div>安装好以后，修改操作系统PATH路径，加入/usr/local/ruby/bin：</div>
<div><span style="background-color: #e6e6e6;">export PATH=/usr/local/ruby/bin:$PATH</span></div>
<div>将我们自己安装的ruby放在系统PATH前面，避免操作系统自带的ruby造成的干扰。在Linux上，一般将设置放在/etc/profile中，便于对全局生效。</div>
<div><strong><span style="font-size: 12pt;">二、安装</span> </strong> <strong><span style="font-size: 12pt;">ruby on rails</span> </strong></div>
<div>在安装rails之前，要先安装rubygems。rubygems是ruby的在线包管理工具，可以从rubyforge下载rubygems：</div>
<div><a href="http://rubyforge.org/projects/rubygems/">http://rubyforge.org/projects/rubygems/</a></div>
<div>下载好源代码包，解压缩，安装：</div>
<div><span style="background-color: #e6e6e6;">tar xzvf rubygems-0.9.0.tgz</span></div>
<div><span style="background-color: #e6e6e6;">cd rubygems-0.9.0/</span></div>
<div><span style="background-color: #e6e6e6;">ruby setup.rb</span></div>
<div>然后就可以安装rails了，在确认服务器已经连接互联网的情况下执行：</div>
<div><span style="background-color: #e6e6e6;">gem install rails –y</span></div>
<div>即通过gem从rubyforge网站下载rails所有依赖包安装。</div>
<div>安装好rails以后，可以执行：</div>
<div><span style="background-color: #e6e6e6;">rails –v </span></div>
<div>确认一下rails的版本。</div>
<div><strong><span style="font-size: 12pt;">三、安装</span> </strong> <strong><span style="font-size: 12pt;">ruby</span> </strong> <strong><span style="font-size: 12pt;">的数据库适配器</span> </strong></div>
<div>rails发行包中已经自带纯ruby的MySQL数据库适配器，然而对于生产环境来说，我们仍然应该下载安装C版本的数据库适配器，以达到更好的性能。下载mysql-ruby-2.7.3.tar.gz：</div>
<div><a href="http://www.tmtm.org/en/mysql/ruby/">http://www.tmtm.org/en/mysql/ruby/</a></div>
<div><span style="background-color: #e6e6e6;">tar xzvf <a href="http://www.ptubuntu.com/tag/mysql" class="st_tag internal_tag" rel="tag" title="标签 mysql 下的日志">mysql</a>-ruby-2.7.3.tar.gz</span></div>
<div><span style="background-color: #e6e6e6;">cd mysql-ruby-2.7.3</span></div>
<div><span style="background-color: #e6e6e6;">ruby extconf.rb &#8211;with-mysql-dir=/opt/mysql5 </span></div>
<div><span style="background-color: #e6e6e6;">make &amp;&amp; make install</span></div>
<div>注意&#8211;with-mysql-dir应该指向MySQL数据库的安装路径，如果数据库服务器和Web服务器不在同一台机器上，那么Web服务器上也必须安装MySQL软件，因为ruby的C版本MySQL适配器需要在编译的时候联接MySQL的系统库。</div>
<div><strong><span style="font-size: 12pt;">四、安装</span> </strong> <strong><span style="font-size: 12pt;">Ruby</span> </strong> <strong><span style="font-size: 12pt;">的</span> </strong> <strong><span style="font-size: 12pt;">FCGI</span> </strong> <strong><span style="font-size: 12pt;">支持</span> </strong></div>
<div>由于ruby的fcgi支持库需要在编译的时候联接FCGI的系统库，因此我们需要先安装FCGI库，下载FCGI源代码发行包：</div>
<div><a href="http://www.fastcgi.com/dist/">http://www.fastcgi.com/dist/</a></div>
<div><span style="background-color: #e6e6e6;">tar xzvf fcgi-2.4.0.tar.gz</span></div>
<div><span style="background-color: #e6e6e6;">cd fcgi-2.4.0</span></div>
<div><span style="background-color: #e6e6e6;">./configure &#8211;prefix=/usr/local/fcgi</span></div>
<div><span style="background-color: #e6e6e6;">make &amp;&amp; make install</span></div>
<div>同样，将fcgi安装在自己指定的目录下，而不是默认的/usr/local，避免多个软件混在一起。</div>
<div>然后就可以安装ruby的fcgi支持库了，下载ruby-fcgi-0.8.7.tar.gz：</div>
<div><a href="http://rubyforge.org/projects/fcgi/">http://rubyforge.org/projects/fcgi/</a></div>
<div><span style="background-color: #e6e6e6;">tar xzvf ruby-fcgi-0.8.7.tar.gz</span></div>
<div><span style="background-color: #e6e6e6;">cd ruby-fcgi-0.8.7</span></div>
<div><span style="background-color: #e6e6e6;">ruby install.rb config &#8212; &#8211;with-fcgi-include=/usr/local/fcgi/include &#8211;with-fcgi-lib=/usr/local/fcgi/lib </span></div>
<div><span style="background-color: #e6e6e6;">ruby install.rb setup</span></div>
<div><span style="background-color: #e6e6e6;">ruby install.rb install</span></div>
<div><strong><span style="font-size: 12pt;">五、安装</span> </strong> <strong><span style="font-size: 12pt;">lighttpd Web Server</span> </strong></div>
<div><strong><span style="font-size: 12pt;">安装</span> </strong> <strong><span style="font-size: 12pt;">Lighttpd</span> </strong></div>
<div>在安装lighttpd之前，应该确认操作系统已经安装pcre，即Perl兼容的规则表达式库：</div>
<div><span style="background-color: #e6e6e6;">rpm –qa |grep pcre</span></div>
<div>如果没有，请从Linux安装光盘里面安装。</div>
<div>然后下载lighttpd：</div>
<div><a href="http://www.lighttpd.net/download/">http://www.lighttpd.net/download/</a></div>
<div><span style="background-color: #e6e6e6;">tar xzvf lighttpd-1.4.13.tar.gz</span></div>
<div><span style="background-color: #e6e6e6;">cd lighttpd-1.4.13</span></div>
<div><span style="background-color: #e6e6e6;">./configure &#8211;prefix=/usr/local/lighttpd</span></div>
<div>configure完毕以后，会给出一个激活的模块和没有激活模块的清单，可以检查一下，是否自己需要的模块都已经激活，在enable的模块中一定要有“mod_rewrite”这一项，否则重新检查pcre是否安装。然后编译安装：</div>
<div><span style="background-color: #e6e6e6;">make &amp;&amp; make install </span></div>
<div>编译后配置：</div>
<div><span style="background-color: #e6e6e6;">cp doc/sysconfig.lighttpd /etc/sysconfig/lighttpd</span></div>
<div><span style="background-color: #e6e6e6;">mkdir /etc/lighttpd</span></div>
<div><span style="background-color: #e6e6e6;">cp doc/lighttpd.conf /etc/lighttpd/lighttpd.conf</span></div>
<div>如果你的Linux是RedHat/CentOS，那么：</div>
<div><span style="background-color: #e6e6e6;">cp doc/rc.lighttpd.redhat /etc/init.d/lighttpd</span></div>
<div>如果你的Linux是SuSE，那么：</div>
<div><span style="background-color: #e6e6e6;">cp doc/rc.lighttpd /etc/init.d/lighttpd</span></div>
<div>如果你的Linux是ubuntu，那么需要自己创建启动脚本，lighttpd官方wiki上面已经给出来该脚本，地址在：</div>
<div><a title="ubuntu start script" href="http://redmine.lighttpd.net/wiki/1/ScriptsUbuntu" target="_blank">http://redmine.lighttpd.net/wiki/1/ScriptsUbuntu</a></div>
<div>其他Linux发行版本可以自行参考该文件内容进行修改，或者自己写一个控制脚本，也不过举手之劳：</div>
<div class="dp-highlighter">
<div class="bar">
<div class="tools">C代码 <a title="复制代码" onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" href="http://www.javaeye.com/topic/43228#"><img src="http://www.javaeye.com/images/icon_copy.gif" alt="复制代码" /></a></div>
</div>
<ol class="dp-cpp">
<li><span><span class="preprocessor">#!/bin/sh</span><span> </span></span></li>
<li><span> </span></li>
<li><span><span class="keyword">case</span><span> </span><span class="string">“$1&#8243;</span><span> in </span></span></li>
<li><span> start) </span></li>
<li><span> /usr/local/lighttpd/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf &gt; /dev/null 2&gt;&amp;1 </span></li>
<li><span> ;; </span></li>
<li><span> stop) </span></li>
<li><span> killall lighttpd </span></li>
<li><span> ;; </span></li>
<li><span> restart) </span></li>
<li><span> $0 stop </span></li>
<li><span> sleep 1 </span></li>
<li><span> $0 start </span></li>
<li><span> ;; </span></li>
<li><span> *) </span></li>
<li><span> echo <span class="string">“Usage: lighttpd.sh {start|stop|restart}”</span><span> </span></span></li>
<li><span> ;; </span></li>
<li><span>esac </span></li>
<li><span> </span></li>
<li><span>exit 0 </span></li>
</ol>
</div>
<pre class="c" style="display: none;">#!/bin/sh

case "$1" in
  start)
    /usr/local/lighttpd/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf &gt; /dev/null 2&gt;&amp;1
    ;;
  stop)
    killall lighttpd
    ;;
  restart)
   $0 stop
   sleep 1
   $0 start
   ;;
  *)
  echo "Usage: lighttpd.sh {start|stop|restart}"
  ;;
esac

exit 0</pre>
<div>然后修改/etc/init.d/lighttpd，把</div>
<div><span style="background-color: #e6e6e6;">LIGHTTPD_BIN=/usr/sbin/lighttpd</span></div>
<div>改为</div>
<div><span style="background-color: #e6e6e6;">LIGHTTPD_BIN=/usr/local/lighttpd/sbin/lighttpd</span></div>
<div>此脚本用来控制lighttpd的启动关闭和重起：</div>
<div><span style="background-color: #e6e6e6;">/etc/init.d/lighttpd start </span></div>
<div><span style="background-color: #e6e6e6;">/etc/init.d/lighttpd stop </span></div>
<div><span style="background-color: #e6e6e6;">/etc/init.d/lighttpd restart</span></div>
<div>如果你希望服务器启动的时候就启动lighttpd，那么：</div>
<div><span style="background-color: #e6e6e6;">chkconfig lighttpd on</span></div>
<div>这样lighttpd就安装好了，接下来需要配置lighttpd。</div>
<div><strong><span style="font-size: 12pt;">配置</span> </strong> <strong><span style="font-size: 12pt;">Lighttpd</span> </strong></div>
<div>修改/etc/lighttpd/lighttpd.conf</div>
<div>1）server.modules</div>
<div>取消需要用到模块的注释，mod_rewrite，mod_access，mod_<a href="http://www.ptubuntu.com/tag/fastcgi" class="st_tag internal_tag" rel="tag" title="标签 fastcgi 下的日志">fastcgi</a>，mod_simple_vhost，mod_cgi，mod_compress，mod_accesslog是一般需要用到的。</div>
<div>2）server.document-root, server.error-log，accesslog.filename需要指定相应的目录</div>
<div>3）用什么权限来运行lighttpd</div>
<div><span style="background-color: #e6e6e6;">server.username<span> = “nobody”</span> </span></div>
<div><span style="background-color: #e6e6e6;">server.groupname<span> = “nobody”</span> </span></div>
<div>从安全角度来说，不建议用root权限运行web server，可以自行指定普通用户权限。</div>
<div>4）静态文件压缩</div>
<div><span style="background-color: #e6e6e6;">compress.cache-dir<span> = “/tmp/lighttpd/cache/compress”</span> </span></div>
<div><span style="background-color: #e6e6e6;">compress.filetype<span> = (“text/plain”, “text/html”,”text/javascript”,”text/css”)</span> </span></div>
<div>可以指定某些静态资源类型使用压缩方式传输，节省带宽，对于大量AJAX应用来说，可以极大提高页面加载速度。</div>
<div>5）配置ruby on rails</div>
<div>最简单的配置如下：</div>
<div><span style="background-color: #e6e6e6;">$<a href="http://www.ptubuntu.com/tag/http" class="st_tag internal_tag" rel="tag" title="标签 http 下的日志">HTTP</a>["host"] == “www.xxx.com” {</span></div>
<div><span style="background-color: #e6e6e6;"> server.document-root = “/yourrails/public”</span></div>
<div><span style="background-color: #e6e6e6;"> server.error-handler-404 = “/dispatch.fcgi”</span></div>
<div><span style="background-color: #e6e6e6;"> fastcgi.server = (“.fcgi” =&gt;</span></div>
<div><span style="background-color: #e6e6e6;"><span> (“localhost” =&gt;</span> </span></div>
<div><span style="background-color: #e6e6e6;"><span> (“min-procs” =&gt; 10,</span> </span></div>
<div><span style="background-color: #e6e6e6;"><span> “max-procs” =&gt; 10,</span> </span></div>
<div><span style="background-color: #e6e6e6;"><span> “socket” =&gt; “/tmp/lighttpd/socket/rails.socket”,</span> </span></div>
<div><span style="background-color: #e6e6e6;"><span> “bin-path” =&gt; “/yourrails/public/dispatch.fcgi”,</span> </span></div>
<div><span style="background-color: #e6e6e6;"><span> “bin-environment” =&gt; (“RAILS_ENV” =&gt; “production”)</span> </span></div>
<div><span style="background-color: #e6e6e6;"><span> )</span> </span></div>
<div><span style="background-color: #e6e6e6;"><span> )</span> </span></div>
<div><span style="background-color: #e6e6e6;"> )</span></div>
<div><span style="background-color: #e6e6e6;">}</span></div>
<div>即由lighttpd启动10个FCGI进程，lighttpd和FCGI之间使用本机Unix Socket通信。</div>
<div>Lighttpd的FAQ：无法启动Ruby on Rails</div>
<div>FastCGI的启动脚本位于Rails应用目录下面public/dispatch.fcgi，如果无法启动Lighttpd，报告 FastCGI错误，你可以尝试着手工运行该脚本cd public &amp;&amp; ./dispatch.fcgi，看看是否可以运行。一般来说，很多人都是在Windows下面创建Rails项目，导致dispatch.fcgi脚本 的ruby运行路径指向windows下面的ruby，部署到Linux上面就无法运行了，另外一方面Windows上面创建的Rails项目在 Linux上面dispatch.fcgi没有可执行权限，所以也需要授予可执行权限。</div>
<div><strong><span style="font-size: 12pt;">六、安装</span> </strong> <strong><span style="font-size: 12pt;">ImageMagick</span> </strong> <strong><span style="font-size: 12pt;">和</span> </strong> <strong><span style="font-size: 12pt;">RMagic</span> </strong></div>
<div>RMagic是ruby处理图片需要用到的库，很多ruby应用由于都涉及图片处理的功能，往往需要依赖RMagic，但安装ImageMagick和RMagic相当烦琐，需要特别的说明。</div>
<div><strong><span style="font-size: 12pt;">安装</span> </strong> <strong><span style="font-size: 12pt;">ImageMagick</span> </strong></div>
<div><a href="http://www.imagemagick.org/">http://www.imagemagick.org</a></div>
<div>ImageMagick是用C语言实现的图形处理库，有Unix版本和Windows版本。对于Unix版本来说，安装比较麻烦些，另外不建议 安装ImageMagick二进制版本，往往会导致缺少某些图片处理功能，导致RMagic安装失败。下载ImageMagick源代码，解压缩，配置：</div>
<div><span style="background-color: #e6e6e6;">tar xzvf ImageMagick-6.2.9-0.tar.gz</span></div>
<div><span style="background-color: #e6e6e6;">cd tar xzvf ImageMagick-6.2.9</span></div>
<div><span style="background-color: #e6e6e6;">./configure &#8211;prefix=/usr/local/ImageMagick</span></div>
<div>观察配置后给出来的支持图形格式，看看该图形格式支持是否是yes，如果不是，那么必须先安装该图形格式的本地库。例如，你应该检查是否已经安装如下rpm包：</div>
<div><span style="background-color: #e6e6e6;">rpm –qa |grep libpng</span></div>
<div><span style="background-color: #e6e6e6;">rpm –qa |grep libpng-devel</span></div>
<div><span style="background-color: #e6e6e6;">rpm –qa |grep libjpeg</span></div>
<div><span style="background-color: #e6e6e6;">rpm –qa |grep gd-devel</span></div>
<div>如果你希望支持tiff格式，还应该检查</div>
<div><span style="background-color: #e6e6e6;">rpm –qa |grep libtiff</span></div>
<div>如果没有安装，那么在Linux安装光盘找到相应rpm包安装上，再次configure直到确认需要的图形格式全部支持为止，然后编译安装：</div>
<div><span style="background-color: #e6e6e6;">make &amp;&amp; make install</span></div>
<div>由于ImageMagic被安装在我们自行指定的/usr/local/ImageMagick，后面安装RMagic会找不到需要用到的ImageMagic的命令和库，因此需要配置一下操作系统：</div>
<div>编辑/etc/profile里面的PATH环境变量，在最后面加入：</div>
<div><span style="background-color: #e6e6e6;">export PATH=/usr/local/ruby/bin:/usr/local/ImageMagick/bin:$PATH</span></div>
<div>编辑/etc/ld.so.conf，加入：</div>
<div><span style="background-color: #e6e6e6;">/usr/local/ImageMagick/lib</span></div>
<div>执行命令：</div>
<div><span style="background-color: #e6e6e6;">ldconfig</span></div>
<div>将ImageMagick的库加入系统联接库</div>
<div>然后注销当前用户重新登录，便于环境变量修改生效，执行：</div>
<div><span style="background-color: #e6e6e6;">convert logo: logo.gif</span></div>
<div>看是否正确生成一个logo.gif的图片文件。</div>
<div><strong><span style="font-size: 12pt;">安装</span> </strong> <strong><span style="font-size: 12pt;">RMagic</span> </strong></div>
<div><a href="http://rubyforge.org/projects/rmagick/">http://rubyforge.org/projects/rmagick/</a></div>
<div>在rubyfoge上面下载RMagic的源代码发行包，不要下载gem包，然后解压缩编译：</div>
<div><span style="background-color: #e6e6e6;">./configure </span></div>
<div><span style="background-color: #e6e6e6;">make &amp;&amp; make install</span></div>
<div>如果配置和编译过程没有报错，即大功告成。</div>
<div>对于MacOSX来说，安装RMagic以上步骤会出错，请参考：</div>
<div><a href="http://rmagick.rubyforge.org/install-osx.html">http://rmagick.rubyforge.org/install-osx.html</a></div>
<div>总体来说，ImageMagick和RMagic的安装很容易出错，安装起来比较困难，如果碰到无法解决的问题，可以通过Google寻求解决办法。</div>
<div><span style="font-size: medium;"><strong>如果你在安装过程当中，遇到了什么问题，请看：<a title="Lighttpd和RoR安装配置的疑难解答" href="http://www.javaeye.com/blog/168989" target="_blank">Lighttpd和RoR安装配置的疑难解答</a></strong></span></div>
<div>来自：http://www.javaeye.com/topic/43228<!--more--></div>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ptubuntu.com%2F2008%2F11%2F494.html&amp;title=%E5%9C%A8Linux%E5%B9%B3%E5%8F%B0%E4%B8%8A%E5%AE%89%E8%A3%85%E5%92%8C%E9%85%8D%E7%BD%AERuby%20on%20Rails%E8%AF%A6%E8%A7%A3" id="wpa2a_20"><img src="http://www.ptubuntu.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ptubuntu.com/2008/11/494.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

