我浏览了无数帖子,但似乎找不到答案。我在 ubuntu 22.04 上使用 apache。我可以打开“https://webapp.sb.sf.org”,但我只希望别名能够正常工作,即“ht...
我浏览了无数帖子,但似乎找不到答案。我在 ubuntu 22.04 上使用 apache。我可以打开“https://webapp.sb.sf.org”,但我只希望别名能够工作,即“https://webapp”。当我在浏览器中打开“https://webapp”时,我在网页上收到以下消息 Invalid host_name configuration。error.log 中没有显示任何错误,access.log 下也没有任何有用的信息,即使我将 LogLevel 设置为调试。DNS 工作正常,我可以解析短名称“webapp”和 fqdn“webapp.sb.sf.org”。我已配置反向代理。发现一些帖子说别名无法与反向代理一起使用,但解决方案不起作用。这是我的配置
Include /etc/webapp/addons/apache2/includes/server/*.conf
IncludeOptional /etc/webapp/addons/apache2/custom/server/*.conf
LogLevel debug
<VirtualHost *:80>
ServerName webapp.sb.sf.org
ServerAlias webapp
RewriteEngine On
RewriteRule ^/?(.*) https://%{SERVER_NAME}:443/$1 [R,L]
</VirtualHost>
<VirtualHost *:443>
ServerName webapp.sb.sf.org
ServerAlias webapp
DocumentRoot /opt/webapp/public
ProxyRequests off
ProxyPreserveHost On
Include /etc/webapp/addons/apache2/includes/vhost/*.conf
IncludeOptional /etc/webapp/addons/apache2/custom/vhost/*.conf
# Can't use Location block since it would overshadow all the other proxypass directives on CentOS
ProxyPass / http://127.0.0.1:6000/ retry=0
ProxyPassReverse / http://127.0.0.1:6000/
</VirtualHost>
我在尝试使用 Ubuntu 服务器上的 Apache 部署我的 Django 网站时遇到了困难。以下是问题的详细信息:错误消息:当前线程 0x00007e9faacab780(大多数
我在尝试使用 Ubuntu 服务器上的 Apache 部署 Django 网站时遇到了困难。以下是问题的详细信息:
错误消息:
Current thread 0x00007e9faacab780 (most recent call first):
<no Python frame>
[Thu Jun 27 02:58:10.538441 2024] [wsgi:warn] [pid 16762:tid 139224230311808] (13)Permission denied: mod_wsgi (pid=16762): Unable to stat Python home /home/robch/TestSite/django_env. Python interpreter may not be able to be initialized correctly. Verify the supplied path and access permissions for whole of the path.
Python path configuration:
PYTHONHOME = '/home/robch/TestSite/django_env'
PYTHONPATH = (not set)
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
当我进入我的页面时,看到错误 403:
以下是有关我的文件的更多信息:
(django_env) robch@django-server:~$ ls -la
total 44
drwxr-x--- 6 robch robch 4096 Jun 27 01:44 .
drwxr-xr-x 3 root root 4096 Jun 26 21:58 ..
-rw------- 1 robch robch 1102 Jun 27 00:08 .bash_history
-rw-r--r-- 1 robch robch 220 Jun 26 21:58 .bash_logout
-rw-r--r-- 1 robch robch 3771 Jun 26 21:58 .bashrc
drwx------ 3 robch robch 4096 Jun 26 23:45 .cache
-rw------- 1 robch robch 20 Jun 27 01:44 .lesshst
drwxrwxr-x 3 robch robch 4096 Jun 26 22:21 .local
-rw-r--r-- 1 robch robch 807 Jun 26 21:58 .profile
drwx------ 2 robch robch 4096 Jun 26 22:56 .ssh
-rw-r--r-- 1 robch robch 0 Jun 26 22:43 .sudo_as_admin_successful
drwxrwxr-x 13 robch www-data 4096 Jun 27 02:51 TestSite
(django_env) robch@django-server:~$ cd TestSite/ && ls -la
total 300
drwxrwxr-x 13 robch www-data 4096 Jun 27 02:51 .
drwxr-x--- 6 robch robch 4096 Jun 27 01:44 ..
drwxrwxr-x 8 robch robch 4096 Jun 26 23:47 .git
-rw-rw-r-- 1 robch robch 6 Jun 26 23:39 README.md
drwxrwxr-x 3 robch robch 4096 Jun 27 02:23 Soundrise
drwxrwxr-x 5 robch robch 4096 Jun 26 23:39 accounts
drwxrwxr-x 4 robch robch 4096 Jun 26 23:39 beatmakers
drwxrwxr-x 5 robch robch 4096 Jun 26 23:39 beats
drwxrwxr-x 4 robch robch 4096 Jun 26 23:39 content
-rw-rw-r-- 1 robch www-data 241664 Jun 27 00:59 db.sqlite3
drwxrwxr-x 5 www-data www-data 4096 Jun 27 02:51 django_env
drwxrwxr-x 5 robch robch 4096 Jun 26 23:39 files
-rw-rw-r-- 1 robch robch 665 Jun 26 23:39 manage.py
-rw-rw-r-- 1 robch robch 80 Jun 26 23:47 requirements.txt
drwxr-xr-x 4 www-data www-data 4096 Jun 26 23:56 static
drwxrwxr-x 4 robch robch 4096 Jun 26 23:39 transaction
drwxrwxr-x 4 robch robch 4096 Jun 26 23:39 utils
(django_env) robch@django-server:~/TestSite$ cat /etc/apache2/sites-enabled/TestSite.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName 85.215.209.167
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
Alias /static /home/robch/TestSite/static
<Directory /home/robch/TestSite/static>
Require all granted
</Directory>
Alias /media /home/robch/TestSite/files/media
<Directory /home/robch/TestSite/files/media>
Require all granted
</Directory>
<Directory /home/robch/TestSite/Soundrise>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIScriptAlias / /home/robch/TestSite/Soundrise/wsgi.py
WSGIDaemonProcess django_app python-home=/home/robch/TestSite/django_env python-path=/home/robch/TestSite
WSGIProcessGroup django_app
</VirtualHost>
(django_env) robch@django-server:~/TestSite$
采取的步骤:
请求协助:
我怎样才能让我的网站最终显示出来。
我应该采取什么步骤来确保虚拟环境中的 Python 具有所有必要的模块,尤其是“编码”?