我正在使用 Symfony 5.0.7我的實時部署 ansibleafter-symlink-shared.yaml文件:---- name: Set up infrastructure-related parameters template: src: '{{ playbook_dir }}/templates/.env_live.dist' dest: '{{ ansistrano_release_path.stdout }}/.env'- name: Install Composer dependencies composer: command: install arguments: --classmap-authoritative no_dev: no optimize_autoloader: yes working_dir: '{{ ansistrano_release_path.stdout }}'- name: Clear the cache command: 'php {{ release_console_path }} cache:clear --no-warmup --env=prod'- name: Warm up the cache command: 'php {{ release_console_path }} cache:warmup --env=prod'- name: Create DB if not exists command: 'php {{ release_console_path }} doctrine:database:create --if-not-exists --env=prod' register: create_db_output changed_when: create_db_output.stdout is not search('already exists. Skipped')- name: Run migrations command: 'php {{ release_console_path }} doctrine:migrations:migrate --no-interaction --env=prod' register: run_migrations_output changed_when: run_migrations_output.stdout is not search('No migrations to execute')- name: Install bundle assets command: 'php {{ release_console_path }} assets:install --symlink --env=prod {{ ansistrano_release_path.stdout }}/public'- name: Copy build directory command: 'cp -a {{ ansistrano_release_path.stdout }}/public/build /var/www/project/public' tags: - deploy部署工作完美,但是每次我部署到服務(wù)器時,我的生產(chǎn)環(huán)境都會遇到 500 錯誤。我查看了我的prod.log文件以了解導(dǎo)致錯誤的原因,并得到以下信息:這看起來像是一個權(quán)限問題,因為每次我部署時,都會出現(xiàn)這個錯誤。有沒有可能我可以從 NGINX 的角度做一些事情來確保這個功能正常?或者這是一個可靠的解決方案?我試圖避免在每次部署時手動修復(fù)這些錯誤。
1 回答

縹緲止盈
TA貢獻(xiàn)2041條經(jīng)驗 獲得超4個贊
發(fā)生問題可能是因為 ansible 在root
用戶上運行,但 PHP 服務(wù)器沒有
嘗試在劇本中添加更改目錄所有權(quán)的最后一步
- name: Fix user rights command: 'chown -R www-data: /var/www/project/public' tags: - deploy
在我的示例中,所有權(quán)授予用戶www-data
(默認(rèn)),但在您的情況下可能會有所不同。
對于檢查正確的用戶,使用命令
cd /var/www/project && ls -la
- 1 回答
- 0 關(guān)注
- 104 瀏覽
添加回答
舉報
0/150
提交
取消