在 Ubuntu ~20.04.1 上部署 LEMP,安装 NVM,通过它安装 NPM、Composer,安装 Laravel,执行迁移,更改所有项目文件的所有者和组
$ sudo chown -R www-data:www-data /var/www/lara1.local
我在 NGINX 中配置了主机,在 /etc/hosts 中添加了分辨率,在浏览器中打开了站点(这里一切似乎都正常)。
然后我记得项目的根本需要做什么(顺便问一下,为什么?)
$ npm i
我尝试得到错误:
toorr2p@srv1:/var/www/lara1.local$ npm i
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /var/www/lara1.local/node_modules/axios
npm ERR! dest /var/www/lara1.local/node_modules/.axios-9HH0Je4B
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/var/www/lara1.local/node_modules/axios' -> '/var/www/lara1.local/node_modules/.axios-9HH0Je4B'
npm ERR! [Error: EACCES: permission denied, rename '/var/www/lara1.local/node_modules/axios' -> '/var/www/lara1.local/node_modules/.axios-9HH0Je4B'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/var/www/lara1.local/node_modules/axios',
npm ERR! dest: '/var/www/lara1.local/node_modules/.axios-9HH0Je4B'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in: /home/toorr2p/.npm/_logs/2023-08-26T22_52_07_490Z-debug-0.log
告诉我如何解决?一般来说,权限有什么问题,如何让 NPM 作为 www-data 运行或通过 sudo 作为 root 运行?
或者这里有什么大不了的?
P/S 我是第一次安装 Laravel。
建议的解决方案:
您需要更改所有项目目录文件的所有者和组
所有动作返回后