如果我们使用sudo su www切换用户,就会得到“This account is currently not available.”的错误提示。但我们可以使用sudo su - www -s /bin/bash命令给www-data用户启动一个bash,来执行composer命令:
daweibro@ubuntu:~$ sudo su - www -s /bin/bash
www@ubuntu:~$ ls
html
这时我们再次修改配置文件,使用阿里云给大家提供的国内Composer镜像:
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
再查看composer的全局配置文件,就会发现Composer的运行环境都放在/var/www/目录下了:
www@KingChef-Workstation:~$ composer config -gl
[repositories.packagist.org.type] composer
[repositories.packagist.org.url] https://mirrors.aliyun.com/composer/
[process-timeout] 300
[use-include-path] false
[preferred-install] auto
[notify-on-install] true
[github-protocols] [https, ssh]
[vendor-dir] vendor (/var/www/vendor)
[bin-dir] {$vendor-dir}/bin (/var/www/vendor/bin)
[cache-dir] /var/www/.cache/composer
[data-dir] /var/www/.local/share/composer
[cache-files-dir] {$cache-dir}/files (/var/www/.cache/composer/files)
[cache-repo-dir] {$cache-dir}/repo (/var/www/.cache/composer/repo)
[cache-vcs-dir] {$cache-dir}/vcs (/var/www/.cache/composer/vcs)
[cache-ttl] 15552000
[cache-files-ttl] 15552000
[cache-files-maxsize] 300MiB (314572800)
[bin-compat] auto
[discard-changes] false
[autoloader-suffix]
[sort-packages] false
[optimize-autoloader] false
[classmap-authoritative] false
[apcu-autoloader] false
[prepend-autoloader] true
[github-domains] [github.com]
[bitbucket-expose-hostname] true
[disable-tls] false
[secure-http] true
[cafile]
[capath]
[github-expose-hostname] true
[gitlab-domains] [gitlab.com]
[store-auths] prompt
[archive-format] tar
[archive-dir] .
[htaccess-protect] true
[use-github-api] true
[lock] true
[home] /var/www/.config/composer
这样使用www用户配置网站服务,整个环境就会很清爽,也不会产生权限问题,我们就可以集中精力使用Drupal了。