我正在尝试在 Ubuntu 12.04 上配置带有 django 的 apache。我使用的是 mod_wsgi。我使用了几个不同的教程,但没有一个对我完全有用。沮丧的是,我安装了 nginx 而没有删除 Apache。尝试配置 nginx。失败。删除了 nginx。现在我又回来尝试配置 Apache。但是,我收到此错误:
Forbidden
You don't have permission to access / on this server.
Apache/2.2.22 (Ubuntu) Server at localhost Port 80
任何帮助都将不胜感激。此外,如果有人有使用 Django 配置 Apache 的经验并能帮助我,我将不胜感激。如果您需要 error.log,请告诉我,我会将其粘贴在这里。如果您好奇的话,我将 Apache 作为 lamp 堆栈的一部分安装。
如果有人知道对他们有用的教程,请粘贴网址。我注意到我做的很多教程都很旧了,而 django 是一个快速发展的框架。
以下是 var/www 的权限:
drwxr-xr-x 14 root root 4096 Jun 16 15:43 var
drwxr-xr-x 5 maahd maahd 4096 May 29 14:20 www
-rwxr-xr-x 1 maahd maahd 580 Mar 27 17:01 ajax.php
-rwxr-xr-x 1 maahd maahd 177 Feb 15 05:08 index.html
drwxr-xr-x 2 maahd maahd 4096 Apr 24 12:35 phploginsession
-rwxr-xr-x 1 maahd maahd 1356 Apr 21 14:24 sftp-config.json
-rwxr-xr-x 1 maahd maahd 18 Mar 12 14:03 test1.php
drwxr-xr-x 5 maahd maahd 4096 Apr 22 13:49 upload
/etc/apache2/httpd.conf 的内容:
ServerName localhost
LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias / /var/www/sp-django-master/mysite/wsgi.py
WSGIPythonPath /var/www/sp-django-master/
<Directory /var/www/sp-django-master/mysite>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
更新:当我尝试重新启动服务器时出现此错误:
* Restarting web server apache2 /usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
[Tue Jun 17 00:09:53 2014] [warn] module wsgi_module is already loaded, skipping
/usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
[Tue Jun 17 00:09:53 2014] [warn] module wsgi_module is already loaded, skipping
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
lsof -i -P -n | grep 80 的输出
ubuntu-ge 2603 maahd 12u IPv4 17608 0t0 TCP 10.27.168.45:48144->91.189.94.25:80 (CLOSE_WAIT)
chrome 2608 maahd 14u IPv4 54104 0t0 TCP 10.27.168.45:42019->198.252.206.24:80 (ESTABLISHED)
chrome 2608 maahd 89u IPv4 52215 0t0 TCP 10.27.168.45:36980->174.132.123.98:80 (ESTABLISHED)
chrome 2608 maahd 101u IPv4 40423 0t0 TCP 10.27.168.45:46129->82.148.98.157:80 (ESTABLISHED)
chrome 2608 maahd 125u IPv4 38434 0t0 TCP 10.27.168.45:42661->95.172.94.14:80 (ESTABLISHED)
chrome 2608 maahd 127u IPv4 55498 0t0 TCP 10.27.168.45:37574->198.252.206.140:80 (ESTABLISHED)
chrome 2608 maahd 135u IPv4 38439 0t0 TCP 10.27.168.45:58174->212.77.199.218:80 (ESTABLISHED)
chrome 2608 maahd 142u IPv4 52860 0t0 TCP 10.27.168.45:36982->174.132.123.98:80 (ESTABLISHED)
chrome 2608 maahd 143u IPv4 54393 0t0 TCP 10.27.168.45:39455->54.230.158.198:80 (ESTABLISHED)
chrome 2608 maahd 144u IPv4 37728 0t0 TCP 10.27.168.45:59387->23.21.122.50:80 (ESTABLISHED)
chrome 2608 maahd 151u IPv4 56723 0t0 TCP 10.27.168.45:53436->69.167.156.26:80 (ESTABLISHED)
chrome 2608 maahd 153u IPv4 52863 0t0 TCP 10.27.168.45:36983->174.132.123.98:80 (ESTABLISHED)
chrome 2608 maahd 156u IPv4 40510 0t0 TCP 10.27.168.45:59386->23.21.122.50:80 (ESTABLISHED)
chrome 2608 maahd 158u IPv4 52866 0t0 TCP 10.27.168.45:36984->174.132.123.98:80 (ESTABLISHED)
chrome 2608 maahd 163u IPv4 53439 0t0 TCP 10.27.168.45:36985->174.132.123.98:80 (ESTABLISHED)
chrome 2608 maahd 180u IPv4 56642 0t0 TCP 10.27.168.45:60257->204.154.111.229:80 (ESTABLISHED)
chrome 2608 maahd 190u IPv4 54527 0t0 TCP 10.27.168.45:53437->69.167.156.26:80 (ESTABLISHED)
chrome 2608 maahd 191u IPv4 54530 0t0 TCP 10.27.168.45:53438->69.167.156.26:80 (ESTABLISHED)
chrome 2608 maahd 196u IPv4 53442 0t0 TCP 10.27.168.45:36986->174.132.123.98:80 (ESTABLISHED)
chrome 2608 maahd 197u IPv4 54972 0t0 TCP 10.27.168.45:60821->174.129.25.157:80 (ESTABLISHED)
chrome 2608 maahd 198u IPv4 56691 0t0 TCP 10.27.168.45:60510->103.245.222.184:80 (ESTABLISHED)
chrome 2608 maahd 200u IPv4 53283 0t0 TCP 10.27.168.45:46474->103.31.6.34:80 (ESTABLISHED)
chrome 2608 maahd 202u IPv4 54505 0t0 TCP 10.27.168.45:36913->198.252.206.17:80 (ESTABLISHED)
chrome 2608 maahd 203u IPv4 53458 0t0 TCP 10.27.168.45:51691->173.194.35.121:80 (ESTABLISHED)
chrome 2608 maahd 206u IPv4 54119 0t0 TCP 10.27.168.45:37694->198.252.206.140:80 (ESTABLISHED)
chrome 2608 maahd 207u IPv4 54533 0t0 TCP 10.27.168.45:53439->69.167.156.26:80 (ESTABLISHED)
chrome 2608 maahd 208u IPv4 54536 0t0 TCP 10.27.168.45:53440->69.167.156.26:80 (ESTABLISHED)
chrome 2608 maahd 212u IPv4 54539 0t0 TCP 10.27.168.45:53441->69.167.156.26:80 (ESTABLISHED)
chrome 2608 maahd 219u IPv4 53459 0t0 TCP 10.27.168.45:48985->173.194.70.95:80 (ESTABLISHED)
chrome 2608 maahd 222u IPv4 50654 0t0 TCP 10.27.168.45:42184->173.194.39.45:80 (ESTABLISHED)
chrome 2608 maahd 224u IPv4 56733 0t0 TCP 10.27.168.45:40622->69.167.143.172:80 (ESTABLISHED)
chrome 2608 maahd 225u IPv4 56738 0t0 TCP 10.27.168.45:55693->69.167.156.17:80 (ESTABLISHED)
chrome 2608 maahd 229u IPv4 55297 0t0 TCP 10.27.168.45:53901->173.194.70.121:80 (ESTABLISHED)
chrome 2608 maahd 230u IPv4 55298 0t0 TCP 10.27.168.45:56802->185.31.19.192:80 (ESTABLISHED)
chrome 2608 maahd 233u IPv4 54317 0t0 TCP 10.27.168.45:55758->82.148.102.4:80 (ESTABLISHED)
chrome 2608 maahd 234u IPv4 52224 0t0 TCP 10.27.168.45:55410->212.77.199.224:80 (ESTABLISHED)
chrome 2608 maahd 235u IPv4 52878 0t0 TCP 10.27.168.45:48986->173.194.70.95:80 (ESTABLISHED)
chrome 2608 maahd 236u IPv4 56734 0t0 TCP 10.27.168.45:40623->69.167.143.172:80 (ESTABLISHED)
chrome 2608 maahd 238u IPv4 55302 0t0 TCP 10.27.168.45:57066->173.194.70.156:80 (ESTABLISHED)
chrome 2608 maahd 241u IPv4 52920 0t0 TCP 10.27.168.45:32969->184.26.200.117:80 (ESTABLISHED)
chrome 2608 maahd 242u IPv4 53479 0t0 TCP 10.27.168.45:47444->173.194.39.57:80 (ESTABLISHED)
chrome 2608 maahd 244u IPv4 52932 0t0 TCP 10.27.168.45:37250->54.229.19.41:80 (ESTABLISHED)
chrome 2608 maahd 245u IPv4 52933 0t0 TCP 10.27.168.45:37251->54.229.19.41:80 (ESTABLISHED)
chrome 2608 maahd 246u IPv4 55312 0t0 TCP 10.27.168.45:33604->72.14.248.34:80 (ESTABLISHED)
chrome 2608 maahd 247u IPv4 53491 0t0 TCP 10.27.168.45:35331->46.137.72.128:80 (ESTABLISHED)
chrome 2608 maahd 248u IPv4 55319 0t0 TCP 10.27.168.45:35120->173.194.39.60:80 (ESTABLISHED)
chrome 2608 maahd 249u IPv4 55323 0t0 TCP 10.27.168.45:53178->68.67.176.5:80 (ESTABLISHED)
chrome 2608 maahd 250u IPv4 55324 0t0 TCP 10.27.168.45:52934->173.194.35.122:80 (ESTABLISHED)
chrome 2608 maahd 253u IPv4 53495 0t0 TCP 10.27.168.45:33537->23.209.148.46:80 (ESTABLISHED)
chrome 2608 maahd 254u IPv4 53497 0t0 TCP 10.27.168.45:55903->68.67.176.7:80 (ESTABLISHED)
chrome 2608 maahd 256u IPv4 54707 0t0 TCP 10.27.168.45:34135->207.241.148.80:80 (ESTABLISHED)
chrome 2608 maahd 257u IPv4 54710 0t0 TCP 10.27.168.45:56075->207.241.148.91:80 (ESTABLISHED)
chrome 2608 maahd 258u IPv4 55335 0t0 TCP 10.27.168.45:40919->176.34.138.156:80 (ESTABLISHED)
chrome 2608 maahd 259u IPv4 55603 0t0 TCP 10.27.168.45:37944->23.57.207.139:80 (ESTABLISHED)
chrome 2608 maahd 260u IPv4 55392 0t0 TCP 10.27.168.45:60212->204.154.111.229:80 (ESTABLISHED)
chrome 2608 maahd 261u IPv4 53523 0t0 TCP 10.27.168.45:57086->173.194.35.123:80 (ESTABLISHED)
chrome 2608 maahd 263u IPv4 55796 0t0 TCP 10.27.168.45:49590->173.194.36.30:80 (ESTABLISHED)
chrome 2608 maahd 266u IPv4 56465 0t0 TCP 10.27.168.45:60215->204.11.109.63:80 (ESTABLISHED)
chrome 2608 maahd 267u IPv4 53535 0t0 TCP 10.27.168.45:60216->204.11.109.63:80 (ESTABLISHED)
chrome 2608 maahd 268u IPv4 54606 0t0 TCP 10.27.168.45:46405->72.32.216.176:80 (ESTABLISHED)
chrome 2608 maahd 269u IPv4 54368 0t0 TCP 10.27.168.45:60217->204.11.109.63:80 (ESTABLISHED)
chrome 2608 maahd 270u IPv4 54345 0t0 TCP 10.27.168.45:52943->173.194.35.122:80 (ESTABLISHED)
chrome 2608 maahd 271u IPv4 54715 0t0 TCP 10.27.168.45:41601->212.77.199.209:80 (ESTABLISHED)
chrome 2608 maahd 272u IPv4 54711 0t0 TCP 10.27.168.45:56076->207.241.148.91:80 (ESTABLISHED)
chrome 2608 maahd 274u IPv4 55419 0t0 TCP 10.27.168.45:45195->54.225.240.90:80 (ESTABLISHED)
chrome 2608 maahd 275u IPv4 54394 0t0 TCP 10.27.168.45:37274->54.229.19.41:80 (ESTABLISHED)
chrome 2608 maahd 277u IPv4 54712 0t0 TCP 10.27.168.45:56077->207.241.148.91:80 (ESTABLISHED)
chrome 2608 maahd 278u IPv4 54395 0t0 TCP 10.27.168.45:37275->54.229.19.41:80 (ESTABLISHED)
chrome 2608 maahd 279u IPv4 54398 0t0 TCP 10.27.168.45:37276->54.229.19.41:80 (ESTABLISHED)
chrome 2608 maahd 280u IPv4 54401 0t0 TCP 10.27.168.45:37277->54.229.19.41:80 (ESTABLISHED)
chrome 2608 maahd 281u IPv4 53609 0t0 TCP 10.27.168.45:55790->82.148.102.4:80 (ESTABLISHED)
chrome 2608 maahd 282u IPv4 53612 0t0 TCP 10.27.168.45:55791->82.148.102.4:80 (ESTABLISHED)
chrome 2608 maahd 284u IPv4 56536 0t0 TCP 10.27.168.45:43291->173.192.220.64:80 (ESTABLISHED)
chrome 2608 maahd 285u IPv4 56538 0t0 TCP 10.27.168.45:36253->67.217.177.158:80 (ESTABLISHED)
chrome 2608 maahd 286u IPv4 56537 0t0 TCP 10.27.168.45:33714->54.255.156.221:80 (ESTABLISHED)
chrome 2608 maahd 287u IPv4 55426 0t0 TCP 10.27.168.45:49253->12.129.199.106:80 (ESTABLISHED)
chrome 2608 maahd 288u IPv4 55428 0t0 TCP 10.27.168.45:53623->54.246.112.221:80 (ESTABLISHED)
chrome 2608 maahd 289u IPv4 54409 0t0 TCP 10.27.168.45:54767->54.225.133.14:80 (ESTABLISHED)
chrome 2608 maahd 290u IPv4 54408 0t0 TCP 10.27.168.45:52682->138.108.6.20:80 (ESTABLISHED)
chrome 2608 maahd 291u IPv4 55430 0t0 TCP 10.27.168.45:42689->82.148.117.35:80 (ESTABLISHED)
chrome 2608 maahd 292u IPv4 56566 0t0 TCP 10.27.168.45:35605->212.77.199.225:80 (ESTABLISHED)
chrome 2608 maahd 293u IPv4 54713 0t0 TCP 10.27.168.45:56078->207.241.148.91:80 (ESTABLISHED)
chrome 2608 maahd 294u IPv4 54419 0t0 TCP 10.27.168.45:35504->67.217.177.164:80 (ESTABLISHED)
chrome 2608 maahd 295u IPv4 54426 0t0 TCP 10.27.168.45:48218->79.125.12.28:80 (ESTABLISHED)
chrome 2608 maahd 296u IPv4 56616 0t0 TCP 10.27.168.45:51809->50.19.233.13:80 (ESTABLISHED)
chrome 2608 maahd 297u IPv4 53649 0t0 TCP 10.27.168.45:56653->176.32.100.68:80 (ESTABLISHED)
chrome 2608 maahd 298u IPv4 53657 0t0 TCP 10.27.168.45:50796->54.197.240.229:80 (ESTABLISHED)
chrome 2608 maahd 300u IPv4 56604 0t0 TCP 10.27.168.45:42187->204.2.197.204:80 (ESTABLISHED)
chrome 2608 maahd 301u IPv4 56605 0t0 TCP 10.27.168.45:57379->103.15.158.208:80 (ESTABLISHED)
chrome 2608 maahd 302u IPv4 56602 0t0 TCP 10.27.168.45:57663->216.151.217.153:80 (ESTABLISHED)
chrome 2608 maahd 303u IPv4 56603 0t0 TCP 10.27.168.45:47493->173.194.39.57:80 (ESTABLISHED)
chrome 2608 maahd 304u IPv4 55452 0t0 TCP 10.27.168.45:55995->8.30.11.13:80 (ESTABLISHED)
chrome 2608 maahd 305u IPv4 56606 0t0 TCP 10.27.168.45:36411->74.121.141.85:80 (ESTABLISHED)
chrome 2608 maahd 306u IPv4 53669 0t0 TCP 10.27.168.45:45043->173.193.208.135:80 (ESTABLISHED)
chrome 2608 maahd 307u IPv4 55457 0t0 TCP 10.27.168.45:45041->173.193.208.135:80 (ESTABLISHED)
chrome 2608 maahd 308u IPv4 54611 0t0 TCP 10.27.168.45:51100->173.194.35.124:80 (ESTABLISHED)
chrome 2608 maahd 309u IPv4 56622 0t0 TCP 10.27.168.45:45044->173.193.208.135:80 (ESTABLISHED)
chrome 2608 maahd 310u IPv4 55462 0t0 TCP 10.27.168.45:45045->173.193.208.135:80 (ESTABLISHED)
chrome 2608 maahd 312u IPv4 54714 0t0 TCP 10.27.168.45:56079->207.241.148.91:80 (ESTABLISHED)
chrome 2608 maahd 318u IPv4 56879 0t0 TCP 10.27.168.45:34118->54.230.44.48:80 (ESTABLISHED)
chrome 2608 maahd 319u IPv4 56870 0t0 TCP 10.27.168.45:33321->124.155.223.9:80 (ESTABLISHED)
chrome 2608 maahd 320u IPv4 54721 0t0 TCP 10.27.168.45:47567->198.232.124.97:80 (ESTABLISHED)
chrome 2608 maahd 323u IPv4 54726 0t0 TCP 10.27.168.45:57200->173.194.70.156:80 (ESTABLISHED)
chrome 2608 maahd 324u IPv4 54618 0t0 TCP 10.27.168.45:58544->68.232.35.139:80 (ESTABLISHED)
chrome 2608 maahd 326u IPv4 56185 0t0 TCP 10.27.168.45:42469->173.194.70.120:80 (ESTABLISHED)
chrome 2608 maahd 331u IPv4 53899 0t0 TCP 10.27.168.45:57801->173.194.39.58:80 (ESTABLISHED)
chrome 2608 maahd 334u IPv4 53904 0t0 TCP 10.27.168.45:35261->209.114.44.42:80 (ESTABLISHED)
chrome 2608 maahd 335u IPv4 55754 0t0 TCP 10.27.168.45:52672->198.41.191.38:80 (ESTABLISHED)
chrome 2608 maahd 336u IPv4 55755 0t0 TCP 10.27.168.45:38502->50.17.239.15:80 (ESTABLISHED)
chrome 2608 maahd 337u IPv4 53915 0t0 TCP 10.27.168.45:38503->50.17.239.15:80 (ESTABLISHED)
chrome 2608 maahd 338u IPv4 53919 0t0 TCP 10.27.168.45:56606->68.67.176.10:80 (ESTABLISHED)
chrome 2608 maahd 339u IPv4 54691 0t0 TCP 10.27.168.45:38505->50.17.239.15:80 (ESTABLISHED)
chrome 2608 maahd 340u IPv4 54694 0t0 TCP 10.27.168.45:56608->68.67.176.10:80 (ESTABLISHED)
chrome 2608 maahd 341u IPv4 55761 0t0 TCP 10.27.168.45:38507->50.17.239.15:80 (ESTABLISHED)
chrome 2608 maahd 342u IPv4 55764 0t0 TCP 10.27.168.45:56610->68.67.176.10:80 (ESTABLISHED)
chrome 2608 maahd 343u IPv4 55767 0t0 TCP 10.27.168.45:38509->50.17.239.15:80 (ESTABLISHED)
chrome 2608 maahd 344u IPv4 55770 0t0 TCP 10.27.168.45:56612->68.67.176.10:80 (ESTABLISHED)
chrome 2608 maahd 345u IPv4 56904 0t0 TCP 10.27.168.45:38511->50.17.239.15:80 (ESTABLISHED)
chrome 2608 maahd 346u IPv4 56909 0t0 TCP 10.27.168.45:56614->68.67.176.10:80 (ESTABLISHED)
chrome 2608 maahd 350u IPv4 53956 0t0 TCP 10.27.168.45:56098->207.241.148.91:80 (ESTABLISHED)
chrome 2608 maahd 351u IPv4 53957 0t0 TCP 10.27.168.45:56099->207.241.148.91:80 (ESTABLISHED)
chrome 2608 maahd 352u IPv4 54733 0t0 TCP 10.27.168.45:56100->207.241.148.91:80 (ESTABLISHED)
chrome 2608 maahd 353u IPv4 54742 0t0 TCP 10.27.168.45:58587->212.77.199.218:80 (ESTABLISHED)
chrome 2608 maahd 354u IPv4 54776 0t0 TCP 10.27.168.45:33485->23.50.80.143:80 (ESTABLISHED)
chrome 2608 maahd 357u IPv4 53988 0t0 TCP 10.27.168.45:55974->54.86.224.50:80 (ESTABLISHED)
chrome 2608 maahd 358u IPv4 57033 0t0 TCP 10.27.168.45:47468->71.19.242.237:80 (ESTABLISHED)
chrome 2608 maahd 360u IPv4 55863 0t0 TCP 10.27.168.45:55570->212.77.199.224:80 (ESTABLISHED)
chrome 2608 maahd 361u IPv4 55865 0t0 TCP 10.27.168.45:57307->94.100.23.179:80 (ESTABLISHED)
chrome 2608 maahd 362u IPv4 55864 0t0 TCP 10.27.168.45:55571->212.77.199.224:80 (ESTABLISHED)
chrome 2608 maahd 363u IPv4 55866 0t0 TCP 10.27.168.45:57308->94.100.23.179:80 (ESTABLISHED)
chrome 2608 maahd 364u IPv4 55867 0t0 TCP 10.27.168.45:57309->94.100.23.179:80 (ESTABLISHED)
chrome 2608 maahd 365u IPv4 55868 0t0 TCP 10.27.168.45:57310->94.100.23.179:80 (ESTABLISHED)
chrome 2608 maahd 366u IPv4 55885 0t0 TCP 10.27.168.45:57801->8.39.37.21:80 (ESTABLISHED)
chrome 2608 maahd 367u IPv4 57077 0t0 TCP 10.27.168.45:57802->8.39.37.21:80 (ESTABLISHED)
chrome 2608 maahd 368u IPv4 54018 0t0 TCP 10.27.168.45:37895->82.199.80.141:80 (ESTABLISHED)
chrome 2608 maahd 369u IPv4 54017 0t0 TCP 10.27.168.45:42423->173.194.39.45:80 (ESTABLISHED)
chrome 2608 maahd 370u IPv4 54781 0t0 TCP 10.27.168.45:49062->54.228.249.4:80 (ESTABLISHED)
chrome 2608 maahd 371u IPv4 54026 0t0 TCP 10.27.168.45:35730->212.77.199.225:80 (ESTABLISHED)
chrome 2608 maahd 373u IPv4 54028 0t0 TCP 10.27.168.45:40050->212.77.199.208:80 (ESTABLISHED)
chrome 2608 maahd 374u IPv4 54033 0t0 TCP 10.27.168.45:43144->69.25.24.26:80 (ESTABLISHED)
chrome 2608 maahd 378u IPv4 54041 0t0 TCP 10.27.168.45:39493->8.39.37.25:80 (ESTABLISHED)
chrome 2608 maahd 379u IPv4 54046 0t0 TCP 10.27.168.45:43429->71.19.244.184:80 (ESTABLISHED)
谢谢
答案1
您的内容正尝试用完/home/maahd/development/django/sp-django-master
,但运行 Apache 的用户(www-data
Ubuntu 上的默认用户)无权访问。
最有可能的是它甚至无法遍历到您的用户的主目录,您应该将该目录移动到它可以访问的地方(并相应地重新配置),而不是破坏您的主目录的权限。