虚拟机下linux系统安装nginx
近在windows虚机下安装nginx,也遇到部分问题,写篇随笔总结一下
一.安装虚机
windows下安装虚拟机我就不说了,一搜一大把,一直下一步就ok了
二. 打开虚拟安装nginx
1.选择版本,下载nginx。下载地址:http://nginx.org/download/
[root@localhost /]# wget http://nginx.org/download/nginx-1.7.0.tar.gz
2.安装pcre openssl gcc库及源码包
[root@nginx /]# yum -y install pcre pcre-devel openssl openssl-devel gcc gcc-c++
3.解压
[root@nginx /]# ll nginx-1.6.3.tar.gz
[root@nginx /]# tar zxvf nginx-1.6.3.tar.gz
[root@nginx /]# cd nginx-1.6.3
[root@nginx nginx-1.7.0]# pwd
/nginx-1.7.0
4.创建nginx用户
[root@nginx nginx-1.7.0]# useradd nginx -s /sbin/nologin -M
5.配置、编译、安装
[root@nginx nginx-1.7.0]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
[root@nginx nginx-1.7.0]# echo $?
0
[root@nginx nginx-1.7.0]# make && make install
[root@nginx nginx-1.7.0]# echo $?
0
[root@nginx nginx-1.7.0]# ln -s /usr/local/nginx/sbin/* /usr/local/sbin
6.启动nginx
[root@nginx nginx-1.7.0]# /usr/local/sbin/nginx -t
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
[root@nginx nginx-1.7.0]# /usr/local/sbin/nginx
[root@nginx nginx-1.7.0]# netstat -lntup | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3556/nginx
[root@nginx nginx-1.7.0]# lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 3556 root 6u IPv4 17544 0t0 TCP *:http (LISTEN)
nginx 3557 nginx 6u IPv4 17544 0t0 TCP *:http (LISTEN)
7.至此nginx启动成功了,我们先在虚拟机中试一下
[root@nginx nginx-1.7.]# curl localhost
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p> <p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p>
</body>
</html>
8.在外部的windows下访问虚拟机中的nginx服务
[root@nginx nginx-1.7.0]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.78.130 netmask 255.255.255.0 broadcast 192.168.78.255
inet6 fe80::3164:48be:dd5f:fa27 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:78:48:f2 txqueuelen 1000 (Ethernet)
RX packets 202596 bytes 299827475 (285.9 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 107108 bytes 6501152 (6.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 104 bytes 10607 (10.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 104 bytes 10607 (10.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:87:29:e0 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
红色字体部分就是虚拟机的ip地址了,然后我在外部浏览器中访问http://192.168.78.130,发现请求不到服务,原来是因为linux下防火墙的问题,默认使用的fireWall
9.禁用firewalld&开启iptables&systemctl使用简介
9.1.安装
[root@localhost ~]# yum install iptables-services
9.2.屏蔽该服务
[root@localhost ~]# systemctl mask firewalld # systemctl mask firewalld 屏蔽服务(让它不能启动)
# ln -s '/dev/null''/etc/systemd/system/firewalld.service'
# systemctl unmask firewalld 显示服务(如 firewalld.service)
# rm '/etc/systemd/system/firewalld.service'
9.3.启用iptables
[root@localhost ~]# systemctl enable iptables
#如果需要使用 ip6tables , 需另外加一行
[root@localhost ~]# systemctl enable ip6tables
9.4.启动iptables,停止firewalld
#停止firewalld服务,开启 iptables服务
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl start iptables
# 同上,如果需要使用 ip6tables , 需另外加一条
[root@localhost ~]# systemctl start ip6tables
最后在用外部windows浏览器访问:http://192.168.78.130,bingo,可以了
以上就是我安装nginx的整个流程,网上类似的教程很多,我也只是亲身实验,整理了出来。
虚拟机下linux系统安装nginx的更多相关文章
- 虚拟机下Linux系统安装vmtool工具
1.启动此虚拟机2.用超级用户root登录3.登录成功后,Ctrl+Alt ,取出鼠标,点选菜单栏,虚拟机 →安装VMware工具 → Install4.待虚拟系统挂载了光盘后,弹出cdrom文件夹或 ...
- 2-0 虚拟机与Linux系统安装
虚拟机与Linux系统安装 虚拟机硬件选择 由于是初学Linux,所以我们通过在虚拟机里安装的方式学习Linux,如果不知道找虚拟机和Linux的话请看我上一篇博客:计算机基础 如果你已经准备好了虚拟 ...
- 虚拟机下Linux读取USB设备的问题虚拟机下Linux无法读取USB设备的解决方案
我们在虚拟机中识别USB设备有三种情况导致Linux系统不能读取到USB设备: 1. .当虚拟机的USB服务没有开启的时候 2. 若虚拟机的USB连接的设置选项没有设置好 3. Widows抢先一步, ...
- 虚拟机下Linux系统如何设置IP地址
虚拟机下Linux系统设置IP地址三种方法 文章来源:https://jingyan.baidu.com/article/ea24bc399ffeb9da62b3318f.html 工具/原料 V ...
- 虚拟机下linux迁移造成MAC地址异常处理办法
虚拟机下linux迁移造成MAC地址异常处理办法 Linux无法启用网卡:Device eth0 has different MAC address than expected,ignoring解决 ...
- Vmware安装与VMware下Linux系统安装
源文件地址:http://www.cnblogs.com/lclq/p/5619271.html 1.下载安装VMware,我安装的是VMware 12.VMware从11开始不再支持32位系统,32 ...
- 虚拟机下linux安装mysql,apache和php
由于腿伤了,卧床在家折腾下linux,尝试用虚拟机装mysql,apche和php.中间各种波折,装了好几天,觉得有些经验还是要记录下来,让自己别忘了:) 按照下面这篇文章的方法,基本可以顺利安装成功 ...
- VMware虚拟机下Linux系统的全屏显示
在VMware虚拟机下的Linux无法全屏的问题的解决方案如下: 1. 启动虚拟机,并启动Redhat6.4. 2. 点击“view”——然后将Autofit window这个选项勾选.(一般 ...
- 虚拟机、linux系统安装
下载VMWare解压后依据提示正触安装VMWare到硬盘中 (1) 建立虚拟机 A.用鼠标左建双击桌面中的"VMwareworkstation"图标.执行虚拟机 B.建立一台虚拟机 ...
随机推荐
- javascript的BOM,DOM对象
BOM对象 window对象 所有浏览器都支持 window 对象.概念上讲.一个html文档对应一个window对象.功能上讲: 控制浏览器窗口的.使用上讲: window对象不需要创建对象,直接使 ...
- .NET作品集:linux下的博客程序
博客程序架构 本博客程序是博主11年的时候参考loachs小泥鳅博客内核开发的.net跨平台博客cms,距今已有6年多了,个人博客网站一直在用,虽然没有wordpress那么强大,但是当时在深究.ne ...
- 前端测试框架Jest系列教程 -- Asynchronous(测试异步代码)
写在前面: 在JavaScript代码中,异步运行是很常见的.当你有异步运行的代码时,Jest需要知道它测试的代码何时完成,然后才能继续进行另一个测试.Jest提供了几种方法来处理这个问题. 测试异步 ...
- WPF自定义产品框架
在讲解之前先看一下效果,有助于理解: 这是客户端的效果图.整个产品分为两部分:1.WPF开发的展示效果的客户端 2.WCF开发的提供数据服务接口的服务端 本章主要讲解一下实际中开发WPF开发客 ...
- NYOJ 119 士兵杀敌(三) RMQ ST
NYOJ 119 士兵杀敌(三) RMQ ST 题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=119 思路: ST在线 预处理O(nlog ...
- pdo 封装增删改查类
<?php/** * Class model * @package Core\lib */class model{ protected $pdo = null; // 连接数据库 ...
- 继webpack后又一打包神器Parcel
前言: 在继grunt.gulp实现自动化构建之后,webpack又引领前端打包潮流,众所周知的是,vue-cli的脚手架就是基于webpack进行项目打包的.而webpack还在上升的势头的时候,又 ...
- win10下Python3.6安装、配置以及pip安装包教程
0.目录 1.前言 2.安装python 3.使用pip下载.安装包 3.1 安装Scrapy 3.2 安装PyQt 3.3 同时安装多个包 3.4 pip的常用命令 1.前言 之前在电脑上安装了py ...
- 数据库介绍(MySQL安装 体系结构、基本管理)
第1章 数据库介绍及mysql安装 1.1 数据库简介 数据库,简而言之可视为电子化的文件柜——存储电子文件的处所,用户可以对文件中的数据运行新增.截取.更新.删除等操作. 所谓“数据库”系以一定方式 ...
- UPDATE/INSERT用法研究
UPDATE和INSERT语法相信大家都很熟悉,UPDATE的基本语法结构是 : UPDATE 表名称 SET 列名称 = 新值 WHERE 列名称 = 某值 INSERT的基本语法是: INSERT ...