nginx部署
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了nginx部署,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2461字,纯文字阅读大概需要4分钟。
内容图文
![nginx部署](/upload/InfoBanner/zyjiaocheng/938/21d6c16033fc423b9777339ec9b65e39.jpg)
二级域名部署-nginx
安装前配置环境
在安装nginx前首先要确认系统中安装了gcc、pcre-devel、zlib-devel、openssl-devel。
通过一下命令检测是否安装过
$yum list installed | grep "gcc"//""内为需要检测的程序
下载Nginx
【nginx下载地址:https://nginx.org/download】
【镜像网站下载地址http://mirrors.sohu.com/nginx/ 】
安装Nginx
下载“nginx.tar.gz”,移动到/usr/local/下。
## 解压
$tar -zxvf nginx.tar.gz
?
##进入nginx目录
$cd nginx
## 配置./configure --prefix=/usr/local/nginx# makemakemake $install
##执行make
$make
##执行make install
$make install
测试是否安装成功
##
$cd /usr/loca/nginx/sbin/
$./nginx -t
##返回is ok即目前没有问题
安装正常即返回
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
启动nginx
$cd /usr/local/nginx/sbin
$./nginx //启动nginx
在浏览器中输入服务器的ip地址,如:192.168.1.12 测试
配置nginx.conf文件
进入到nginx目录
进入conf目录
$vi nginx.conf
配置nginx.conf文件
user root;
worker_processes 1;
?
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
?
?
events {
worker_connections 1024;
}
?
?
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {##代理转发二级域名;!!html文件要设置为index.html
listen 80;
server_name abc.foresthan.com;##二级域名填写在这儿;
root /www/wwwroot/www.foresthan.com/fire/;##网页存放的地址
location / { ##什么都不用写;
}
}
server {##代理转发配置;!!要在阿里云解析二级域名
listen 80;
server_name vip.foresthan.com;##绑定的域名;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:3000;##启动的服务的IP:端口号;
}
}
}
保存退出返回 上一级
进入sbin目录
运行nginx
nginx常用命令
#./nginx 启动nginx服务
?
# systemctl stop nginx.service 停止服务
?
#./nginx -s reload 重新启动服务
?
# systemctl list-units --type=service 查看所有已启动的服务
?
# systemctl status nginx.service 查看服务当前状态
?
# systemctl enable nginx.service 设置开机自启动
?
# systemctl disable nginx.service 停止开机自启动
?
?
内容总结
以上是互联网集市为您收集整理的nginx部署全部内容,希望文章能够帮你解决nginx部署所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。