安装Nginx

张军 3818 0

张军博客


Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务。Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambler.ru站点(俄文:Рамблер)开发的,第一个公开版本0.1.0发布于2004年10月4日。 其将源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名。2011年6月1日,nginx 1.0.4发布。 Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,在BSD-like 协议下发行。其特点是占有内存少,并发能力强,事实上nginx的并发能力确实在同类型的网页服务器中表现较好,中国大陆使用nginx网站用户有:百度、京东、新浪、网易、腾讯、淘宝等。

1   下载安装软

nginx-1.8.0.tar.gz

pcre-8.35.tar.gz

 

2         预先安装软件

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位系统 [root@sever lib]# ln -s /usr/local/lib/libpcre.so.1 /lib

解决:64位系统 [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服务器

输入命令: drivers

输入命令:C:\Windows\System32\drivers\etc\hosts 

192.168.1.124 www.baidu.com

192.168.1.124 www.sina.com

 


8         访问页面

张军博客

 

 

 

9         结束



更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论