ubuntu 安装nginx docker

nginx

安装命令:

sudo apt-get install nginx

1555929756938

 

安装好的文件位置:

/usr/sbin/nginx # 主程序目录

/etc/nginx # 存放配置文件目录

/usr/share/nginx # 存放静态文件目录

/etc/nginx/sites-available # 默认站点配置文件

/var/log/nginx # 存放日志目录

/var/www/html  # 默认站点根目录

 

相关操作

# 首次启动nginx服务器
sudo /usr/sbin/nginx

# 停止nginx服务器
sudo /usr/sbin/nginx -s stop

# 重启nginx
sudo /usr/sbin/nginx -s reload

 

Docker

更新ubuntu的apt源,上面如果执行过可以忽略

sudo apt-get update

安装包允许apt通过HTTPS使用仓库

sudo apt-get install apt-transport-https ca-certificates curl software-properties-common

1559067730172

 

添加Docker官方GPG key,网络不好的话,会报错,多执行几次即可。

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

设置Docker稳定版仓库,网络不好的话,会报错,多执行几次即可。

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

添加Docker仓库后,更新apt源索引,注意,这里更新的源是关于docker的。

sudo apt-get update

1559068011503

 

安装最新版Docker CE(社区版)

sudo apt-get install docker-ce

1559068087606

 

检查Docker CE是否安装正确,hello-world是一个打印字符串的测试镜像,docker会自动下载

sudo docker run hello-world

1559068107255

 

原文地址:https://www.cnblogs.com/Jacob-yang/p/13091255.html