-
-
Save luritas/d9a7073f0b1aa8dde43de4afb2839caa to your computer and use it in GitHub Desktop.
Laravel Docker Compose Nginx PHP-FPM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| yum install epel-release | |
| ### For CentOS/RHEL 7 ### | |
| rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm | |
| ### For CentOS/RHEL 6 ### | |
| # rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm | |
| yum --enablerepo=remi-php72 install php | |
| # php7.1 | |
| yum --enablerepo=remi-php71 install php | |
| #php modules | |
| ### For PHP 7.2 ### | |
| yum --enablerepo=remi-php72 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt | |
| ### For PHP 7.1 ### | |
| # yum --enablerepo=remi-php71 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt | |
| # search php modules | |
| yum --enablerepo=remi-php72 search php | grep php72 | |
| #mysql 5.7 | |
| wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm | |
| # install rpm | |
| yum localinstall mysql57-community-release-el7-7.noarch.rpm | |
| # to verify | |
| yum repolist enabled | grep "mysql.*-community.*" | |
| # install package | |
| yum install -y mysql-community-server | |
| # start mysqld | |
| service mysqld start | |
| # startup | |
| chkconfig mysqld on | |
| # root password | |
| grep 'temporary password' /var/log/mysqld.log |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: '2' | |
| services: | |
| nginx: | |
| image: nginx:alpine | |
| ports: | |
| - "8000:80" | |
| volumes: | |
| - ./nginx.conf:/etc/nginx/nginx.conf:ro | |
| - ./admin:/laravel | |
| links: | |
| - fpm | |
| fpm: | |
| build: | |
| context: . | |
| dockerfile: ./Dockerfile | |
| volumes: | |
| - ./admin:/laravel | |
| expose: | |
| - 9000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM php:7.2-fpm-alpine | |
| RUN docker-php-source extract && \ | |
| apk add --update --no-cache autoconf g++ make && \ | |
| pecl install redis && \ | |
| docker-php-ext-enable redis && \ | |
| docker-php-ext-install mysqli && \ | |
| docker-php-ext-install pdo && \ | |
| docker-php-ext-install pdo_mysql && \ | |
| docker-php-ext-install mbstring && \ | |
| docker-php-ext-install tokenizer && \ | |
| docker-php-source delete | |
| # images | |
| RUN apk add --no-cache freetype libpng libjpeg-turbo freetype-dev libpng-dev libjpeg-turbo-dev && \ | |
| docker-php-ext-configure gd \ | |
| --with-gd \ | |
| --with-freetype-dir=/usr/include/ \ | |
| --with-png-dir=/usr/include/ \ | |
| --with-jpeg-dir=/usr/include/ && \ | |
| NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \ | |
| docker-php-ext-install -j${NPROC} gd && \ | |
| apk del --no-cache freetype-dev libpng-dev libjpeg-turbo-dev | |
| RUN rm -rf /var/cache/apk/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| user nginx; | |
| worker_processes 4; | |
| pid /run/nginx.pid; | |
| events { | |
| worker_connections 768; | |
| } | |
| http { | |
| sendfile off; | |
| tcp_nopush on; | |
| tcp_nodelay on; | |
| keepalive_timeout 65; | |
| types_hash_max_size 2048; | |
| include /etc/nginx/mime.types; | |
| default_type application/octet-stream; | |
| access_log /var/log/nginx/access.log; | |
| error_log /var/log/nginx/error.log; | |
| client_max_body_size 100M; | |
| server { | |
| listen 80 default_server; | |
| server_name _; | |
| root /var/www; | |
| index index.php; | |
| location / { | |
| try_files $uri $uri/ /index.php$is_args$args; | |
| } | |
| location ~ \.php$ { | |
| include /etc/nginx/fastcgi_params; | |
| fastcgi_pass fpm:9000; | |
| fastcgi_index index.php; | |
| fastcgi_param SCRIPT_FILENAME /laravel/public/index.php; | |
| } | |
| } | |
| } |
Author
Author
- 로컬에서
php artisan migrate등을 할때는DB_HOST=docker.for.mac.localhost에서DB_HOST=localhost로 바꿔줘야함 - voyager를 사용하려면 symbolic link를 로컬에서 바꿔줘야함
- public 디렉터리로 이동
rm storage를 하여 기존 symbolic link 삭제ln -s '../storage/app/public' storage로 symbolic link 재설정
Author
docker-compose.yml 파일에
fpm
build:
context: .
dockerfile: ./Dockerfile
추가하고, Dockerfile를 생성하여 빌드함
Author
php7.1 pdo-mysql 이 없어서 php artisan migrate:status에서 memory 에러가 남
storage가 777로 변경하거나 웹서버 user가 접근 가능하게 해야함.(안그럼 500 에러남)
Author
iptables -I INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT 로 포트를 열어줘야 mysql 외부 접속 가능
Author
docker에 laravel 심볼릭 링크가 안걸려서 에러날때는
docker exec -it snsl_nginx_1 /bin/sh 로 docker를 shell로 접속 후
ln -s /laravel/storage/app/public/ /laravel/public/storage 를 해줌
chmod 777 /laravel/public/storage 로 업로드 하게 해줌
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
도커에서 라라벨 설치
docker-compose.yml에서volumes항목에./blog:/laravel를 추가하여 php 파일이 아닌 것들도 서비스 할 수 있도록 수정