<?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>琪埃信息系统（上海）有限公司 &#187; Nginx</title>
	<atom:link href="http://www.qiais.com/achives/category/web-server/nginx/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.qiais.com</link>
	<description>琪埃信息系统</description>
	<lastBuildDate>Tue, 11 Feb 2020 01:50:29 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.0</generator>
	<item>
		<title>CentOS6+Nginx安装自己发行的SSL</title>
		<link>http://www.qiais.com/achives/755/</link>
		<comments>http://www.qiais.com/achives/755/#comments</comments>
		<pubDate>Sun, 07 Sep 2014 02:54:18 +0000</pubDate>
		<dc:creator><![CDATA[sai]]></dc:creator>
				<category><![CDATA[Nginx]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://www.qiais.com/?p=755</guid>
		<description><![CDATA[在使用phpmyadmin管理数据库时，需要使用SSL链接以保护我们的数据，phpmyadmin基本就几个管理...]]></description>
				<content:encoded><![CDATA[<p>在使用phpmyadmin管理数据库时，需要使用SSL链接以保护我们的数据，phpmyadmin基本就几个管理员使用，没有必要购买认证机构的SSL，自己生成就可以了。</p>
<p>生成证书与密钥</p>
<pre class="brush: plain; title: ; notranslate">
cd /etc/pki/tls/certs/
$ sudo make phpmyadmin.crt
[sudo] password for user01: 
umask 77 ; \
	/usr/bin/openssl genrsa -aes128 2048 &gt; phpmyadmin.key
Generating RSA private key, 2048 bit long modulus
........................................................................................+++
.....+++
e is 65537 (0x10001)
Enter pass phrase:
Verifying - Enter pass phrase:
umask 77 ; \
	/usr/bin/openssl req -utf8 -new -key phpmyadmin.key -x509 -days 365 -out phpmyadmin.crt -set_serial 0
Enter pass phrase for phpmyadmin.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:ShangHai
Locality Name (eg, city) [Default City]:ShangHai
Organization Name (eg, company) [Default Company Ltd]:Qiai IS Corp.
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []:
Email Address []:sai@qiais.com
$ ls
</pre>
<p>此命令会在/etc/pki/tls/certs下生成phpmyadmin.crt与phpmyadmin.key文件。<br />
此步骤中<br />
Enter pass phrase:<br />
要求设置证书密码，请记住此密码，因为下面要用到。</p>
<p>将 phpmyadmin.key 移动到 /etc/pki/tls/private/</p>
<pre class="brush: plain; title: ; notranslate">
$ sudo mv phpmyadmin.key /etc/pki/tls/private/
[/code/

配置到nginx

1
server {
    listen       443 ssl;
    server_name  localhost;

    client_max_body_size 8M;

    ssl_certificate      /etc/pki/tls/certs/phpmyadmin.crt;
    ssl_certificate_key  /etc/pki/tls/private/phpmyadmin.key;

    ssl_session_cache shared:SSL:1m;
    ssl_session_timeout  5m;

    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers   on;

    location / {
        root   /home/sai/public_html/phpmyadmin;
        index  index.php;
    }

    location ~ \.php$ {
        root           /home/user01/public_html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}
</pre>
<p>server_name  localhost;此处localhost换成自己的域名，例如，phpmyadmin.example.com<br />
root           /home/user01/public_html;为phpmyadmin的目录<br />
listen       443 ssl;监听ssl端口 443，同时不要忘了在iptables中打开443端口</p>
<p>从新启动nginx, 这里会要求输入证书生成时的密码。</p>
<pre class="brush: plain; title: ; notranslate">
$ sudo /etc/rc.d/init.d/nginx restart
Enter PEM pass phrase:
Stopping nginx:                                            [  OK  ]
Starting nginx: Enter PEM pass phrase:
                                                           [  OK  ]
$ cd /etc/pk
</pre>
<p>每次启动nginx都需要输入ssl证书密码的话比较烦人，我们将key的pass phrase删除掉，这样重启时就不需要输入le。</p>
<pre class="brush: plain; title: ; notranslate">
$ cd /etc/pki/tls/private/
$ ls
phpmyadmin.key
$ sudo cp phpmyadmin.key phpmyadmin.key.bak
$ sudo openssl rsa -in phpmyadmin.key -out phpmyadmin.key
Enter pass phrase for phpmyadmin.key:
writing RSA key
$
</pre>
<p>通过https访问我们的站点，可以看到如下界面，不用在意https处的横杠与错号，因为这是我们自己发行的SSL证书。</p>
<p><a href="http://www.qiais.com/wp-content/uploads/2014/09/スクリーンショット-2014-09-07-11.53.27.png"><img src="http://www.qiais.com/wp-content/uploads/2014/09/スクリーンショット-2014-09-07-11.53.27-600x559.png" alt="スクリーンショット 2014-09-07 11.53.27" width="600" height="559" class="alignnone size-medium wp-image-756" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.qiais.com/achives/755/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nginx 413 Request Entity Too Large 解决方法（备忘）</title>
		<link>http://www.qiais.com/achives/753/</link>
		<comments>http://www.qiais.com/achives/753/#comments</comments>
		<pubDate>Sat, 06 Sep 2014 04:48:27 +0000</pubDate>
		<dc:creator><![CDATA[sai]]></dc:creator>
				<category><![CDATA[Nginx]]></category>

		<guid isPermaLink="false">http://www.qiais.com/?p=753</guid>
		<description><![CDATA[在server节配置client_max_body_size即可]]></description>
				<content:encoded><![CDATA[<p>在server节配置client_max_body_size即可</p>
<pre class="brush: plain; title: ; notranslate">
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
 
    server {
        client_max_body_size 20M;
        listen       80;
        server_name  localhost;
 
        # Main location
        location / {
            proxy_pass         http://127.0.0.1:8000/;
        }
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.qiais.com/achives/753/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux+Nginx+SSL架设安全网站</title>
		<link>http://www.qiais.com/achives/719/</link>
		<comments>http://www.qiais.com/achives/719/#comments</comments>
		<pubDate>Wed, 23 Apr 2014 08:10:48 +0000</pubDate>
		<dc:creator><![CDATA[sai]]></dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://www.qiais.com/?p=719</guid>
		<description><![CDATA[前言： 就像大家所知道的那样，我们的站点有时候需要需要用户登录，注册，或者填写咨询表单， 为了保护用户的隐私，...]]></description>
				<content:encoded><![CDATA[<p>前言：</p>
<p>就像大家所知道的那样，我们的站点有时候需要需要用户登录，注册，或者填写咨询表单，</p>
<p>为了保护用户的隐私，我们需要将用户递交的信息进行加密，这样即使信息被截，</p>
<p>由于数据被加密，产生信息泄漏的可能性大大降低。</p>
<p>今天将讨论如何在CentOS上安装配置SSL网站服务器。</p>
<h3>制作生成CSR（Certificate Signing Request）</h3>
<p>进入/etc/nginx/conf.d</p>
<pre class="brush: plain; title: ; notranslate"># cd /etc/nginx/conf.d </pre>
<p>为了方便管理，将相关的密码，密钥文件放到同一文件夹下</p>
<pre class="brush: plain; title: ; notranslate">
# mkdir example.com 
# cd example.com
</pre>
<p>生成密钥文件</p>
<pre class="brush: plain; title: ; notranslate"># openssl genrsa -des3 -out ./example.key 2048</pre>
<p>这里采用2048bit位加密，根据服务商的要求不同，也有1024bit位的，视情况而定。</p>
<p>CSR文件生成</p>
<pre class="brush: plain; title: ; notranslate"># openssl req -new -key ./example.key -out ./example.csr</pre>
<p>指定CSR信息</p>
<pre class="brush: plain; title: ; notranslate">
Country Name (2 letter code) [AU]:CN
State or Province Name (full name) [Some-State]:Shanghai
Locality Name (eg, city) []:Pudongxinqu
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Qiai Co.,Ltd.
Organizational Unit Name (eg, section) []:Development
Common Name (eg, YOUR name) []:www.qiais.com
Email Address []:
A challenge password []:
An optional company name []:
</pre>
<p>查看确认CSR信息</p>
<pre class="brush: plain; title: ; notranslate">
# cat ./ssl.csr/domainname.csr
-----BEGIN CERTIFICATE REQUEST-----
BAgTBXRva3lvMRAwDgYDVQQHEwdrYXdhZ29lMRcwFQYDVQQKEw5NeSBDb21wYW55
IEx0ZDEZMBcGA1UEAxMQcGVuZ3Vpbi1oZWFkLmNvbTxxxx0wNjA0MjIxMTM3Mjda
Fw0xNjA0MTkxMTM3MjdaMGMxCzAJBgNVBAYTAmpwMQ4wDAYDVQQIEwV0b2t5bzEQ
MA4GA1UEBxMHa2xxxxxxZTEXMBUGA1UEChMOTXkgQ29tcGFueSBMdGQxGTAXBgNV
BAMTEHBlbmd1aW4taGVhZC5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGB
AMXDYSfWjWUTYxfmleIZE4uH/LK73mZcXg3EXxxxxxxxqrlgdx6P9Phq4q1koXl8
0Vxxxxxo3ZvvV08bhVhRwTRs6JRn4RktIPBWxpbGYD6ezfM+gIZ7tG+SQ4DNDXrG
G5K5LkbL3hQc5EWyUAtKiRMnI1slZkviMPJhMi+WE6G/AgMBAAEwDQYJKoZIhvcN
-----END CERTIFICATE REQUEST-----
</pre>
<p>一般来说，我们只需要将上述内容提供给SSL服务商，他们就会根据此密钥文件</p>
<p>生成密码文件。</p>
<h3>2.申请SSL服务器认证</h3>
<p>接下来，我们从SSL服务上哪里获得SSL认证用的证明文件，内容类似如下</p>
<pre class="brush: plain; title: ; notranslate">
-----BEGIN CERTIFICATE-----
MIICNTCCAZ4CAQAwDQYJKoZIhvcNAQEEBQAwYzELMAkGA1UEBhMCanAxDjAMBgNV
BAgTBXRvaxxxMRAwDgYDVQQHEwdrYXdhZ29lMRcwFQYDVQQKEw5NeSBDb21wYW55
IEx0ZDEZMBcGA1UEAxxxxxxxZ3Vpbi1oZWFkLmNvbTAeFw0wNjA0MjIxMTM3Mjda
Fw0xNjA0MTkxMTM3MjdaMGMxCzAJBgNVBAYTAmpwMQ4wDAYDVQQIEwV0b2t5bzEQ
MA4GA1UEBxMHa2F3YWdvZTEXMBUGA1UEChMOTXkgQ29tcGFueSBMdGQxGTAXBgNV
BAMTEHBlbxx1aW4taGVhZC5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGB
AMXDYSfWjWUTYxfmleIZE4uH/LK73mZcXg3EXDtob79bqrlgdx6P9Phq4q1koXl8
0VK0gF0o3ZvvV08bhVhRwxxxxxxx4RktIPBWxpbGYD6ezfM+gIZ7tG+SQ4DNDXrG
G5K5LkbL3hQc5EWyUAtKiRMnI1slZkviMPJhMi+WE6G/AgMBAAEwDQYJKoZIhvcN
AQEEBQADgYEAoRlykFxCHssjoe/LNMMxxxxxxxxxxdK5M3IGVgDDa9mzs19teagW
7OoRZDxxxxxYAa9fwLjy5PPKRHpr1QGjp7/u0djuQ+ZUiGPrUwxlTOtiWBUwjFQk
HY5eoHdGKopo+ezn7NnrelcvYOaXoQvJtu6Jh+zPTnLEHhJOTi4iLs8=
-----END CERTIFICATE-----
</pre>
<p>我们将其保存在/etc/nginx/conf.d/example.com/example.crt文件中。</p>
<p>如果从服务商哪里还有中间证明文件的话，我们将其保存在/etc/nginx/conf.d/example.com/ca.crt文件中<br />
中间证明文件类似于以上文件：</p>
<h3>3.Nginx 上配置SSL</h3>
<p>如果有中间认证文件的话，我们需要将中间认证文件内容拷贝到证明文件</p>
<pre class="brush: plain; title: ; notranslate"># cat example.crt ca.crt &gt; cert.crt</pre>
<p>设置/etc/nginx/conf.d/ssl.conf</p>
<pre class="brush: plain; title: ; notranslate"># vi /etc/nginx/conf.d/ssl.conf</pre>
<pre class="brush: plain; title: ; notranslate">
#
# HTTPS server configuration
#

server {
    listen       443;
    server_name  shimbun4946nakano.com;

    ssl                  on;
#    ssl_certificate      cert.pem;
     ssl_certificate      /etc/nginx/conf.d/example.com/cert.crt;
#    ssl_certificate_key  cert.key;
     ssl_certificate_key  /etc/nginx/conf.d/example.com/example.key;

    ssl_session_timeout  5m;

    ssl_protocols  SSLv2 SSLv3 TLSv1;
    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    ssl_prefer_server_ciphers   on;

    location / {
        root   /var/www/html;
        index  index.php index.html index.htm;
    }

    error_page  404              /404.html;
    location = /404.html {
        root   /var/www/html;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /var/www/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /var/www/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}
</pre>
<h3>4. 解除服务器重启密码</h3>
<p>以上设置SSL的key时设置了密码，nginx重新启动时需要输入密码，这有时候不方便，特别是在我们重新启动服务器（硬件），这个时候我们没法输入key的密码，而导致我们的nginx不能启动。</p>
<pre class="brush: plain; title: ; notranslate">
# cp example.key example.key.bak 
# openssl rsa -in example.key -out example.key
</pre>
<h3>5. 访问https://example.com</h3>
<p>没有错误的话，在URL栏会看到像锁一样的图标，那就表示SSL服务器安装成功。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.qiais.com/achives/719/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CentOS6.5上nginx通过location实现类似UserDir以及虚拟主机功能</title>
		<link>http://www.qiais.com/achives/713/</link>
		<comments>http://www.qiais.com/achives/713/#comments</comments>
		<pubDate>Tue, 15 Apr 2014 08:17:32 +0000</pubDate>
		<dc:creator><![CDATA[sai]]></dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Nginx]]></category>

		<guid isPermaLink="false">http://www.qiais.com/?p=713</guid>
		<description><![CDATA[搭建网站时，除了网站本身，我们还需要必要的配套服务，比如通过phpmyadmin来管理我们的网站数据库。 如果...]]></description>
				<content:encoded><![CDATA[<p>搭建网站时，除了网站本身，我们还需要必要的配套服务，比如通过phpmyadmin来管理我们的网站数据库。</p>
<p>如果是Apache服务器，我们通过虚拟主机或者UserDir，可以很简单的实现上述要求，</p>
<p>在Nginx，没有虚拟主机与UserDir的概念，但这些功能可以通过Location匹配来实现。</p>
<p>注意，centos6.5的nginx的配置文件在/etc/nginx/nginx.conf，它包含引进所有/etc/nginx/conf.d/*.conf文件</p>
<h3>1. 实现UserDir功能</h3>
<p>假设我们有域名 qiais.com, 我们的网站主程序正在使用此域名，</p>
<p>另外，我们还想通过 http://qiais.com/phpmyadmin 来管理我们的数据库</p>
<p>我们可以通过以下配置来实现</p>
<pre class="brush: plain; title: ; notranslate"># vi /etc/nginx/conf.d/default.conf </pre>
<pre class="brush: plain; title: ; notranslate">
#
# The default server
#
server {
    listen       80 default_server;
    server_name  qiais.com;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        #root   /usr/share/nginx/html;
        root   /var/www/html/html;
        index  index.php index.html index.htm;
        auth_basic &quot;Restricted Area&quot;;
        auth_basic_user_file /etc/nginx/conf.d/.htpasswd;
    }

    error_page  404              /404.html;
    location = /404.html {
        #root   /usr/share/nginx/html;
        root   /var/www/html/html;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        #root   /usr/share/nginx/html;
        root   /var/www/html/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /var/www/html/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}

    location /phpmyadmin {
        root /home/sai/public_html;
        index index.php index.html index.htm;
        location ~ ^/phpmyadmin/(.+\.php)$ {
            try_files $uri =404;
            root /home/sai/public_html;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include /etc/nginx/fastcgi_params;
        }
        location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
            root /home/sai/public_html;
        }
    }
</pre>
<p>    location / {<br />
        #root   /usr/share/nginx/html;<br />
        root   /var/www/html/html;<br />
        index  index.php index.html index.htm;<br />
        auth_basic &#8220;Restricted Area&#8221;;<br />
        auth_basic_user_file /etc/nginx/conf.d/.htpasswd;<br />
    }</p>
<p>这段代码是配置我们主网站用的：http://qiais.com</p>
<p>    location /phpmyadmin {<br />
        root /home/sai/public_html;<br />
        index index.php index.html index.htm;<br />
        location ~ ^/phpmyadmin/(.+\.php)$ {<br />
            try_files $uri =404;<br />
            root /home/sai/public_html;<br />
            fastcgi_pass 127.0.0.1:9000;<br />
            fastcgi_index index.php;<br />
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;<br />
            include /etc/nginx/fastcgi_params;<br />
        }<br />
        location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {<br />
            root /home/sai/public_html;<br />
        }<br />
    }</p>
<p>这段代码是配置我们phpmyadmin用的：http://qiais.com/phpmyadmin,</p>
<p>当然，你需要将phpmyadmin的文件上传到/home/sai/public_html/phpmyadmin文件夹中。</p>
<h3>2. 实现类似与虚拟主机的功能</h3>
<p>这个很简单，只要从上述default.conf文件拷贝成新的配置文件，修改其中的server_name就可以了。</p>
<pre class="brush: plain; title: ; notranslate">
# cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/phpmyadmin.conf
# vi /etc/nginx/conf.d/phpmyadmin.conf
</pre>
<pre class="brush: plain; title: ; notranslate">
#
# The default server
#
server {
    listen       80;
    server_name  phpmyadmin.qiais.com;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        root   /home/sai/public_html/phpmyadmin;
        index  index.php index.html index.htm;
    }

    error_page  404              /404.html;
    location = /404.html {
        root   /home/sai/public_html/phpmyadmin;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        #root   /usr/share/nginx/html;
        root   /home/sai/public_html/phpmyadmin;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /home/sai/public_html/phpmyadmin;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}
</pre>
<p>这样，访问 http://phpmyadmin.qiais.com 同样可以看到我们数据库管理界面。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.qiais.com/achives/713/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AWS创建可重复使用的EC2实例</title>
		<link>http://www.qiais.com/achives/698/</link>
		<comments>http://www.qiais.com/achives/698/#comments</comments>
		<pubDate>Wed, 09 Apr 2014 07:00:54 +0000</pubDate>
		<dc:creator><![CDATA[sai]]></dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[EC2]]></category>
		<category><![CDATA[Nginx]]></category>

		<guid isPermaLink="false">http://www.qiais.com/?p=698</guid>
		<description><![CDATA[云主机不同于我们的实际主机，实际主机要求我们在购买硬件后安装所有软件，或者购买安装了必要软件的主机。 每台主机...]]></description>
				<content:encoded><![CDATA[<p>云主机不同于我们的实际主机，实际主机要求我们在购买硬件后安装所有软件，或者购买安装了必要软件的主机。</p>
<p>每台主机都可能要重复相同的操作。</p>
<p>在AWS上我们可能通过一个已经搭建好的实例，来创建AMI,以后通过此AMI来创建实例，</p>
<p>从而可以减少我们很多不必要的劳动。</p>
<p>今天我们讨论如何在AWS上创建自己的AMI。</p>
<h3>1. 选择需要创建AMI的实例，先暂停次实例</h3>
<p>虽然创建AMI可以不用停止实例的运行，但是安全起见，还是暂停比较好。</p>
<p>Instance -> 想要创建AMI的实例（i-hanbaiten-model） &#8211;> 右击鼠标，点击stop</p>
<p><a href="http://www.qiais.com/wp-content/uploads/2014/04/2014-04-09-01.png"><img src="http://www.qiais.com/wp-content/uploads/2014/04/2014-04-09-01-600x363.png" alt="2014-04-09-01" width="600" height="363" class="alignnone size-medium wp-image-699" /></a></p>
<h3>2. 选择已经停止的实例，创建AMI</h3>
<p>右击已经停止的实例 &#8211;> 选择 Create Image</p>
<p><a href="http://www.qiais.com/wp-content/uploads/2014/04/2014-04-09-02.png"><img src="http://www.qiais.com/wp-content/uploads/2014/04/2014-04-09-02-600x363.png" alt="2014-04-09-02" width="600" height="363" class="alignnone size-medium wp-image-703" /></a></p>
<p>会弹出以下窗口</p>
<p><a href="http://www.qiais.com/wp-content/uploads/2014/04/2014-04-09-03.png"><img src="http://www.qiais.com/wp-content/uploads/2014/04/2014-04-09-03-600x363.png" alt="2014-04-09-03" width="600" height="363" class="alignnone size-medium wp-image-704" /></a></p>
<p>在Image Name 中输入容易辨别的名称，</p>
<p>点击Create Image按钮就可以了，</p>
<p>创建AMI需要等待一段时间。</p>
<h3>3. 利用创建好的AMI，创建EC2实例</h3>
<p>点击 AMIs标签 &#8211;> 选择刚创建好的AMI（这里为hanbaiten-model）&#8211;> 右击 &#8211;> 选择 Launch</p>
<p><a href="http://www.qiais.com/wp-content/uploads/2014/04/2014-04-09-04.png"><img src="http://www.qiais.com/wp-content/uploads/2014/04/2014-04-09-04-600x363.png" alt="2014-04-09-04" width="600" height="363" class="alignnone size-medium wp-image-706" /></a></p>
<p>接下来的工作请参考<a href="http://www.qiais.com/achives/235/" title="在亚马逊AWS上创建EC2的Linux(CentOS)实例" target="_blank">在亚马逊AWS上创建EC2的Linux(CentOS)实例</a></p>
<h3>4. 创建AMI的好处</h3>
<p>1. 省去很多重复的工作</p>
<p>2. 增加系统盘的EBS容量，直接创建实例的话，系统盘的大小大部分为10G以下，作为服务器的话，很快就就爆满。<br />
   通过自己的AMI创建的话，EBS可以配置的更大。</p>
<p>结束</p>
]]></content:encoded>
			<wfw:commentRss>http://www.qiais.com/achives/698/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CentOS6.5上安装nginx与php5.5</title>
		<link>http://www.qiais.com/achives/691/</link>
		<comments>http://www.qiais.com/achives/691/#comments</comments>
		<pubDate>Tue, 08 Apr 2014 03:50:02 +0000</pubDate>
		<dc:creator><![CDATA[sai]]></dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.qiais.com/?p=691</guid>
		<description><![CDATA[1. 安装必要的包 2. 添加仓库 添加/etc/yum.repos.d/nginx.repo文件，在ngin...]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.qiais.com/wp-content/uploads/2014/04/2014-04-08-12.54.20.png"><img src="http://www.qiais.com/wp-content/uploads/2014/04/2014-04-08-12.54.20-600x511.png" alt="2014-04-08 12.54.20" width="600" height="511" class="alignnone size-medium wp-image-692" /></a></p>
<h3>1. 安装必要的包</h3>
<pre class="brush: plain; title: ; notranslate">
# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
</pre>
<h3>2. 添加仓库</h3>
<p>添加/etc/yum.repos.d/nginx.repo文件，在nginx.repo中添加以下内容</p>
<pre class="brush: plain; title: ; notranslate">
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
</pre>
<h3>3. 安装 Nginx, PHP 5.5.9 and PHP-FPM</h3>
<pre class="brush: plain; title: ; notranslate">
# yum --enablerepo=remi,remi-php55 install nginx php-fpm php-common
</pre>
<h3>4. 安装 PHP 5.5.9 模块</h3>
<pre class="brush: plain; title: ; notranslate">
# yum --enablerepo=remi,remi-php55 install php-pecl-apc php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml
</pre>
<h3>5. 停止httpd</h3>
<pre class="brush: plain; title: ; notranslate">
# /etc/rc.d/init.d/httpd stop
# chkconfig httpd stop
</pre>
<h3>启动nginx，php-fpm</h3>
<p>请参考<a href="http://www.qiais.com/achives/430/" title="亚马逊AWS上安装Nginx(Linux,CentOS环境)" target="_blank">亚马逊AWS上安装Nginx(Linux,CentOS环境)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.qiais.com/achives/691/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nginx通过密码保护我们未公开的网站</title>
		<link>http://www.qiais.com/achives/667/</link>
		<comments>http://www.qiais.com/achives/667/#comments</comments>
		<pubDate>Tue, 01 Apr 2014 04:31:34 +0000</pubDate>
		<dc:creator><![CDATA[sai]]></dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Nginx]]></category>

		<guid isPermaLink="false">http://www.qiais.com/?p=667</guid>
		<description><![CDATA[有些时候，我们的网站服务器虽然架设起来了，但是还需要完善或者等待指定日期公开，那么就需要通过密码保护我们的网站...]]></description>
				<content:encoded><![CDATA[<p>有些时候，我们的网站服务器虽然架设起来了，但是还需要完善或者等待指定日期公开，那么就需要通过密码保护我们的网站了。</p>
<p>这里将介绍如何在Nginx网站服务器上简单保护未公开的网站,</p>
<h3>要的结果是这样的：</h3>
<p><a href="http://www.qiais.com/wp-content/uploads/2014/04/20140401.png"><img src="http://www.qiais.com/wp-content/uploads/2014/04/20140401-600x438.png" alt="20140401" width="600" height="438" class="alignnone size-medium wp-image-668" /></a></p>
<h3>步骤如下：</h3>
<p>1. 编辑/etc/nginx/conf.d/default.coonf</p>
<p>找到 location / {}，在最下面添加两行 auth_basic &#8220;Restricted Area&#8221;; auth_basic_user_file /etc/nginx/conf.d/.htpasswd;</p>
<pre class="brush: plain; title: ; notranslate">
    #access_log  logs/host.access.log  main;

    location / {
        #root   /usr/share/nginx/html;
        root   /var/www/html/html;
        index  index.php index.html index.htm;
        auth_basic &quot;Restricted Area&quot;;
        auth_basic_user_file /etc/nginx/conf.d/.htpasswd;
    }
</pre>
<p>注意，这里我们修改的是conf.d/default.php, 您的网站服务器的配置文件有可能不是此文件，可能会是上一节目录的nginx.conf, 或者其他，<br />
视您的具体情况而定。</p>
<p>2. 接下来通过apache2-utils的htpasswd命令创建用户名与密码</p>
<pre class="brush: plain; title: ; notranslate">
# cd /etc/nginx/conf.d/
# touch .htpasswd
# htpasswd -b .htpasswd your-username your-password
</pre>
<p>centos6.4默认安装了apache2-utils，如果出现htpasswd命令错误，请确认是否安装了apache2-utils。</p>
<p>CentOS6.5 默认没有安装apache2-utils，我们可以通过以下方法加密密码</p>
<pre class="brush: plain; title: ; notranslate">
# cd /etc/nginx/conf.d/
# touch .htpasswd
# printf &quot;your-username:$(openssl passwd -1 your-password)\n&quot; &gt;&gt; .htpasswd
</pre>
<p>以上为MD5加密，也可以通过别的方式加密。</p>
<p># 用crypt encryption方式加密</p>
<pre class="brush: plain; title: ; notranslate">
# printf &quot;your-username:$(openssl your-password -crypt V3Ry)\n&quot; &gt;&gt; .htpasswd 
</pre>
<p># 用apr1 (Apache MD5) encryption方式加密</p>
<pre class="brush: plain; title: ; notranslate">
# printf &quot;your-username:$(openssl your-password -apr1 V3Ry)\n&quot; &gt;&gt; .htpasswd 
</pre>
<p>3. 最后重新启动nginx,以使配置生效。</p>
<pre class="brush: plain; title: ; notranslate">/etc/rc.d/init.d/nginx restart</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.qiais.com/achives/667/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>亚马逊AWS上安装Nginx(Linux,CentOS环境)</title>
		<link>http://www.qiais.com/achives/430/</link>
		<comments>http://www.qiais.com/achives/430/#comments</comments>
		<pubDate>Sat, 08 Feb 2014 06:18:44 +0000</pubDate>
		<dc:creator><![CDATA[sai]]></dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[EC2]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.qiais.com/?p=430</guid>
		<description><![CDATA[以前一直使用Apache服务器，但是在内存贵如油的AWS上，使用省内存的Nginx服务器应该是个不错的选择，它...]]></description>
				<content:encoded><![CDATA[<p>以前一直使用Apache服务器，但是在内存贵如油的AWS上，使用省内存的Nginx服务器应该是个不错的选择，它能降低我们很多成本。</p>
<p>关于AWS的linux实例安装请参考<a href="http://www.qiais.com/achives/235/" title="在亚马逊AWS上创建EC2的Linux(CentOS)实例" target="_blank">在亚马逊AWS上创建EC2的Linux(CentOS)实例</a></p>
<p>我们分以下五步，完成aws上nginx的架设。</p>
<p>1. 安装mysql<br />
2. 安装nginx<br />
3. 安装php<br />
4. 配置php<br />
5. 配置nginx<br />
6. 测试安装结果</p>
<p>安装必要的库</p>
<pre class="brush: plain; title: ; notranslate">
# cd
# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
# rm -rf epel-release-6-8.noarch.rpm
</pre>
<h3>1. 安装mysql</h3>
<p>切换到root用户</p>
<pre class="brush: plain; title: ; notranslate">su</pre>
<p>安装mysql</p>
<pre class="brush: plain; title: ; notranslate"># yum install mysql mysql-server</pre>
<p>初始化mysql，具体参看<a href="http://www.qiais.com/achives/92/" title="在Linux(CentOS6)上搭建Apache2+Mysql5+PHP5开发环境" target="_blank">在Linux(CentOS6)上搭建Apache2+Mysql5+PHP5开发环境</a>的mysql安装部分。</p>
<h3>1. 安装nginx</h3>
<pre class="brush: plain; title: ; notranslate"># yum install nginx</pre>
<p>启动nginx，并且配置nginx开机启动</p>
<pre class="brush: plain; title: ; notranslate">
# /etc/init.d/nginx start
# chkconfig nginx on
</pre>
<h3>3. 安装php </h3>
<p>安装php及相关php的包</p>
<pre class="brush: plain; title: ; notranslate">
# yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml php-pear php-fpm
</pre>
<h3>4. 配置php</h3>
<pre class="brush: plain; title: ; notranslate"># vi /etc/php.ini</pre>
<p>找到#cgi.fix_pathinfo=1，在下面添加</p>
<pre class="brush: plain; title: ; notranslate">cgi.fix_pathinfo=0</pre>
<h3>5. 配置nginx </h3>
<pre class="brush: plain; title: ; notranslate">vi /etc/nginx/conf.d/default.conf</pre>
<p>更改如下</p>
<pre class="brush: plain; title: ; notranslate">
server {
    listen       80 default_server;
    server_name  _;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        #root   /usr/share/nginx/html;
        root   /var/www/html;
        index  index.php index.html index.htm;
    }

    error_page  404              /404.html;
    location = /404.html {
        #root   /usr/share/nginx/html;
        root   /var/www/html;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        #root   /usr/share/nginx/html;
        root   /var/www/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /var/www/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}
</pre>
<h3>6. 启动nginx</h3>
<pre class="brush: plain; title: ; notranslate">
# /etc/rc.d/init.d/nginx restart
# chkconfig nginx on
</pre>
<h3>7. 启动php-fpm</h3>
<pre class="brush: plain; title: ; notranslate">
# /etc/rc.d/init.d/php-fpm restart
# chkconfig php-fpm on
</pre>
<h3> 8. 测试安装 </h3>
<p>在/var/www/html中添加info.php,访问 http://********/info.php</p>
<p><a href="http://www.qiais.com/wp-content/uploads/2014/02/2014-03-27-16.22.01.png"><img src="http://www.qiais.com/wp-content/uploads/2014/02/2014-03-27-16.22.01-600x534.png" alt="2014-03-27 16.22.01" width="600" height="534" class="alignnone size-medium wp-image-660" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.qiais.com/achives/430/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
