LINUX系统安装

一、安装依赖

prce(重定向支持)和openssl(https支持,如果不需要https可以不安装。)

yum install -y pcre-devel
yum -y install gcc make gcc-c++ wget
yum -y install openssl openssl-devel

二、下载

wget http://nginx.org/download/nginx-1.8.0.tar.gz
wget http://nginx.org/download/nginx-1.13.3.tar.gz
wget http://nginx.org/download/nginx-1.13.7.tar.gz

# 如果没有安装wget
# 下载已编译版本
$ yum install wget

# 解压压缩包
tar zxf nginx-1.13.3.tar.gz

三、编译安装

1、然后进入目录编译安装,configure参数说明

cd nginx-1.11.5
./configure

....
Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using system zlib library
  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

关于上面的参数可以使用nginx -V来查看。

2、安装报错误的话比如:“C compiler cc is not found”,这个就是缺少编译环境,安装一下就可以了
yum -y install gcc make gcc-c++ openssl-devel

3、如果没有error信息,就可以执行下边的安装了:

make
make install

四、Nginx测试

1、运行下面命令会出现两个结果,一般情况nginx会安装在/usr/local/nginx目录中

cd /usr/local/nginx/sbin/
./nginx -t

# nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
# nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

2、设置全局nginx命令

vi ~/.bash_profile

3、将下面内容添加到 ~/.bash_profile 文件中

PATH=$PATH:$HOME/bin:/usr/local/nginx/sbin/
export PATH

4、运行命令source ~/.bash_profile让配置立即生效。你就可以全局运行 nginx 命令了。

五、使用命令行安装

1、 在ubuntu系统下。
$ sudo apt-get install nginx

2 、在CentOS系统下。
sudo yum install nginx

3、在mac下,可以使用brew安装。
$ brew install nginx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Robust_HU

喜欢的朋友,可以打赏支持一下

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值