UbuntuにDjangoとApache2.4をインストールし、サイトを動かそうとしています。
Djangoでexample1とexample2という別のプロジェクトを作成し、それぞれを一つのApache上で動かしたいのですが、片方ずつしか動かせない状態です。
/etc/apache2/sites-available/django.conf
以上の場所にdjango.confというファイルを作成し、Apacheの設定を行いました。
django.conf
1<VirtualHost *:80> 2ServerName example1 3WSGIDaemonProcess project1 python-home=/usr python-path=/home/path/to/directory 4WSGIProcessGroup project1 5WSGIScriptAlias / /home/path/to/wsgi.py process-group=project1 6<Directory /home/path/to/directory> 7 <Files wsgi.py> 8 Require all granted 9 </Files> 10</Directory> 11 12Alias /static/ /home/path/to/static/ 13<Directory /home/path/to/static> 14 Require all granted 15</Directory> 16</VirtualHost> 17 18<VirtualHost *:80> 19ServerName example2 20WSGIDaemonProcess project2 python-home=/usr python-path=/home/path/to/directory 21WSGIProcessGroup project2 22WSGIScriptAlias / /home/path/to/wsgi.py process-group=project2 23<Directory /home/path/to/directory> 24 <Files wsgi.py> 25 Require all granted 26 </Files> 27</Directory> 28 29Alias /static/ /home/path/to/static/ 30<Directory /home/path/to/static> 31 Require all granted 32</Directory> 33</VirtualHost>
パスはそれぞれのプロジェクトの正しいパスを書いています。
しかし、上記の設定でサイトにアクセスすると、example1は表示されるのですが、example2はDjangoのPageNotFoundエラーの画面が返ってきます。
エラー内容を確認すると、example1のurls.pyを見ているようで、example2が認識されていません。
django.confファイルを、django1.confファイルとdjango2.confファイルに分割し、それぞれをa2ensite
で有効化してみたのですが、そうしたところ、exmaple2は表示される一方で、exmaple1はDjangoのPageNotFoundエラーの画面が表示されました。エラー内容も、先ほどまでのエラー内容と同じでした。
どのように設定すれば、両方とも動かすことができるのでしょうか?
ご教示いただけますと幸いです。よろしくお願いいたします。
あなたの回答
tips
プレビュー