Nginx (engine x) 是一個高性能的HTTP和反向代理web服務(wù)器,同時也提供了IMAP/POP3/SMTP服務(wù)。Nginx是由伊戈爾·賽索耶夫為俄羅斯訪問量第二的Rambler.ru站點(俄文:Рамблер)開發(fā)的,第一個公開版本0.1.0發(fā)布于2004年10月4日。 其將源代碼以類BSD許可證的形式發(fā)布,因它的穩(wěn)定性、豐富的功能集、示例配置文件和低系統(tǒng)資源的消耗而聞名。2011年6月1日,nginx 1.0.4發(fā)布。 Nginx是一款輕量級的Web 服務(wù)器/反向代理服務(wù)器及電子郵件(IMAP/POP3)代理服務(wù)器,在BSD-like 協(xié)議下發(fā)行。其特點是占有內(nèi)存少,并發(fā)能力強,事實上nginx的并發(fā)能力確實在同類型的網(wǎng)頁服務(wù)器中表現(xiàn)較好,中國大陸使用nginx網(wǎng)站用戶有:百度、京東、新浪、網(wǎng)易、騰訊、淘寶等。
1 下載安裝軟
nginx-1.8.0.tar.gz
pcre-8.35.tar.gz
2 預(yù)先安裝軟件
error:configure: error: You need a C++ compiler for C++ support. ------------------------------------------ 解決:yum install -y gcc gcc-c++ ------------------------------------------ error:./configure: error: SSL modules require the OpenSSL library. ------------------------------------------ 解決:yum -y install openssl openssl-devel ------------------------------------------ error:./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory ------------------------------------------ 解決:32位系統(tǒng) [root@sever lib]# ln -s /usr/local/lib/libpcre.so.1 /lib 解決:64位系統(tǒng) [root@sever lib]# ln -s /usr/local/lib/libpcre.so.1 /lib6 |
3 安裝Nginx所需的pcre庫
#tar zxvf pcre-8.10.tar.gz #cd pcre-8.10/ #./configure && make && make install cd ../ |
4 安裝Nginx
#tar zxvf nginx-0.8.46.tar.gz #cd nginx-0.8.46/ ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module #make && make install cd ../ |
5 安裝日志
427 ll 428 cd / 429 ll 430 cd root 431 ll 432 cd /soft 433 mkdir /soft 434 ll 435 cd /soft 436 ll 437 pwd 438 ll 439 tar zxvf nginx-1.8.0.tar.gz 440 tar zxvf pcre-8.35.tar.gz 441 ll 442 rm -rf *.gz 443 ll 444 cd pcre-8.35/ 445 ll 446 ./configure && make && make install 447 yum list 448 yum install -y gcc gcc-c++ 449 ./configure && make && make install 450 cd /var/cache/yum 451 ll 452 cd /soft/ 453 ll 454 cd nginx-1.8.0/ 455 ll 456 ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module 457 make && make install 458 cat /user 459 cat /etc/passwd 460 cat /etc/group 461 groupadd -g 503 nginx 462 useradd -g nginx -d /home/nginx -s /bin/bash -m nginx -u 1005 463 ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module 464 apt-get install openssl 465 apt -get install openssl 466 yum install openssl openssl-devel 468 ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module 469 yum -y install openssl openssl-devel 470 ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module 471 make && make install 472 cd /usr/local/nginx/ 473 ll 474 cd sbin 475 ll 476 ./nginx 477 ln -s /usr/local/lib/libpcre.so.1 /lib64 478 ./nginx 479 ps -ef|grep nginx 480 mkdir -p /web/baidu /web/sina 481 cd /web 482 tree web 483 ll 484 cd .. 485 tree web 486 ls 487 cd web 488 ll 489 cd baidu/ 490 ll 491 vi index.html 492 cd ../sina/ 493 vi index.html 494 ll 495 cd / 496 ll 497 cd /usr/local/nginx/ 498 ll 499 cd conf/ 500 ll 501 pwd 502 cp nginx.conf nginx.conf.20150911 503 vi nginx.conf 504 pkill nginx 505 pkill -HUP nginx 506 cd /web/baidu/ 507 ll 508 chmod +x index.html 509 cd ../sina/ 510 chmod +x index.html 511 ll 512 pkill nginx 513 pkill -HUP nginx 514 netstat -an | grep 80 515 netstat -an | grep :80 516 cd /usr/local/nginx/ 517 ll 518 cd sbin/ 519 ./nginx 520 netstat -an | grep :80 521 cd /web/baidu/ 522 ll 523 vi index.html 524 cd /usr/local/nginx/ 525 ll 526 cd logs/ 527 ll 528 more error.log 529 more baidu.access.log 530 history |
6 配置nginx配置文件
server { listen 80; server_name www.baidu.com; access_log logs/baidu.access.log main; location / { root /web/baidu; index index.html index.htm; } } server { listen 80; server_name www.sina.com; access_log logs/sina.access.log main; location / { root /web/sina; index index.html index.htm; } } |
7 配置本地DNS服務(wù)器
輸入命令: drivers 輸入命令:C:\Windows\System32\drivers\etc\hosts 192.168.1.124 www.baidu.com 192.168.1.124 www.sina.com |
8 訪問頁面
9 結(jié)束
本文為張軍原創(chuàng)文章,轉(zhuǎn)載無需和我聯(lián)系,但請注明來自張軍的軍軍小站,個人博客http://m.eyofj.com
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯(lián)系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
