简体   繁体   English

pip在ubuntu服务器virtualenv中安装django的问题

[英]issue with pip installing django in ubuntu server virtualenv

I created a virtualenv on and EC2 instance, and have installed ubuntu server. 我在和EC2实例上创建了virtualenv,并安装了ubuntu服务器。

I created a non root user "ivan" as gave is sudo permission: 我创建了一个非root用户“ ivan”,因为它具有sudo权限:

usermod -a -G sudo ivan

When I activate the virtualenv and run this command with the user ivan: 当我激活virtualenv并以用户ivan运行此命令时:

pip install django==1.7  

I get various permission related errors: 我收到各种与权限相关的错误:

The directory '/home/ivan/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want the -H flag.

as well as more importantly 以及更重要的是

  PermissionError: [Errno 13] Permission denied: '/home/ivan/sites/mysite/virtualenv/lib/python3.4/site-packages'

While the virtualenv was activated, I tried 在激活virtualenv时,我尝试了

sudo pip install django==1.7 sudo pip install django == 1.7

but that installed django to the system folders, and not in the virtualenv. 但是将django安装到了系统文件夹中,而不是在virtualenv中。

I also tried changing to the root user and activating the virtualenv used the pip install command again with this result (since it already installed to the system with the sudo pip install command): 我还尝试更改为root用户,并再次使用pip install命令激活virtualenv,结果如下(因为它已经使用sudo pip install命令安装到了系统中):

Requirement already satisfied  

I changed the permission on the site-packages to 777, then the error 13 permission error changed to a different file: 我将站点包上的权限更改为777,然后将错误13权限错误更改为另一个文件:

  PermissionError: [Errno 13] Permission denied: '/home/ivan/sites/mysite/virtualenv/bin/django-admin.py'

Questions: 问题:

1) Is using chmod for every directory or file that comes up with a permission error is a sloppy way of doing things? 1)是否对每个出现权限错误的目录或文件使用chmod是一种草率的做法? Is there a better way? 有没有更好的办法? Do I change the /home/ or some other directory permissions when I first start a ubuntu server? 首次启动ubuntu服务器时是否更改/ home /或其他目录权限?

2) is using a 777 permission on these files and directories the web server to attack? 2)是否对Web服务器要攻击的这些文件和目录使用777权限?

3) should I chmod the files and directories I have these issues with to 777, then change them back to 755? 3)我应该将遇到这些问题的文件和目录更改为777,然后将其更改回755吗?

This is my first attempt at setting up a web server, and I would appreciate any help. 这是我第一次尝试设置Web服务器,希望能对您有所帮助。

Ivan 伊万

You need to change owner of files and directories inside /home/ivan/ directory to ivan . 您需要将/home/ivan/目录中的文件和目录的所有者更改为ivan Try this: 尝试这个:

sudo chown -R ivan:ivan /home/ivan

Also, since some packages are probably partly-installed, I would recommend to recreate virtualenvs and reinstall python packages from ivan user. 另外,由于某些软件包可能已部分安装,因此我建议重新创建virtualenvs并从ivan用户重新安装python软件包。

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

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