简体   繁体   English

www-data在无业游民配置的virtualbox上找不到红宝石

[英]www-data can't find the ruby gems on vagrant configured virtualbox

I'm trying to get a virtual server running using Vagrant and VirtualBox. 我正在尝试使用Vagrant和VirtualBox运行虚拟服务器。 For the VirtualBox I'm using scotch/box which got all the basic stuff for running a ubuntu server with some components (apache, mysql, php etc.) more on scotchbox can be found here. 对于VirtualBox,我使用的是scotch/box ,它提供了用于运行带有某些组件(apache,mysql,php等)的ubuntu服务器的所有基本信息,可以在scotchbox上找到更多信息。

Now I got the server up and running (running a Yii2 application) but as soon as the application starts I get an Yii error message sh: 1: sass: not found and because of that a SASS file couldn't be converted to CSS. 现在我启动并运行服务器(运行Yii2应用程序),但是一旦应用程序启动,我就会收到一条Yii错误消息sh: 1: sass: not found ,因此无法将SASS文件转换为CSS。 So I went back to my server to check if sass was installed, it wasn't so I ran the command gem install sass and after that sass was installed. 所以我回到服务器检查sass是否已安装,不是,所以我运行了命令gem install sass ,然后安装了该sass。 gem list sass -i returned true. gem list sass -i返回true。

But still the problem stayed, sass couldn't be found. 但是问题仍然存在,找不到sass。 I went back to my console and of course apache is ran by user www-data and I logged in to ssh with the vagrant user. 我回到控制台,当然,apache是​​由用户www-data运行的,并且我与无业游民的用户登录到ssh。 And this is were it gets a bit vague for me. 这对我来说有点含糊。 In the environments variables of the apache service I added the paths to both ruby and the gems. 在apache服务的环境变量中,我将路径添加到了ruby和gems。 But still the www-data user cannot find the sass command or the gem command or even the ruby command. 但是www数据用户仍然找不到sass命令,gem命令甚至ruby命令。

I also tried to change the owner of the apache service from www-data to the vagrant user that did kinda help but thats not the solution I want to accept. 我还尝试将apache服务的所有者从www-data更改为确实有帮助的无业游民的用户,但这不是我想要接受的解决方案。 I want a solution that the apache service stays owned by the www-data user and not a root user like vagrant. 我想要一种解决方案,使apache服务仍归www-data用户所有,而不是像vagrant这样的root用户。

If more data needs to be added please let me know. 如果需要添加更多数据,请告诉我。

Envvars file Envvars文件

    envvars - default environment variables for apache2ctl

# this won't be correct after changing uid
unset HOME

# for supporting multiple apache2 instances
if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then
    SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}"
else
    SUFFIX=
fi

# Since there is no sane way to get the parsed apache2 config in scripts, some
# settings are defined via environment variables and then used in apache2ctl,
# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
# temporary state file location. This might be changed to /run in Wheezy+1
export APACHE_PID_FILE=/var/run/apache2/apache2$SUFFIX.pid
export APACHE_RUN_DIR=/var/run/apache2$SUFFIX
export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX
# Only /var/log/apache2 is handled by /etc/logrotate.d/apache2.
export APACHE_LOG_DIR=/var/log/apache2$SUFFIX

## The locale used by some modules like mod_dav
export LANG=C
## Uncomment the following line to use the system default locale instead:
#. /etc/default/locale

export LANG

## The command to get the status for 'apache2ctl status'.
## Some packages providing 'www-browser' need '--dump' instead of '-dump'.
#export APACHE_LYNX='www-browser -dump'

## If you need a higher file descriptor limit, uncomment and adjust the
## following line (default is 8192):
#APACHE_ULIMIT_MAX_FILES='ulimit -n 65536'

## If you would like to pass arguments to the web server, add them below
## to the APACHE_ARGUMENTS environment.
#export APACHE_ARGUMENTS=''

## Enable the debug mode for maintainer scripts.
## This will produce a verbose output on package installations of web server modules and web application
## installations which interact with Apache
#export APACHE2_MAINTSCRIPT_DEBUG=1
export GEM_HOME=/home/vagrant/.rvm/gems/ruby-2.1.3
export GEM_PATH=/home/vagrant/.rvm/gems/ruby-2.1.3:/home/vagrant/.rvm/gems/ruby-2.1.3@global
export MY_RUBY_HOME=/home/vagrant/.rvm/rubies/ruby-2.1.3
export IRBRC=/home/vagrant/.rvm/rubies/ruby-2.1.3/.irbrc
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Try to find out whether the PATH that apache uses is indeed modified by your adjustments of the envvars file. 尝试找出您对envvars文件的调整是否确实修改了apache使用的PATH。 You could do this by simply putting running this php code: var_dump(getenv("PATH")); die; 您可以通过简单地运行以下php代码来做到这一点: var_dump(getenv("PATH")); die; var_dump(getenv("PATH")); die; I've had the exact same problem. 我遇到了完全相同的问题。 After a long time trying it turned out that service apache2 stop and start in vagrant is not working as expected. 经过长时间的尝试,事实证明,在无业游民中, service apache2 stopstart无法正常工作。 After setting the PATH variable in /etc/apache2/envvars try reloading apache by reloading vagrant instead: vagrant reload /etc/apache2/envvars设置PATH变量后,尝试通过重新加载vagrant来重新加载apache: vagrant reload

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM