0

전적으로 오프라인 환경에서 웹 사이트를 개발 중입니다. 또한, I는 CI위한 gitlab 러너를 사용하는 호스트의 문제는 gitlab 주자 laravel 애플리케이션 배포에 CentOS에 gitlab-runner 사용자가 사용하고 아파치 laravel를 실행 apache 사용자가 사용에 CentOS 제Laravel 오프라인 환경에서 Gitlab-runner와의 지속적인 통합 (CentOS 7)

이다. 파일 소유권을 변경하기 전까지 Permission denied 아파치 오류가 발생했습니다. 그 후 나는 아파치 로그에서이 오류가 발생합니다 :

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 실행 맞지? 권한 거부 오류를 수정하려면 어떻게해야합니까?

답변

0

SELinux를

나는 문제를 발견하고 항상 SELinux가처럼 그것은, SELinux를하고 있었고, 난 문제 무엇 시작 부분


그것을 무시 :

ls -lZ 명령을 사용하여 파일에 selinux 컨텍스트를 볼 수 있습니다. 기본적으로 www의 모든 파일은 httpd_sys_content_t입니다. 문제는 바로 selinux입니다. 아파치가이 파일을 읽을 수있게하십시오. 쓰기가 가능하도록 storagebootstrap/cache 컨텍스트를 변경해야합니다.

4 아파치 컨텍스트 유형이 있습니다 :

  • httpd_sys_content_t : 읽기 전용 디렉토리와 파일
  • httpd_sys_rw_content_t :
  • httpd_log_t 아파치
  • 에서 사용하는 읽기 및 쓰기 디렉토리와 파일 : Apache에서 로그 파일 및 디렉토리 용으로 사용합니다.
  • http을 d_cache_t : 캐시 파일 및 디렉토리에 아파치가 사용

수행 할 작업 : 모두의

첫 번째는 더 나은 명령

yum install -y policycoreutils-python

에 대한 policycoreutils-python를 설치 semanage 명령 policycoreutils-python을 설치 한 후 사용할 수 있으므로 다음과 같이 파일 컨텍스트를 변경할 수 있습니다.

semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/laravel/storage(/.*)?" semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/laravel/bootstrap/cache(/.*)?"

이 명령으로 변경 내용을 커밋하는 것을 잊지 마세요 :

restorecon -Rv /var/www/html/laravel/storage restorecon -Rv /var/www/html/laravel/bootstrap/cache 문제는 해결된다

:

심판 : http://www.serverlab.ca/tutorials/linux/web-servers-linux/configuring-selinux-policies-for-apache-web-servers/