---
title: "linux 安装nginx服务器"
author: "lym6520"
date: "2014-02-11T17:33:07Z"
tags: ["Linux", "nginx"]
categories: ["企业架构"]
slug: "linux-nginx"
draft: false
lastmod: "2014-02-11T17:33:07Z"
id: 2012897
url: "https://lym6520.iteye.com/blog/2012897"
---

下载nginx：<http://nginx.org/en/download.html>
将下载的安装包放到linux服务器上
解压安装包，{version}为版本号：

```linux
tar -zxvf nginx-{version}.tar.gz 
```


```linux
cd nginx-{version}
```

编译,--prefix指定安装的目录：

```linux

./configure --prefix=/lym/server/nginx --with-http_stub_status_module --without-http-cache --with-http_ssl_module

```


```linux

make
make install

```


设置目录权限

```linux

chmod 775 /lym/server/nginx/logs
chmod -R 775 /lym/wwwroot
chmod 755 /lym/server/nginx/sbin/nginx

```


检查配置文件是否正确：

```linux
/lym/server/nginx/sbin/nginx -t
```

启动nginx：

```linux
/lym/server/nginx/sbin/nginx
```

重启nginx:

```linux
/lym/server/nginx/sbin/nginx -s reload
```




安装过程中相关问题解决方法---------------------------------------------------------------------


执行./configure命令错误: error: the HTTP rewrite module requires the PCRE library
解决方法：

```linux

yum -y install pcre-devel openssl openssl-devel

```


linux 64系统中安装nginx时如果出现错误：nginx:  getpwnam(“www”) failed
解决方法1：
      在nginx.conf中 把user nobody的注释去掉既可
解决方法2：
      错误的原因是没有创建www这个用户，应该在服务器系统中添加www用户组和用户www，如下命令： 

```linux

groupadd -f www
useradd -g www www

```