一、服务部署

1、预处理

安装CentOS ,配置hosts、静态IP、设置必要的安全参数等(略)

1-1、系统环境

[root@vnx ~]# cat /etc/redhat-release
CentOS release 6.9 (Final)
[root@vnx ~]# uname -r
2.6.-.el6.x86_64
[root@vnx ~]# uname -m
x86_64

1-2、检查依赖

[root@vnx ~]# rpm -qa gcc gcc-c++
[root@vnx ~]# rpm -qa pcre-devel pcre
[root@vnx ~]# rpm -qa zlib zlib-devel
[root@vnx ~]# rpm -qa openssl openssl-devel

1-3、安装依赖

[root@vnx ~]# yum -y install gcc gcc-c++
[root@vnx ~]# yum -y install pcre-devel pcre
[root@vnx ~]# yum -y install zlib zlib-devel
[root@vnx ~]# yum -y install openssl openssl-devel

模块说明:

  Nginx 是 C语言 开发,安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装:

  PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库。nginx也需要此库。

  zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库。

  OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库。

摘自:centos7安装Nginx - 极光天际 - 博客园  https://www.cnblogs.com/kaid/p/7640723.html

1-4、创建Nginx用户

[root@vnx ~]# useradd nginx -s /sbin/nologin -M

2、下载、解压、编译、安装

[root@vnx ~]# wget --no-check-certificate  https://nginx.org/download/nginx-1.14.0.tar.gz
[root@vnx ~]# mkdir -p /home/tools
[root@vnx ~]# tar -zxf nginx-1.14..tar.gz -C /home/tools/ [root@vnx ~]# cd /home/tools/nginx-1.14./
[root@vnx nginx-1.14.]# ./configure --user=nginx --group=nginx --prefix=/app/nginx-1.14./ --with-http_stub_status_module --with-http_ssl_module
[root@vnx nginx-1.14.]# make && make install [root@vnx nginx-1.14.]# ln -s /app/nginx-1.14./ /app/nginx

3、安装结果检查

3-1、验证,查看目录情况、检查配置文件语法

[root@vnx nginx-1.14.]# tree -d /app/
/app/
├── nginx -> /app/nginx-1.14./
└── nginx-1.14.
├── conf
├── html
├── logs
└── sbin [root@vnx nginx-1.14.]# /app/nginx/sbin/nginx -t
nginx: the configuration file /app/nginx-1.14.//conf/nginx.conf syntax is ok
nginx: configuration file /app/nginx-1.14.//conf/nginx.conf test is successful

3-2、启动,检查端口等检查启动结果

[root@vnx nginx-1.14.]# /app/nginx/sbin/nginx 

[root@vnx nginx-1.14.]# lsof -i :
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx root 6u IPv4 0t0 TCP *:http (LISTEN)
nginx nginx 6u IPv4 0t0 TCP *:http (LISTEN)
[root@vnx nginx-1.14.]# netstat -lnt | grep
tcp 0.0.0.0: 0.0.0.0:* LISTEN
[root@vnx nginx-1.14.]# [root@vnx home]# wget 127.0.0.1
[root@vnx nginx-1.14.]# curl 127.0.0.1

二、基于域名的虚拟主机配置

1、编辑hosts映射

[root@vnx nginx]# vim /etc/hosts
[root@vnx nginx]# tail - /etc/hosts
192.168.220.129 vnx www.vnx.com blog.vnx.com bbs.vnx.com

2、拷贝、编辑配置文件

[root@vnx nginx]# diff conf/nginx.conf conf/nginx.conf.default
[root@vnx nginx]# egrep -v "#|^$" conf/nginx.conf.default >conf/nginx.conf
[root@vnx nginx]# vim conf/nginx.conf
[root@vnx nginx]# cat conf/nginx.conf
worker_processes ;
events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout ;
server {
listen ;
server_name www.vnx.com;
location / {
root html/www;
index index.html index.htm;
}
}
}

3、静态页模拟网站首页

[root@vnx nginx]# mkdir /app/nginx/html/www -p
[root@vnx nginx]# echo "http://www.vnx.com" > /app/nginx/html/www/index.html
[root@vnx nginx]# cat ../html/www/index.html
http://www.vnx.com

4、检查、重载配置文件

[root@vnx nginx]# ./sbin/nginx -t
nginx: the configuration file /app/nginx-1.14.//conf/nginx.conf syntax is ok
nginx: configuration file /app/nginx-1.14.//conf/nginx.conf test is successful [root@vnx nginx]# ./sbin/nginx -s reload

5、检查nginx启动情况、访问情况

[root@vnx www]# ps -ef | grep nginx
root : ? :: nginx: master process ./sbin/nginx
nginx : ? :: nginx: worker process
root : pts/ :: grep nginx
[root@vnx www]#
[root@vnx www]# curl www.vnx.com
http://www.vnx.com

