仅供参考, 不同系统操作可能会不一样, 中间遇到错误, 找一下错误原因, 一般是单词”error“后的一句, 复制, 百度, vim操作下面有注释
安装nginx
- 方法一:这个是最简单的方法,但是很有可能会失败,这里搞定了就能直接去配置nginx了
说明 |
命令 |
1.安装g++a |
sudo apt-get install g++ |
2.使用apt直接安装 |
sudo apt-get install nginx |
3.启动 |
service nginx start |
下载nginx及相关组件输入 :
1 2 3 4 5
| cd /usr/local/src/ wget http://nginx.org/download/nginx-1.10.2.tar.gz wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz wget http://zlib.net/zlib-1.2.11.tar.gz wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
|
**安装c++编译环境**
1 2
| yum install gcc-c++ 或者 apt-get install g++ 中间需要确认一次, 输入: y
|
**安装nginx及相关组件**
安装openssl: 1 2 3 4
| tar zxvf openssl-fips-2.0.10.tar.gz cd openssl-fips-2.0.10 ./config && make && make install cd /usr/local/src/ 或者 cd .. 回到src文件夹中
|
安装pcre: tar zxvf pcre-8.40.tar.gz
1 2 3
| cd pcre-8.40 ./configure && make && make install cd /usr/local/src/ 或者 cd .. 回到src文件夹中
|
安装zlib: tar zxvf zlib-1.2.11.tar.gz
1 2 3
| cd zlib-1.2.11 ./configure && make && make install cd /usr/local/src/ 或者 cd .. 回到src文件夹中
|
安装nginx : tar zxvf nginx-1.10.2.tar.gz
1 2
| cd nginx-1.10.2 ./configure && make && make install
|
启动 nginx
1
| whereis nginx # 得到路径 例如: /usr/local/nginx
|
1 2 3
| /usr/local/nginx/sbin/nginx 或者 cd /usr/local/nginx/sbin/ 输入: nginx 或 ./nginx
|
1
| ps -aux | grep nginx # 出现三条记录就表示已经启动成功
|
- 如果启动成功, 不改配置文件打开自己的域名也能看到一个默认页面, 说明域名已经绑定成功

配置nginx
1 2
| whereis nginx # 得到路径 例如: /usr/local/nginx cd /usr/local/nginx
|
- 找到如图所示的地方, 位置和文件名称改为自己需要展示的网页

注释
- nginx操作命令:
启动
1
| /usr/local/nginx/sbin/nginx
|
停止/重启
1
| /usr/local/nginx/sbin/nginx -s stop(quit、reload)
|
命令帮助
1
| /usr/local/nginx/sbin/nginx -h
|
验证配置文件
1
| /usr/local/nginx/sbin/nginx -t
|
配置文件
1
| vim /usr/local/nginx/conf/nginx.conf
|
vim简单操作命令: 深入了解百度
开启编辑:按“i”或者“Insert”键
退出编辑:“Esc”键
退出vim:“:q”
保存vim:“:w”
保存退出vim:“:wq”
不保存退出vim:“:q!”
- 查看当前系统版本, 输入:
1
| cat /etc/redhat-release 或 : lsb_release -a
|
参考: https://www.cnblogs.com/taiyonghai/p/6728707.html