如何在CentOS 6上重新安装python2.7以安装mod_wsgi

我已经在CentOS 6 VPS上从源代码安装了Python2.7,并且想要启动并运行一个Django站点。 不幸的是,到目前为止Googlesearch的所有内容都表明我需要安装mod_wsgi,这意味着我需要用–enable-shared标志重新安装Python2.7。

  • 我需要先卸载Python2.7吗?
  • 我怎样才能安装mod_wsgi没有完全搞乱我的系统?

提前致谢。 我一直没有find一个新手友好的指南。

mod_wsgi位于基础存储库中。 你可以运行yum install mod_wsgi

但是,如果你一直在玩从源代码安装Python,那很可能是因为你搞砸了Python环境。 在这种情况下,最好的办法是从头重新安装VPS并运行yum install mod_wsgi

假设你已经在/var/www/djangoproject部署了你的Django项目,你将会得到如下的树:

/var/www/djangoproject/ ├── manage.py ├── djangoapp │ ├── __init__.py │ ├── models.py │ ├── tests.py │ └── views.py └── djangoproject ├── __init__.py ├── __init__.pyc ├── settings.py ├── settings.pyc ├── urls.py └── wsgi.py

这将需要一个Apache conf( /etc/httpd/conf.d/djangoproject.conf ),如下所示:

#WSGIPythonPath /var/www/djangoproject/djangoproject <VirtualHost *> ServerAdmin [email protected] WSGIScriptAlias / /var/www/djangoproject/djangoproject/wsgi.py WSGIDaemonProcess myproj user=apache threads=3 <Directory /> Options FollowSymLinks AllowOverride None </Directory> DocumentRoot /tmp ServerName www.example.com ErrorLog /var/log/httpd/djangoproject_error_log CustomLog /var/log/httpd/djangoproject_access_log combined </VirtualHost>