Laradock Ubuntu下的环境配置和安装

2020-08-24  本文已影响0人  Yohann丶blog
WechatIMG82.jpeg

环境

$ lsb_release -a
LSB Version:    core-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:    18.04
Codename:   bionic
$ uname -r
4.15.0-48-generic
$ getconf LONG_BIT
64

卸载Docker

$ apt-get purge docker
$ apt-get purge docker-ce
$ apt-get remove -y docker-*
$ rm -rf /var/lib/docker

如果系统中存在旧版本的 docker,先进行卸载。

安装Docker

$ apt-get update
$ apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
$ curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | apt-key add -
OK
$ apt-key fingerprint 0EBFCD88
pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) <docker@docker.com>
sub   rsa4096 2017-02-22 [S]
$ add-apt-repository \
   "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
$ apt-get install docker-ce docker-ce-cli containerd.io
$ docker --version
Docker version 19.03.12, build 48a66213fe

安装Docker-compose

$ curl -L https://get.daocloud.io/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
$ chmod +x /usr/local/bin/docker-compose
$ docker-compose --version
docker-compose version 1.24.0, build 0aa59064

安装Laradock

$ git clone https://gitee.com/mirrors/Laradock.git
$ cd Laradock
$ cp env-example .env
# 启用更改源
CHANGE_SOURCE=true
# 设置composer下载镜像
WORKSPACE_COMPOSER_REPO_PACKAGIST=https://mirrors.aliyun.com/composer
# 设置node下载镜像
WORKSPACE_NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node
# 关闭安装项
WORKSPACE_INSTALL_NPM_GULP=false
$ docker-compose build nginx
$ docker-compose build php-fpm
$ docker-compose build workspace

因为编译过程是比较缓慢,这里建议同时开三个窗口分别执行。

$ docker-compose up -d nginx mysql

安装Laravel

$ docker-compose exec workspace bash
/var/www# composer config -g repo.packagist composer https://mirrors.aliyun.com/composer
/var/www# composer create-project --prefer-dist laravel/laravel
/var/www#  chmod 777 -R laravel/storage

启动项目

$ cd Laradock/nginx/sites
$ cp laravel.conf.example 118.31.23.98.conf

这里命令的文件名称是该服务器的IP地址。

# 设置服务器访问地址
server_name 118.31.23.98;
$ cd Laravel
$ cp .env.example .env
# 项目地址
APP_URL=http://118.31.23.98
# mysql数据库连接
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=root
$ docker-compose build nginx && docker-compose restart nginx
laravel.test_.png

浏览器打开 http://118.31.23.98 ,如上图所示,成功访问。

上一篇下一篇

猜你喜欢

热点阅读