11111111111111111
nginx 열 배치: 부 드 러 운 업그레이드
설치 nginx:
yum groupinstall "Development Tools" "Server Platform Development"
yum install pcre-devel openssl-devel
groupadd -r -g 108 nginxuser -r -g 108 -u 108 nginx
tar -zxvf nginx-1.41.tar.gzcd nginx-1.41./configure --prefix=/usr --sbin-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/log/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gizp_static_module --http-client-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre=/usr --with-file-aio
make && make install
원본 rpm 패키지 로 설치:
rpm -ivh nginx-1.4.1-1.el5.ngx.src.rpmcd /usr/src/redhat/SPECS/vim nginx.spec
rpmbuild -ba nginx.spec
nginx: server {}: 가상 호스트 위치 {}:
location /URI/ {
root "/web/htdocs";
}
httpd:
URI 경로:http://www.magedu.com/
nagle 알고리즘: 주로 네트워크 체증 해결
모든 server {}: 가상 호스트 location {} 을 정의 합 니 다.
location /uri/ {root “/web/htdocs”;}
httpd: 로 컬 파일 시스템 기반 경로:
uri :
uri :http://www.baidu.com/( uri )
location [ =| ~| ~*| ^~ ] uri{...}
location uri{}:
location = uri {}: , , ,
location ~ uri {}:
location ~ uri {}:
uri, uri ,~ ,~ :
location ^~ uri {}:
location / {
root /web/htdocs;
}
location /bbs/ {
root /web;
}
:
IP
location / {
root /web/htdocs;
deny 192.168.1.25;
}
location / {
root /web/htdocs;
allow 192.168.1.25;
deny all;
}
location / {
root /web/htdocs;
auth_basic "Restricted Area...";
auth_basic_user_file /etc/nginx/.users;
autoindex on;
}
httppasswd -cm /etc/nginx/.users tom
location /status {
stub_status on;
}
http://192.168.1.28/status
status : , ,
reading:nginx ;
writing:nginx , ;
waiting:
:
1.
vim /etc/pki/openssl.cnf
[CA_default]
dir = /etc/pki/CA
cd /etc/pki/CA
mkdir certs crl newcerts private
(umask 077;openssl genrsa 2048 > private/cakey.pem)
2. :
openssl req -new -x509 -key private/cakey.pem -out cacert.pem
touch serial
echo 01 > serial
touch index.txt
:
cd /etc/nginx
mkdir ssl
cd ssl
1.
(umask 077;openssl genrsa 1024 > nginx.key)
2.
openssl -req -new -key nginx.key -out nginx.csr
3.
openssl ca -in nginx.csr -out nginx.crt -days 3650
server {
listen 443;
server_name localhost;
ssl on;
ssl_cerificate /etc/nginx/ssl/nginx.crt;
ssl_session_key /etc/nginx/ssl/nginx.key;
ssl_protocols SSLv2 SSLv3 TLSv1;
location / {
root /web/htdocs;
index index.html index.htm;
}
}
:
server {
listen 80;
server_name sina.uplook.com;
location / {
root /sina;
index index.html;
}
LEMP:
php-fpm:
127.0.0.1:9000
nginx+PHP+MySQL
vim /etc/php.ini
vim /etc/php-fpm.conf
vim /etc/init.d.php-fpm
tar -zxvf mysql-5.6.10-linux-glibc2.5-i686.tar.gz -C /usr/local
mkdir /mydata/data
useradd -r mysql
chown -R mysql.msyql /mydata/data
cd /usr/local
ln -sv mysql-5.6.10 mysql
chown -R root.mysql ./*
scripts/mysql_install_db --user=mysql --datadir=/mydata/data/
vim /etc/my.cnf
datadir = /mydata/data
innodb_file_per_table = on
log-bin = master-bin
socket = /tmp/mysql.sock
cp support-files/mysql.server /etc/init.d/mysqld
service mysqld start
vim /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib
ldconf -v
ln -sv /usr/local/mysql/include /usr/include/mysql
tar -jxvf php-5.4.13.tar.bz2
cd php-5.4.13
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --enable-fpm --enable-sockets --enable-sysvshm --with-mysqli=/usr/local/mysql/_config --enable-mbstring --with-freetype-dir --with-png-dir --with-zlib-dir --with-libxml-dir=/usr --enable-xml --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --with-curl
make && make install
cp php.ini-production /etc/php.ini
cd /usr/local/php/etc/
cp php-fpm.conf.default php-fpm.conf
cd /root/php-5.4.13/
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
service php-fpm start
nginx php
vim /etc/nginx/nginx.conf
location ~ .php$ {
root /web/htdocs;
index index.php index.html
fastcgi_pass 127.0.0.1:9000;( )
fastcgi_index index.php;
fastcgi_param script_filename ..;
include fastcgi_params;
}
vim /etc/nginx/fastcgi_params
fastcgi_param ...
fastcgi_param ...
fastcgi_param ...
fastcgi_param ...
fastcgi_param ...
fastcgi_param ...
fastcgi_param ...
vim /web/htdocs/index.php
phpinfo();
?>
IO :
:
:
:
: ,
:
:IO
:event-driven
:AIO
nginx:
mmap
event-driven
;
memcached: , string,object,key:value
hash bucket,O(1)
redis:databases,nosql
lvs
nginx
haproxy
LEMP:
enginx
web:nginx,lnmp,memcached,haproxy,tomcat,varnish
location ~* .php$ {
fastcgi_pass 127.0.0.1:9000;
}
fastcgi
nginx
main,
worker_process
error_log
user
group
events {
}
httpd {
}
http
server {
}
location uri {
directive ;
}
uri
server {
listen 80;
server_name www.maoshou.com
location / {
;
}
}
:
proxy_pass
location [op] URI {
http://172.16.100.11/;
}
~
~*
^~
location @name
location /forum/ {
proxy_pass http://172.16.100.11:8080/bbs/;
}
http://www.magedu.com/forum/
--->http://172.16.100.11:8080/bbs/
location ~* ^/forum {
proxy_pass http://172.16.100.11:8080;
}
http://www.magedu.com/forum/ --->
http://172.16.100.11:8080/forum
vim /etc/nginx.conf
location /forum/ {
proxy_pass http://172.16.100.6/bbs/;
}
172.16.100.6 mkdir /var/www/html/bbs
vim /etc/nginx.conf
location ~* /forum {
proxy_pass http://172.16.100.6;
proxy_set_header X-Real-IP $remote_addr;
}
172.16.100.6 mkdir /var/www/html/forum
vim /etc/http.conf
LogFormat "%{X-Real-IP}i" ...
proxy_set_header X-real-IP $remote_addr
get,post,head,put,trace,options,connection,delete
nginx:
round-robin
ip_hash
least_conn
vim /etc/nginx.conf
upstream websrvs {
ip_hash( backup );
server 172.16.100.6 weight=1 max_fails=2 fail_timeout=2;
server 172.16.100.7 weight=1 max_fails=2 fail_timeout=2;
#server 127.0.0.1:8080 backup;
}
proxy_cache_path /nginx/cache/first levels=1:2:1 keys_zone=first:20m max_size=1g;
location / {
proxy_pass http://websrvs/;
proxy_set_header X-Real-IP $remote_addr;
proxy_cache first;
proxy_cache_valid 200 10m;
}
server {
listen 8080;
server_name 127.0.0.1;
location / {
root /web/error;
index index.html index.htm
}
}
mkdir /web/error
vim html
mkdir /nginx/cache/first
nginx:
cache: :
:
proxy_cache_path: server{}
:
proxy_cache_path /nginx/cache/first levels=1:2:1 keys_zone=first:20m max_size=1g;
,1: 2: 2 1: 1
cache_manager:LRU
:
open_log_cache:
open_file_cache:
fastcgi_cache:
nginx limit
nginx:gzip
upstream phpsrvs {
server ....
server ....
}
upstream imgsrvs {
server ....
server ....
}
ustream staticfilesrvs {
server ....
server ....
}
location / {
root /web/htdocs;
index index.php index.html
}
location ~* .php$ {
fastcgi_pass http://phpsrvs;
}
location ~* .(jpg|jpeg|gif|png)$ {
proxy_pass http://imgsrvs;
}
rewirte:URL
if (condition) {
}
:
:
~,!~
,!
~,!~
if ($request_method="POST") {
}
if ($request_uri ~* "/forum") {
}
:
referer:
location / {
root /web;
rewrite "/images/" http://172.16.100.19/images/
}
:
locstion / {
root html;
index index.html;
rewrite "^/bbs/(.*)$" http://www.magedu.com/forum/$1 last;
}
http://www.magedu.com/bbs/index.html --> http://www.magedu.com/forum/index.html
locstion / {
root html;
index index.html;
rewrite "^/bbs/(.)/images/(.).jpg$" http://www.magedu.com/bbs/$2/images/$1.jpg last;
}
http://www.magedu.com/bbs/a/images/b.jpg --> http://www.magedu.com/bbs/b/images/a.jpg --> http://www.magedu.com/bbs/a/images/b.jpg
last: , ;
break: , ;
locstion / {
root html;
index index.html;
rewrite "^/bbs/(.*)$" /forum/$1;
}
zeromq:
mmap:
Facebook:
nginx:
IO :
:
:
: ,
: ,
:IO
:event-driven
:aio
nginx:
mmap
event-driven
:
aio
PHP nginx fastcgi
redis:
nosql: ,
location [op] uri {
proxy_pass http://172.16.100.11/;
}
~
~*
^~
location @name( location):
location / {
error 404 @fallback( fallback)
}
location @fallback {
proxy_pass http://1
92.168.1.20;
}
location /forum/ {
proxy_pass http://192.168.1.100:8080/bbs/;
}
/forum/ /bbs/ ,
http://www.psmov.com/forum/ http://192.168.1.100:8080/bbs/ http
( ) , ,
location ~* ^/forum {
proxy_pass http://192.168.1.100:8080;
}
http://www.psmov.com/forum/ http://192.168.1.100:8080/forum/ http
proxy_set_header x-real-IP $remote_addr( , , proxy_set_header x-real-IP $remote_addr)
:
get、post、head、put、trace、options、connection、delete
location ~* ^/forum {
proxy_pass http://192.168.1.100:8080;
proxy_set_header x-real-ip $remote_addr;
}
nginx :
round-robin
ip_hash: backup
least_com
nginx
cache: ( )
proxy_cache_path: , server
proxy_cache_path /nginx/cache/first levels=1:2:1 keys_zone=first( location ):20m max_size=1G
cache_manager:lru
location / {
proxy_pass http://192.168.1.100:8080/webservs/;
proxy_cache first;
proxy_cache_valie 200 10m;
}
open_log_cache:
open_file_cache:
fastcgi_cache:
nginx limit
nginx:gzip
upstream phpserver {
server ...
server ...
}
upstream imgsrvs {
server ...
server ...
}
location / {
root /web;
index index.php index.html;
}
location ~* .php$ {
fastcgi_pass http://phpserver;
}
location ~* “.(jpg|jpeg|gif|png)$”
proxy_pass http://imgsrvs;
}
rewrited:URL ( )
if (condition){
}
:
;
~,!~
,!
~,!~
if ($request_method=“POST”){
}
if ($request_uri ~* "/forum") {
}
:
referer:
location /images/ {
rewrite http://192.168.1.20/images/
}
:
location / {
root html;
index index.html;
rewrite “^/bbs/(.)$” http://192.168.1.20/forum/$1 last;
}
/bbs/ , $1 (.)$,
last: , ;
break: , ;
webdav: http
http :
Dav on
/etc/init.d/httpd restart
setfacl -m u:apache:rwx /var/www/html
nginx :
location / {
proxy_pass http://192.168.1.20/;
if ($request_method = "PUT")
proxy_pass http://192.168.1.21;
}
curl -T /etc/fstab http://172.16.100.106
PHP+nginx :
1.nginx.conf :
index index.php,location php fastcgi_pass fastcgi_param
server {
listen 80;
server_name localhost;
location / {
root html;
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ .php$ {
root html;
fastcgi_pass 172.18.0.5:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
}
2. fastcgi_pass , php index root
3.ls -l /usr/local/nginx/html/index.php
4. :1. nginx php , 172.18.0.5 nginx root , index.php
2. nginx php , php 127.0.0.1 , nginx.conf :
(fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;)
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.