在上一篇的文章介绍了如何在linux(服务器)上部署yapi
文章地址:https://blog.youkuaiyun.com/baidu_36821021/article/details/86110411
那么,本文就介绍如何让外界访问到服务器上的应用。
一、安装nginx
1、准备环境
yum -y install gcc gcc-c++ autoconf automake make
yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
2、下载安装包
wget http://nginx.org/download/nginx-1.12.0.tar.gz
3、开始安装
tar zxvf nginx-1.12.0.tar.gz
cd nginx-1.12.0
./configure --prefix=/usr/local/nginx
make
make install
–prefix=path 定义一个目录,存放服务器上的文件 ,也就是nginx的安装目录。默认使用 /usr/local/nginx
4、启动
cd /usr/local/nginx/sbin
./nginx
在浏览器上输入:http://localhost,看到页面显示
Welcome to nginx!
证明nginx启动成功了
5、配置访问地址
vim /usr/local/nginx/conf/nginx.conf
6、开机自动启动Nginx服务
vim /etc/init.d/nginx
复制内容如下:
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: NGINX is an HTTP(S) server, HTTP