Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器。

想要Linux下安装Nginx作为WEB服务器,要先准备些必要的库和工具,通常必须安装的是:PERC库和Openssl。

分四步走,让你的Nginx迅速跑起来!

1. 安装PCRE库(Nginx的rewrite模块和HTTP核心模块会用到PCRE正则表达式语法)

不用考虑是否已安装,直接上命令:

使用yum来安装:

[root@example.com ~]# yum install pcre pcre-devel

或者用apt-get:

[root@example.com ~]# apt-get install libpcre3 libpcre3-dev

如果这些安装包已经安装在系统上,你会收到Nothing to do 的信息,就是已安装过了的意思。

 

2.安装OpenSSL(若服务器提供安全网页(https://)时,会用到OpenSSL库)

使用yum:

[root@localhost example]# yum install openssl openssl-devel

或者用apt-get:

[root@localhost example]# apt-get install openssl openssl-dev

3.下载、解压Nginx

http://nginx.org/下载你要使用的版本,放到home目录,然后解压

[root@localhost example]# tar zxf nginx-0.7.66.tar.gz

4.安装Nginx

创建一个应用程序通常分为三步:从源代码到配置、编译和安装编译。每一步都有很多配置项,但对于初学者,我们只是让它能跑起来,可以先忽略这些配置项。最容易的办法依次执行下面三个命令:

[root@localhost nginx-0.7.66]# ./configure             //有一个重要的配置项是 --prefix=...指定安装Nginx的基础目录,比如你想把它安装在 /home/jiang/www/下,这个完整的命令应该是:[root@localhost nginx-0.7.66]# ./configure --prefix=/home/jiang/www

configure过程中可能出现的几个报错,及原因:

  • 1) ./configure: error: C compiler gcc is not found 原因:你没有安装gcc ,这样可能你也没安装下面几个包,请一并安装
    yum install gcc gcc-c++ autoconf make
  • 2) Makefile: 权限不够 原因:当前用户没有权限读写nginx源码目录,请切换到root下运行如下命令,作用是将当前目录的所有文件所有者都设为我们正在使用的普通用户。
    [jiang@localhost nginx-0.7.66]# chown -R jiang:jiang  ./
    [jiang@localhost nginx-0.7.66]# exit
    然后exit退出到普通用户状态下。 chown 后的 feng:feng 分别是所使用的普通账号的用户名,及其用户组名。

[root@localhost nginx-0.7.66]# make

[root@localhost nginx-0.7.66]# make install

至此安装成功,去安装Nginx的基础目录下的sbin/,注意,我这里的目录是/home/jiang/www/sbin,执行命令:

[root@localhost sbin]# ./nginx           //效果见下图

 

屏幕上不会出现任何文本信息,这是个好迹象,意味着正在正确运行。

打开浏览器,输入localhost,done done done done ~~~

标签: none

已有 4 条评论

  1. Hi, my name is Adrienne and I am the sales manager at StarSEO Marketing. I was just looking at your Linux下Nginx安装(pcre和openssl) | 青鱼博客 website and see that your site has the potential to become very popular. I just want to tell you, In case you don't already know... There is a website service which already has more than 16 million users, and the majority of the users are interested in niches like yours. By getting your site on this service you have a chance to get your site more visitors than you can imagine. It is free to sign up and you can read more about it here: http://pixz.nu/209D - Now, let me ask you... Do you need your site to be successful to maintain your business? Do you need targeted traffic who are interested in the services and products you offer? Are looking for exposure, to increase sales, and to quickly develop awareness for your website? If your answer is YES, you can achieve these things only if you get your website on the service I am describing. This traffic service advertises you to thousands, while also giving you a chance to test the network before paying anything at all. All the popular blogs are using this service to boost their readership and ad revenue! Why aren’t you? And what is better than traffic? It’s recurring traffic! That's how running a successful website works... Here's to your success! Read more here: http://pixz.nu/209D

  2. Ewa Ewa

    That's not just logic. That's really sebsnile.

  3. Hi, my name is Adrienne and I am the marketing manager at StarSEO Marketing. I was just looking at your Linux下Nginx安装(pcre和openssl) | 青鱼博客 site and see that your site has the potential to become very popular. I just want to tell you, In case you didn't already know... There is a website service which already has more than 16 million users, and the majority of the users are interested in niches like yours. By getting your website on this service you have a chance to get your site more popular than you can imagine. It is free to sign up and you can read more about it here: http://axr.be/e08- - Now, let me ask you... Do you need your site to be successful to maintain your business? Do you need targeted traffic who are interested in the services and products you offer? Are looking for exposure, to increase sales, and to quickly develop awareness for your website? If your answer is YES, you can achieve these things only if you get your website on the network I am talking about. This traffic network advertises you to thousands, while also giving you a chance to test the service before paying anything at all. All the popular sites are using this service to boost their traffic and ad revenue! Why aren’t you? And what is better than traffic? It’s recurring traffic! That's how running a successful site works... Here's to your success! Find out more here: http://gf10.com.br/url/cc9q

添加新评论