🔖 Nginx 安装脚本和文档
parent
a166dd2180
commit
7f887c5c0d
|
@ -46,4 +46,5 @@
|
|||
|
||||
* JDK 安装和配置:| [CODES](codes/deploy/tool/jdk) | [DOCS](docs/deploy/tool/jdk/install-jdk.md) |
|
||||
* Maven 安装和配置:| [CODES](codes/deploy/tool/maven) | [DOCS](docs/deploy/tool/maven/install-maven.md) |
|
||||
* Nginx 安装和配置:| [CODES](codes/deploy/tool/nginx) | [DOCS](docs/deploy/tool/nginx/install-nginx.md) |
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
# 安装 Nginx
|
||||
|
||||
## linux 安装 nginx 通用脚本
|
||||
|
||||
使用方法:
|
||||
|
||||
```sh
|
||||
wget --no-check-certificate --no-cookies https://raw.githubusercontent.com/dunwu/linux/master/codes/deploy/tool/nginx/install-nginx.sh
|
||||
chmod -R 777 install-nginx.sh
|
||||
./install-nginx.sh
|
||||
```
|
||||
|
||||
脚本会下载解压 nginx 到 `/opt/software/nginx` 路径下。
|
||||
|
||||
## Centos 安装 nginx 脚本
|
||||
|
||||
使用方法:
|
||||
|
||||
```sh
|
||||
wget --no-check-certificate --no-cookies https://raw.githubusercontent.com/dunwu/linux/master/codes/deploy/tool/jdk/install-nginx-by-yum.sh
|
||||
chmod -R 777 install-nginx-by-yum.sh
|
||||
./install-nginx-by-yum.sh
|
||||
```
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
###################################################################################
|
||||
# 安装 nginx 脚本
|
||||
# 仅适用于 centos 发行版本。
|
||||
# Author: Zhang Peng
|
||||
###################################################################################
|
||||
|
||||
echo -e "\n>>>>>>>>> install nginx"
|
||||
|
||||
yum -y install make nginx.x86_64
|
|
@ -1,5 +1,30 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
###################################################################################
|
||||
# 安装 nginx 脚本
|
||||
# 适用于所有 linux 发行版本。
|
||||
# nginx 会被安装到 /opt/software/nginx 路径。
|
||||
# 注意:安装 nginx 需要依赖以下库,需预先安装:
|
||||
# zlib zlib-devel gcc-c++ libtool openssl openssl-devel
|
||||
# Author: Zhang Peng
|
||||
###################################################################################
|
||||
|
||||
echo -e "\n>>>>>>>>> install nginx"
|
||||
|
||||
yum -y install make nginx.x86_64
|
||||
# 首先要安装 PCRE,PCRE 作用是让 nginx 支持 Rewrite 功能
|
||||
pcreRoot=/opt/software/pcre
|
||||
pcreVersion=8.35
|
||||
./install-pcre.sh ${pcreRoot} ${pcreVersion}
|
||||
|
||||
# 下载并解压 nginx
|
||||
ngixnRoot=/opt/software/nginx
|
||||
nginxVersion=1.12.2
|
||||
mkdir -p ${ngixnRoot}
|
||||
wget -O ${ngixnRoot}/nginx-${nginxVersion}.tar.gz http://nginx.org/download/nginx-${nginxVersion}.tar.gz
|
||||
cd ${ngixnRoot}
|
||||
tar zxvf nginx-${nginxVersion}.tar.gz
|
||||
|
||||
# 编译
|
||||
cd nginx-${nginxVersion}
|
||||
./configure --with-http_stub_status_module --with-http_ssl_module --with-pcre=${pcreRoot}/pcre-${pcreVersion}
|
||||
nginx -v
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
###################################################################################
|
||||
# 安装 pcre 脚本
|
||||
# 适用于所有 linux 发行版本。
|
||||
# 注意:本脚本需输入根路径和版本号两个参数。
|
||||
# Author: Zhang Peng
|
||||
###################################################################################
|
||||
|
||||
echo -e "\n>>>>>>>>> install pcre"
|
||||
|
||||
root=$1
|
||||
version=$2
|
||||
|
||||
# 下载并解压 pcre
|
||||
mkdir -p ${root}
|
||||
wget -O ${root}/pcre-${version}.tar.gz http://downloads.sourceforge.net/project/pcre/pcre/${version}/pcre-${version}.tar.gz
|
||||
cd ${root}
|
||||
tar zxvf pcre-${version}.tar.gz
|
||||
cd pcre-${version}
|
||||
|
||||
# 编译
|
||||
./configure
|
||||
make && make install
|
||||
pcre-config --version
|
|
@ -0,0 +1,80 @@
|
|||
# Nginx 安装
|
||||
|
||||
## 安装方法
|
||||
|
||||
### 安装编译工具及库文件
|
||||
|
||||
```
|
||||
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
|
||||
```
|
||||
|
||||
### 先安装 PCRE
|
||||
|
||||
安装步骤如下:
|
||||
|
||||
(1)下载解压到本地
|
||||
|
||||
进入官网下载地址:https://sourceforge.net/projects/pcre/files/pcre/ ,选择合适的版本下载。
|
||||
|
||||
我选择的是 8.35 版本:http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
|
||||
|
||||
```
|
||||
wget -O /opt/software/pcre/pcre-8.35.tar.gz http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
|
||||
cd /opt/software/pcre
|
||||
tar zxvf pcre-8.35.tar.gz
|
||||
```
|
||||
|
||||
(2)编译安装
|
||||
|
||||
执行以下命令:
|
||||
|
||||
```
|
||||
cd /opt/software/pcre/pcre-8.35
|
||||
./configure
|
||||
make && make install
|
||||
```
|
||||
|
||||
(3)检验是否安装成功
|
||||
|
||||
执行 `pcre-config --version` 命令。
|
||||
|
||||
### 安装 Nginx
|
||||
|
||||
安装步骤如下:
|
||||
|
||||
(1)下载解压到本地
|
||||
|
||||
进入官网下载地址:http://nginx.org/en/download.html ,选择合适的版本下载。
|
||||
|
||||
我选择的是 1.12.2 版本:http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
|
||||
|
||||
```
|
||||
wget -O /opt/software/nginx/nginx-1.12.2.tar.gz http://nginx.org/download/nginx-1.12.2.tar.gz
|
||||
cd /opt/software/nginx
|
||||
tar zxvf nginx-1.12.2.tar.gz
|
||||
```
|
||||
|
||||
(2)编译安装
|
||||
|
||||
执行以下命令:
|
||||
|
||||
```
|
||||
cd /opt/software/nginx/nginx-1.12.2
|
||||
./configure --with-http_stub_status_module --with-http_ssl_module --with-pcre=/opt/software/pcre/pcre-8.35
|
||||
```
|
||||
|
||||
(3)检验是否安装成功
|
||||
|
||||
执行 `nginx -v` 命令。
|
||||
|
||||
### 启动 Nginx
|
||||
|
||||
安装成功后,直接执行 `nginx` 命令即可启动 nginx。
|
||||
|
||||
启动后,访问站点:
|
||||
|
||||
![nginx-install.png](nginx-install.png)
|
||||
|
||||
## 脚本
|
||||
|
||||
| [安装脚本](https://github.com/dunwu/linux/tree/master/codes/deploy/tool/nginx) |
|
Binary file not shown.
After Width: | Height: | Size: 46 KiB |
Loading…
Reference in New Issue