Nginx--服务部署、基于域名的虚拟主机配置的更多相关文章

  1. Nginx总结(四)基于域名的虚拟主机配置

    前面讲了如何安装配置Nginx,大家可以去这里看看nginx系列文章:https://www.cnblogs.com/zhangweizhong/category/1529997.html 今天要说的 ...

  2. CentOS 7运维管理笔记(8)----Apache基于域名的虚拟主机配置

    使用基于域名的虚拟主机配置是比较流行的方式,可以在同一个IP上配置多个域名并且都通过80端口访问. (1) 在网卡 eth0的第五个接口上配置 192.168.1.215 这个地址: (2) 配置/e ...

  3. nginx基于域名的虚拟主机配置(本地分布式项目域名配置及测试方法)

    最有用的虚拟主机配置方式. 一个域名只能绑定一个ip地址,一个ip地址可以被多个域名绑定. 可以修改host文件实现域名访问. 前提:即使我们在nginx中配置基于域名的虚拟主机,也需要域名解析,即n ...

  4. 在Nginx中部署基于IP的虚拟主机

    一.虚拟主机概念 虚拟主机是在网络服务器上划分出一定的磁盘空间供用户放置站点.应用组件等,提供必要的站点功能.数据存放和传输功能.所谓虚拟主机,也叫"网站空间", 就是把一台运行在 ...

  5. apache2 httpd 基于域名的虚拟主机配置 for centos6X 和debian-8

    全系统虚拟主机: for debian 系统的apache2 域名 虚拟主机

  6. CentOS 7----Apache基于域名的虚拟主机配置

    配置/etc/hosts文件,192.168.1.209 对应的域名如下: 192.168.1.209 www.name1.com 编辑每个域名的配置文件: <VirtualHost 192.1 ...

  7. LNMP 基于域名的虚拟主机配置 (Centos5.6)

    . . server { listen ; #listen [::]: default_server ipv6only=on; server_name www.blog.com; index inde ...

  8. Nginx(二)-- 配置文件之虚拟主机配置

    1.配置文件与解释 #user nobody; worker_processes 1; # 设置工作子进程,默认是1个工作子进程,可以修改,一般设置为CPU的总核数 #error_log logs/e ...

  9. CentOS 7运维管理笔记(6)----Apache 基于 IP 的虚拟主机配置

    Apache 配置虚拟主机支持3种方式:基于IP的虚拟主机配置,基于端口的虚拟主机配置,基于域名的虚拟主机配置.本篇随笔记录自己基于IP的虚拟主机配置. 如果同一台服务器有多个IP,可以使用基于IP的 ...

随机推荐

  1. springMVC DispatcherServlet类关系图

  2. laravel学习笔记一

    指定端口 数据迁移 php artisan migrate:install 任何路由 match get,post只选择其一 没有表名对应默认的posts表,如果表为post就不行 时区不对时 分页 ...

  3. 文本分类实战(八)—— Transformer模型

    1 大纲概述 文本分类这个系列将会有十篇左右,包括基于word2vec预训练的文本分类,与及基于最新的预训练模型(ELMo,BERT等)的文本分类.总共有以下系列: word2vec预训练词向量 te ...

  4. c# 7.0 6.0 新语法

    1.参考地址:https://docs.microsoft.com/zh-cn/dotnet/csharp/tutorials/exploration/csharp-7?tutorial-step=5 ...

  5. 线性回归和Logistic回归

    目录 线性回归 用线性回归模型拟合非线性关系 梯度下降法 最小二乘法 线性回归用于分类(logistic regression,LR) 目标函数 如何求解\(\theta\) LR处理多分类问题 线性 ...

  6. Photoshop调出外景婚片蓝色小清新艺术效果

    春季婚纱旺季来了,好多童鞋给我抱怨说客片太难转色了,春天的小清新感都转不了,其实并不难,运用好互补色来进行加减色,能很快调整好照片的偏色,互补色也可称为对比色,后期调色的加也可称为减,如加蓝=减黄.加 ...

  7. 有关python2与python3中关于除的不同

    有关python2与python3中关于除的不同 python中2版本与3版本关于除的处理还是有一些差异的. 在python 2.7.15中除(/)是向下取整的,即去尾法. 123/10 # 结果 1 ...

  8. windows平台上用python 远程线程注入,执行shellcode

    // 转自: https://blog.csdn.net/Jailman/article/details/77573990import sys import psutil import ctypes ...

  9. css 通配符选择器

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  10. iOS 利用高德地图WMS服务

    Demo:  https://github.com/xushiyou23/AMapTesting 转: 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net ...