gpt4 book ai didi

Vagrant + Docker 上的 Symfony 2 应用程序

转载 作者:行者123 更新时间:2023-12-02 10:32:04 25 4
gpt4 key购买 nike

我正在尝试在 Vagrant + Docker 群上部署 Symfony 2 应用程序。

Vagrant 文件:

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/precise64"
# config.vm.synced_folder ".", "/vagrant", owner: 'web', group: 'web'
config.vm.network "forwarded_port", host: 5000, guest: 80
# config.vm.network "forwarded_port", host: 5001, guest: 3306

config.vm.provision "docker" do |d|
d.build_image "/vagrant/Docker", args: "-t site/web"
d.run "site/web", args: "-p 80:80 -v /vagrant/application:/var/www/site"
end

end

Dockerfile:

FROM ubuntu:precise
MAINTAINER umbrella-web <http://umbrella-web.com/>

ENV DEBIAN_FRONTEND noninteractive

WORKDIR /

RUN echo "web:x:web:web::/home/web:/bin/bash" >> /etc/passwd
RUN echo "web:x:web:" >> /etc/group

# policy-rc.d access execution of start
RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d

# Update repositories
RUN apt-get update -y && \
apt-get install python-software-properties -y && \
# add-apt-repository ppa:ondrej/apache2 -y && \
add-apt-repository ppa:ondrej/php5-oldstable -y && \
apt-get update -y && \
apt-get upgrade -y

# isntall packages
RUN apt-get update -y && \
apt-get -y install \
apache2 \
php5 \
php5-mysql \
libapache2-mod-php5 \
rpl \
# phpmyadmin \
php-apc \
# debug packages
curl \
nano

# Enable apache mods.
# RUN a2enmod php5
RUN a2enmod rewrite
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
RUN /etc/init.d/apache2 restart
ADD apache/www /var/www/site
ADD apache/default /etc/apache2/sites-available/default
# RUN touch /var/www/site/index.html
# RUN echo "Hello!!!" /var/www/site/index.html

RUN chown -R www-data:www-data /var/www/site

USER web

EXPOSE 80

# CMD /usr/sbin/apache2ctl -D FOREGROUND
CMD bash

Vagrantfile 和 Dockerv 运行良好。但是,我在 Symfony 2 config.php 文件中遇到了重大问题。

Change the permissions of either "app/cache/" or "var/cache/" directory so that the web server can write into it.
Change the permissions of either "app/logs/" or "var/logs/" directory so that the web server can write into it.

因为在docker容器项目中文件所有者为1001。这家伙是谁?

-rw-rw-r-- 1 1001 1001  1065 Oct  6 13:55 LICENSE
-rw-rw-r-- 1 1001 1001 5732 Oct 6 13:55 README.md
-rw-rw-r-- 1 1001 1001 1308 Oct 6 13:55 UPGRADE-2.2.md
-rw-rw-r-- 1 1001 1001 1962 Oct 6 13:55 UPGRADE-2.3.md
-rw-rw-r-- 1 1001 1001 356 Oct 6 13:55 UPGRADE-2.4.md
-rw-rw-r-- 1 1001 1001 8499 Oct 6 13:55 UPGRADE.md
drwxrwxr-x 1 1001 1001 4096 Nov 17 20:44 app
drwxrwxr-x 1 1001 1001 4096 Nov 17 20:43 bin
-rw-rw-r-- 1 1001 1001 2416 Oct 6 13:55 composer.json
-rw-rw-r-- 1 1001 1001 56835 Nov 17 20:43 composer.lock
-rw-r--r-- 1 1001 1001 19 Nov 20 13:49 index.php
drwxrwxr-x 1 1001 1001 4096 Nov 17 21:33 nbproject
drwxrwxr-x 1 1001 1001 4096 Nov 17 20:43 src
drwxrwxr-x 1 1001 1001 4096 Nov 17 20:44 vendor
drwxrwxr-x 1 1001 1001 4096 Nov 20 13:44 web

我该如何解决这个问题?命令 chown 和 setfacl 不起作用...

最佳答案

我没有将 vagrant 与 docker 一起使用,但我在使用 vagrant 和 symfony 时遇到了类似的问题。我必须在 vagrant 文件中配置日志和缓存目录的权限,所以像这样( guest 是 Ubuntu 14.04):

config.vm.synced_folder "symfony/app/cache", "/vagrant/symfony/app/cache", owner: "www-data", group: "vagrant", mount_options: ["dmode=775,fmode=664"]
config.vm.synced_folder "symfony/app/logs", "/vagrant/symfony/app/logs", owner: "www-data", group: "vagrant", mount_options: ["dmode=775,fmode=664"]

这会更改这些目录的权限,但就像我说的,我不确定它如何使用 docker 工作。不管怎样,还是值得一试。

我还应该提到,根据您的 symfony 版本,目录可能是/var/logs 和/var/cache,所以也要仔细检查。

关于Vagrant + Docker 上的 Symfony 2 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27044964/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com