繁体   English   中英

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

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

我正在尝试使用Vagrant和VirtualBox运行虚拟服务器。 对于VirtualBox,我使用的是scotch/box ,它提供了用于运行带有某些组件(apache,mysql,php等)的ubuntu服务器的所有基本信息,可以在scotchbox上找到更多信息。

现在我启动并运行服务器(运行Yii2应用程序),但是一旦应用程序启动,我就会收到一条Yii错误消息sh: 1: sass: not found ,因此无法将SASS文件转换为CSS。 所以我回到服务器检查sass是否已安装,不是,所以我运行了命令gem install sass ,然后安装了该sass。 gem list sass -i返回true。

但是问题仍然存在,找不到sass。 我回到控制台,当然,apache是​​由用户www-data运行的,并且我与无业游民的用户登录到ssh。 这对我来说有点含糊。 在apache服务的环境变量中,我将路径添加到了ruby和gems。 但是www数据用户仍然找不到sass命令,gem命令甚至ruby命令。

我还尝试将apache服务的所有者从www-data更改为确实有帮助的无业游民的用户,但这不是我想要接受的解决方案。 我想要一种解决方案,使apache服务仍归www-data用户所有,而不是像vagrant这样的root用户。

如果需要添加更多数据,请告诉我。

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

尝试找出您对envvars文件的调整是否确实修改了apache使用的PATH。 您可以通过简单地运行以下php代码来做到这一点: var_dump(getenv("PATH")); die; var_dump(getenv("PATH")); die; 我遇到了完全相同的问题。 经过长时间的尝试,事实证明,在无业游民中, service apache2 stopstart无法正常工作。 /etc/apache2/envvars设置PATH变量后,尝试通过重新加载vagrant来重新加载apache: vagrant reload

暂无
暂无

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

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