gpt4 book ai didi

PHP API 无法在 apache2 Ubuntu 服务器上使用 Django |谷歌云

转载 作者:行者123 更新时间:2023-12-04 18:39:43 25 4
gpt4 key购买 nike

我已经成功地在 上的 Linux Ubuntu 机器上的 apache2 Web 服务器上部署了一个 Django 项目。谷歌云 .它工作正常。此外,我有与 MySQL 数据库连接的 PHP API,与 Django 连接的相同。但问题是 Django 应用程序工作正常而 PHP API 不工作。

我还放置了index.html我的 /var/www/html/api_folder/index.php 中的页面小路。所以当我输入 my_ip/api_folder在浏览器中打开 index.html页面,但 API 不工作。 api 文件位于 api_folderindex.html页。

下面是我在 apache2 的/sites-available 目录中的 conf 文件。即使是基本的 PHP 文件也可以工作并在 echo 中打印消息。 但是当我输入 My_ip/api_folder/api/get_about_us/?key=xxxx它向我显示 404 错误页面。

<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 www.example.com

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
Alias /api_folder /var/www/html/api_folder
<Directory /var/www/html/api_folder>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
Allow from all
</Directory>

# 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/my_user/spinner/static
<Directory /home/my_user/spinner/static>
Require all granted
</Directory>

Alias /media /home/my_user/spinner/media
<Directory /home/my_user/spinner/static/media>
Require all granted
</Directory>

<Directory /home/my_user/spinner/spinner>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

WSGIScriptAlias / /home/my_user/spinner/spinner/wsgi.py
WSGIDaemonProcess spinner_app python-path=/home/my_user/spinner python-home=/home/my_user/venv_spinner
WSGIProcessGroup spinner_app



</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

最佳答案

您可能在 .htaccess 文件中有问题。请检查 .htaccess 文件一次。

确保您已启用 apache2 重写规则。
运行以下命令来做到这一点:

sudo a2enmod rewrite
sudo service apache2 restart

关于PHP API 无法在 apache2 Ubuntu 服务器上使用 Django |谷歌云,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59298700/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com