<?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>molezz BAR 世界尽头 &#187; nginx</title>
	<atom:link href="http://www.molezz.net/drink/tag/nginx/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.molezz.net</link>
	<description>a man can be destroyed but not defeated -- 生物技术和计算机技术</description>
	<lastBuildDate>Sun, 18 Sep 2011 05:48:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>我的第一个脚本-centos5.4-nginx-php-mysql-自动安装</title>
		<link>http://www.molezz.net/drink/shell-centos5-4-nginx-php-mysql/</link>
		<comments>http://www.molezz.net/drink/shell-centos5-4-nginx-php-mysql/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 08:09:19 +0000</pubDate>
		<dc:creator>molezz</dc:creator>
				<category><![CDATA[电脑网络|network]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[vps]]></category>

		<guid isPermaLink="false">http://www.molezz.net/?p=526</guid>
		<description><![CDATA[由于最近买了一个burst的vps, 于是开始看些linux下的东西, 挺有意思, 开始在网上进行一些centos的设置, 并且记录在我的wiki上, 最近开始接触到脚本, 发现很强大, 省得学习时重装系统后繁琐的重复设置, 于是自己尝试写了一点, 主要为了偷懒, 而且写得十分粗燥, 不过总算在centos5.4和fedora12中测试通过. 如果安装成功, 能在最后看到各种服务的启动[OK]或是successfully, 由于不是编译安装, 所以基本不是最新版, 但应该是稳定版, 而且由于是默认安装, 以后升级也方便, 出了问题也容易google排查, 因为都是默认安装路径, 不会出现找不到文件的情况. 当然也可以选择LNMP之类的一键包, 只要有人维护, 这类包升级也方便. OK, 安装很简单, 尽量在新装的系统中应用, 如果原先装过mysql, 则可能造成root密码为原先的密码. 1. 首先下载脚本centos.sh 2. 更改权限 chmod +x centos.sh 3. 运行./centos.sh 4. 输入mysql root的密码 5. 等待完成, 最后一排绿色[OK]和一个spawn-fcgi的successfully的字样就完成了 在fedora12和centos5.4中成功, 如果是debian或是ubuntu的话, 可能改成apt-get就行了, 暂时没有测试 1 2 3 4 5 6 [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://sleqma.bay.livefilestore.com/y1p6OhN8SxTDkIDtJMpJ4zkZ5XBAWakzGgRvgRpb0vumXYxkpY1AjAwDbikKA3aHWe3V_lh-Bo3wpkDM_1wbwMDJJLE3bxTYZOT/centos0.2.JPG" target="_blank"><img class="alignright" title="CentOS-5.4-Nginx+php+mysql" src="http://sleqma.bay.livefilestore.com/y1p6OhN8SxTDkIDtJMpJ4zkZ5XBAWakzGgRvgRpb0vumXYxkpY1AjAwDbikKA3aHWe3V_lh-Bo3wpkDM_1wbwMDJJLE3bxTYZOT/centos0.2.JPG" alt="" width="168" height="158" /></a> 由于最近买了一个<a href="https://www.burst.net/" target="_blank">burst</a>的vps, 于是开始看些linux下的东西, 挺有意思, 开始在网上进行一些centos的设置, 并且记录在<a href="http://www.molezz.net/wiki/doku.php?id=linux:centos" target="_blank">我的wiki</a>上, 最近开始接触到脚本, 发现很强大, 省得学习时重装系统后繁琐的重复设置, 于是自己尝试写了一点, 主要为了偷懒, 而且写得十分粗燥, 不过总算在centos5.4和fedora12中测试通过.<br />
如果安装成功, 能在最后看到各种服务的启动[OK]或是successfully, 由于不是编译安装, 所以基本不是最新版, 但应该是稳定版, 而且由于是默认安装, 以后升级也方便, 出了问题也容易google排查, 因为都是默认安装路径, 不会出现找不到文件的情况. 当然也可以选择LNMP之类的一键包, 只要有人维护, 这类包升级也方便.<br />
OK, 安装很简单, 尽量在新装的系统中应用, 如果原先装过mysql, 则可能造成root密码为原先的密码.<br />
1. 首先下载脚本<a href="http://www.molezz.net/wiki/doku.php?do=export_code&#038;id=linux:shell&#038;codeblock=0" target="_blank">centos.sh</a><br />
<span id="more-526"></span><br />
2. 更改权限  chmod +x centos.sh<br />
3. 运行./centos.sh<br />
4. 输入mysql root的密码<br />
5. 等待完成, 最后一排绿色[OK]和一个spawn-fcgi的successfully的字样就完成了<br />
在fedora12和centos5.4中成功, 如果是debian或是ubuntu的话, 可能改成apt-get就行了, 暂时没有测试</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;">#   molezz centos shell: http://www.molezz.net/</span>
<span style="color: #666666; font-style: italic;">#   version: 0.2</span>
<span style="color: #666666; font-style: italic;">#   2010-04-23</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#   Reference:</span>
<span style="color: #666666; font-style: italic;">#   http://www.centospub.com/</span>
<span style="color: #666666; font-style: italic;">#   http://www.atans.cn/post/93/</span>
<span style="color: #666666; font-style: italic;">#   http://www.zquan.me/article.asp?id=31</span>
<span style="color: #666666; font-style: italic;">#</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># check root</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">id</span> -u<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ERROR: You are not root, please use root&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;---------------------set mysql root password--------------------&quot;</span>
<span style="color: #007800;">mysqlrootpasswd</span>=<span style="color: #ff0000;">&quot;root&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;please input the mysql root password: &quot;</span>
<span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #660033;">-p</span> <span style="color: #ff0000;">&quot;(defalt password: root):&quot;</span> mysqlrootpasswd
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$mysqlrootpasswd</span>&quot;</span> = <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		mysqlrootpasswd = <span style="color: #ff0000;">&quot;root&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;---------------------installation start-------------------------&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># update and clear</span>
yum <span style="color: #660033;">-y</span> update
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-sf</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>zoneinfo<span style="color: #000000; font-weight: bold;">/</span>Asia<span style="color: #000000; font-weight: bold;">/</span>Shanghai <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>localtime
rpm <span style="color: #660033;">-qa</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">grep</span> httpd
rpm <span style="color: #660033;">-e</span> httpd
rpm <span style="color: #660033;">-qa</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">grep</span> nginx
rpm <span style="color: #660033;">-e</span> nginx
rpm <span style="color: #660033;">-qa</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">grep</span> spawn-fcgi
rpm <span style="color: #660033;">-e</span> spawn-fcgi
rpm <span style="color: #660033;">-qa</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">grep</span> php
rpm <span style="color: #660033;">-e</span> php-mysql
rpm <span style="color: #660033;">-qa</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">grep</span> mysql
rpm <span style="color: #660033;">-e</span> mysql-server
rpm <span style="color: #660033;">-e</span> perl-DBD-MySQL
rpm <span style="color: #660033;">-e</span> mysql
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;--------------------------install nginx-------------------------&quot;</span>
rpm <span style="color: #660033;">-Uvh</span> http:<span style="color: #000000; font-weight: bold;">//</span>download.fedora.redhat.com<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>epel<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">/</span>i386<span style="color: #000000; font-weight: bold;">/</span>epel-release-<span style="color: #000000;">5</span>-<span style="color: #000000;">3</span>.noarch.rpm
yum <span style="color: #660033;">-y</span> <span style="color: #c20cb9; font-weight: bold;">install</span> nginx
chkconfig <span style="color: #660033;">--level</span> <span style="color: #000000;">235</span> nginx on
service nginx start
&nbsp;
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;--------------------------install mysql-------------------------&quot;</span>
yum <span style="color: #660033;">-y</span> <span style="color: #c20cb9; font-weight: bold;">install</span> mysql-server
chkconfig <span style="color: #660033;">--level</span> <span style="color: #000000;">235</span> mysqld on
&nbsp;
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;-----------------install php and spawn-fcgi-----------------------&quot;</span>
yum <span style="color: #660033;">-y</span> <span style="color: #c20cb9; font-weight: bold;">install</span> php-cgi php-mysql
yum <span style="color: #660033;">-y</span> <span style="color: #c20cb9; font-weight: bold;">install</span> spawn-fcgi
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;spawn-fcgi -C 5 -a 127.0.0.1 -p 9000 -u nginx -g nginx -f /usr/bin/php-cgi&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.local
&nbsp;
<span style="color: #666666; font-style: italic;"># modify the nginx.conf, I hope I can write beautiful later................</span>
<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'104,111s/#//g'</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.conf <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.conf.out
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.conf.out  <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.conf
<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/index.html index.htm/index.html index.htm index.php/g'</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.conf <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.conf.out
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.conf.out  <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.conf
<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s:/scripts:/usr/share/nginx/html:g'</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.conf <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.conf.out
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.conf.out  <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.conf
&nbsp;
&nbsp;
service mysqld start
<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>mysqladmin <span style="color: #660033;">-u</span> root password <span style="color: #007800;">$mysqlrootpasswd</span>
<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'/22 -j/{h;p;g;s/22 -j/80 -j/g}'</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>sysconfig<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>sysconfig<span style="color: #000000; font-weight: bold;">/</span>iptables.out
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>sysconfig<span style="color: #000000; font-weight: bold;">/</span>iptables.out <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>sysconfig<span style="color: #000000; font-weight: bold;">/</span>iptables
service iptables restart
spawn-fcgi <span style="color: #660033;">-C</span> <span style="color: #000000;">5</span> <span style="color: #660033;">-a</span> 127.0.0.1 <span style="color: #660033;">-p</span> <span style="color: #000000;">9000</span> <span style="color: #660033;">-u</span> nginx <span style="color: #660033;">-g</span> nginx <span style="color: #660033;">-f</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-cgi
service nginx restart
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&lt;?php phpinfo(); ?&gt;&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>html<span style="color: #000000; font-weight: bold;">/</span>test.php
&nbsp;
&nbsp;
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;********************************************************************&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;********************************************************************&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;**                             completed!                         **&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;********************************************************************&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;**                                                                **&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;**           php info:           http://127.0.0.1/test.php        **&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;**           nginx config file:  /etc/nginx/nginx.conf            **&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;**           web dir:            /usr/share/nginx/html            **&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;**           mysql dir:          /usr/bin                         **&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;**           mysql database dir: /var/lib/mysql                   **&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;**           php location:       /usr/bin                         **&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;**                                                                **&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;********************************************************************&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;**                                                                **&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;**        for mysql security, you should run secure setting       **&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;**        /usr/bin/mysql_secure_installation                      **&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;**                                                                **&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;********************************************************************&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;mysql root password :  <span style="color: #007800;">$mysqlrootpasswd</span>              &quot;</span></pre></td></tr></table></div>

<img src="http://www.molezz.net/?ak_action=api_record_view&id=526&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.molezz.net/drink/shell-centos5-4-nginx-php-mysql/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

