使用Azure对Codeigniter部署进行故障排除 [英] Troubleshooting Codeigniter Deployment with Azure

查看:62
本文介绍了使用Azure对Codeigniter部署进行故障排除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[![在此处输入图像描述] [3]] [3] [![在此处输入图像描述] [4]] [4]我正在尝试使用Azure部署PHP应用程序。我得到显示的索引页:

解决方案

URL http://tradiscussionboard.azurewebsites.net/users/login 返回404状态代码,因此未找到。这很可能是缺少或缺少配置的重写规则的结果。在Azure上,您需要直接在根目录中包含一个 web.config 文件(相当于Apache在.htaccess文件上的IIS),该文件应直接包含:

 <?xml version = 1.0 encoding = UTF-8?> 
< configuration>
< system.webServer>
< rewrite>
< rules>
< rule name =重写为index.php>
< match url = index.php | robots.txt | images | test.php />
< action type = None />
< / rule>
< rule name =重写CI索引>
< match url =。* />
< conditions>
< add input = {REQUEST_FILENAME} pattern = css | js | jpg | jpeg | png | gif | ico | htm | html negate = true />
< / conditions>
< action type = Rewrite url = index.php / {R:0} />
< / rule>
< / rules>
< / rewrite>
< /system.webServer>
< / configuration>


[![enter image description here][3]][3][![enter image description here][4]][4]I'm trying to deploy a PHP app with Azure. I get the the index page to show up: http://phpdiscussionboard.azurewebsites.net/

But when you click login or register, the error I see is: "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."...which leads me to believe in my database.php file I am configuring it incorrectly..not sure. I have hooked up the connection with MYSQLWorkbench and when I test the connection it works. Similarly, when I change the index of my application to another view, that loads the specified template.

Here is my database.php file my applications/config

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$active_group = 'default';
$active_record = TRUE;

if(ENVIRONMENT == 'production')
{
    $db['default']['hostname'] = 'ahmxn6q9c3.database.windows.net,1433';
    $db['default']['username'] = 'username';
    $db['default']['password'] = 'password';
    $db['default']['database'] = '';
}
else
{
    $db['default']['hostname'] = 'ahmxn6q9c3.database.windows.net,1433';
    $db['default']['username'] = 'username';
    $db['default']['password'] = 'password';
    $db['default']['database'] = '';
}
$db['default']['dbdriver'] = 'sqlsrv';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

//end of database.php

The db driver only works with 'sqlsrv'. In my connection string I get from azure, it says my database is called "discussionboard"...which I named it as on purpose. However when I enter discussionboard as the default db i continue to get the error. For my Azure db page, when I click on the sql database, it tells me: Connect to your database with : Server: ahmxn6q9c3.database.windows.net,1433 For which I have that string and port as my default host. However, in the connection string it says the data source is : us-cdbr-azure-west-c.cloudapp.net

Am i configuring the whole database.php incorrectly?

I would really appreciate anyone's help that has successfully deployed a php app with mysql through azure before.

Thank you for your time

this is what i have right now....looks the same as the image you posted...am i missing something? Sorry I've never deployed a php app before.

I've tried configuring it how you said...the image below is the only way I can get the page to load with a database error..but i still get the Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid object name 'users'. even when I add a users table.

解决方案

The url http://tradiscussionboard.azurewebsites.net/users/login is returning 404 status code so it is not found. This is most likely the result of missing or miss-configured rewrite rules. On Azure you need to include a web.config file (the IIS equivalent of the .htaccess file on Apache) in the root directly that contains:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Rewrite to index.php">
                    <match url="index.php|robots.txt|images|test.php" />
                    <action type="None" />
                </rule>
                <rule name="Rewrite CI Index">
                    <match url=".*" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" pattern="css|js|jpg|jpeg|png|gif|ico|htm|html" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php/{R:0}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

这篇关于使用Azure对Codeigniter部署进行故障排除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