【发布时间】:2017-05-01 06:30:42
【问题描述】:
我正在完全离线的环境中开发一个网站。另外,我使用 gitlab runner 进行 CI,主机是 CentOS 7。
问题是 gitlab runner 在 centos 上使用 gitlab-runner 用户来部署 laravel 应用程序,而 apache 使用 apache 用户来运行 laravel。
我在 apache 上收到 Permission denied 错误,直到我更改了文件的所有权。之后我在 apache 日志上得到这个错误:
Uncaught UnexpectedValueException: The stream or file "storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied
似乎像monolog 这样的一些供应商库想要将错误或调试日志写入storage/logs/laravel.log,但它的权限被拒绝。 :(
.gitlab-ci.yml
stages:
- build
- test
- deploy
buildBash:
stage: build
script:
- bash build.sh
testBash:
stage: test
script:
- bash test.sh
deployBash:
stage: deploy
script:
- sudo bash deploy.sh
build.sh
#!/bin/bash
set -xe
# creating env file from production file
cp .env.production .env
# initializing laravel
php artisan key:generate
php artisan config:cache
# database migration
php artisan migrate --force
deploy.sh
#!/bin/bash
PWD=$(pwd)'/public'
STG=$(pwd)'/storage'
ln -s $PWD /var/www/html/public
chown apache.apache -R /var/www/html/public
chmod -R 755 /var/www/html/public
chmod -R 775 $STG
我使用 gitlab runner 正确吗?如何解决权限被拒绝错误?
【问题讨论】:
标签: apache continuous-integration centos7 gitlab-ci gitlab-ci-runner