一.安装xshell xftp.
- 新建会话
- 输入用户名密码
连接成功后安装nginx
1.环境安装
yum install gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
2.安装包
wget -c https://nginx.org/download/nginx-1.12.0.tar.gz
3.解压
tar -zxvf nginx-1.12.0.tar.gz
cd nginx-1.12.0
使用默认配置
./configure
4.编译
make
make install
或 make install PREFIX=/usr/nginx #这里可以指定安装位置
5.查找安装路径
whereis nginx
6.启动
cd /usr/local/nginx/sbin/ #进入bin目录
./nginx #启动
#常用命令
./nginx -s stop #此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程
./nginx -s quit #此方式停止步骤是待nginx进程处理任务完毕进行停止
./nginx -s reload #刷新
此时可以看到nginx 的默认页面
二.配置项目
.conf文件
server {
listen 80 ;//端口
server_name 192.168.5.60;// 域名或ip
}
location /api{
proxy_pass 接口地址;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /项目1{
alias 项目地址;
index index.html index.htm;
}
location /项目2 {
alias 项目地址;
index index.html index.htm;
}
}
**
history模式需要加重定向
location / {
try_files $uri $uri/ /index.html;
}
查找nginx 的命令
find / -name nginx.conf