本地系统windows10
虚拟机系统ubuntu16.04
参考教程 http://www.nginx.cn/4723.html
傻瓜安装
sudo apt-get update
sudo apt-get install nginx
通常来说安装后之后要配置防火墙
but我的防火墙并没由开启
vagrant@ubuntu-xenial:~$ sudo ufw status
Status: inactive
防火墙的详细配置可以在参考教程看
之后就可以在host上访问localhost:8080了
image.png
或者在guest里访问localhost:80
vagrant@ubuntu-xenial:~$ curl localhost:80
<!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>
nginx的经典界面
遇到的坑
nginx启动报错,信息如下:
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
使用ps ef | grep nginx
,查看是否有nginx进程,有可能被其他进程占用,这时可以采用如下方式处理:
- 查看80端口占用
netstat -ntpl
- 杀掉占用80端口的进程(pid需要自行查取)
kill -9 $pid
还有一些命令
netstat命令详解
https://www.cnblogs.com/xieshengsen/p/6618993.html
lsof -i:端口号
用于查看进程
网友评论