Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP API不能在apache2 Ubuntu服务器|谷歌云上与Django一起使用_Php_Django_Ubuntu_Google Cloud Platform_Apache2 - Fatal编程技术网

PHP API不能在apache2 Ubuntu服务器|谷歌云上与Django一起使用

PHP API不能在apache2 Ubuntu服务器|谷歌云上与Django一起使用,php,django,ubuntu,google-cloud-platform,apache2,Php,Django,Ubuntu,Google Cloud Platform,Apache2,我已经成功地在谷歌云上的Linux Ubuntu机器上的apache2 web服务器上部署了一个Django项目。它工作得很好。另外,我有一个PHP API,它与Django连接的MySQL数据库相连。但问题是Django应用程序运行良好,而PHP API不起作用 我还将index.html页面放在我的/var/www/html/api_文件夹/index.php路径中。因此,当我在浏览器中键入my_ip/api_folder时,它会打开index.html页面,但api不起作用。api文件位于

我已经成功地在谷歌云上的Linux Ubuntu机器上的apache2 web服务器上部署了一个Django项目。它工作得很好。另外,我有一个PHP API,它与Django连接的MySQL数据库相连。但问题是Django应用程序运行良好,而PHP API不起作用

我还将
index.html
页面放在我的
/var/www/html/api_文件夹/index.php
路径中。因此,当我在浏览器中键入
my_ip/api_folder
时,它会打开
index.html
页面,但api不起作用。api文件位于
api_文件夹中
,与
index.html
页面一样

下面是我在apache2的/sites可用目录下的conf文件。即使是基本的PHP文件也可以工作并在echo中打印消息但当我键入
我的\u ip/api\u文件夹/api/get\u about\u 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

#ServerName指令设置请求方案、主机名和端口
#服务器使用来标识自身。这在创建时使用
#重定向URL。在虚拟主机的上下文中,服务器名
#指定必须在请求的主机:标头中显示的主机名
#匹配此虚拟主机。对于默认虚拟主机(此文件),此
#该值不是决定性的,因为它被用作最后的宿主。
#但是,必须为任何其他虚拟主机显式设置它。
#服务器名www.example.com
服务器管理员webmaster@localhost
DocumentRoot/var/www/html
别名/api_文件夹/var/www/html/api_文件夹
选项索引跟随符号链接
允许超越所有
要求所有授权
通融
#可用日志级别:trace8、…、trace1、调试、信息、通知、警告、,
#错误、暴击、警报、紧急情况。
#还可以为特定应用程序配置日志级别
#模块,例如。
#日志级别信息ssl:警告
ErrorLog${APACHE_LOG_DIR}/error.LOG
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
#对于conf/available/中的大多数配置文件
#在全局级别启用或禁用,可以
#仅包含一个特定虚拟主机的行。例如
#以下行仅为此主机启用CGI配置
#在使用“A2F”全局禁用后。
#包括conf available/service-cgi-bin.conf
别名/静态/主页/我的用户/微调器/静态
要求所有授权
别名/媒体/主页/我的用户/微调器/媒体
要求所有授权
要求所有授权
WSGIScriptAlias//home/my_user/spinner/spinner/wsgi.py
WSGIDaemonProcess spinner\u app python path=/home/my\u user/spinner python home=/home/my\u user/venv\u spinner
WSGIProcessGroup微调器应用程序
#vim:syntax=apachets=4sw=4sts=4srnoet

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

确保已启用apache2重写规则。 运行以下命令以执行此操作:

sudo a2enmod rewrite
sudo service apache2 restart

这到底是一个什么样的Django问题???那么你有什么建议?删除Django标签?