由于工作需要夕土,需要配置一個django的工作環(huán)境堵泽,我在centos 7 上安裝了apache椒楣,版本是2.4.6蚜退。和之前使用的apache有明顯的區(qū)別闰靴,下面我就來簡單的說明一下,便于以后遇到類似的情況关霸,有所借鑒传黄。
環(huán)境
- 操作系統(tǒng) :CentOS 7
- Apache:2.4.6
配置
Apache配置多虛擬主機
安裝apache很好安裝杰扫,使用yum安裝很簡單队寇。安裝后,默認路徑為/etc/httpd章姓。
在conf目錄下佳遣,有一個httpd.conf文件识埋,在最下面面加入如下一段話:
include vhost.d/*.conf
然后再根目錄下建一個vhost.d的文件夾,在里面建一個vhost.conf文件零渐。
至此窒舟,多虛擬的環(huán)境就配置好了。
配置django站點
django站點需要wsgi模塊诵盼,自行安裝即可惠豺。
打開vhost.conf,配置如下內(nèi)容:
WSGIScriptAlias / /var/www/server/rplus/wsgi.py
WSGIPythonPath /var/www/server
<VirtualHost *:80>
ServerAdmin admin@amsilence.com
DocumentRoot "/var/www/server"
ServerName www.centos7-1.com
#ErrorLog "/var/httpd/logs/www-error_log"
#CustomLog "/var/httpd/logs/www-access_log" common
Alias /html/ /var/www/server/html/
#WSGIScriptAlias / /var/www/server/rplus/wsgi.py
#WSGIPythonPath /var/www/server
</VirtualHost>
<Directory "var/www/server/html">
Options -Indexes +FollowSymlinks
Require all granted
</Directory>
<Directory "var/www/server/media">
Options -Indexes +FollowSymlinks
Require all granted
</Directory>
<Directory "/var/www/server/rplus">
<Files "wsgi.py">
Options -Indexes +FollowSymlinks
Require all granted
</Files>
</Directory>
根據(jù)自己需要风宁,修改相應(yīng)的配置內(nèi)容洁墙,主要就是項目路徑的位置和靜態(tài)文件的路徑。