5

Zend プロジェクトをサーバーにデプロイすることについて質問があります。localhost では、仮想ホストを使用してドキュメント ルートを public/index.php フォルダーに設定しました。

  • 今すぐデプロイするにはどうすればよいですか? プロジェクト全体をサーバーにコピーしましたが、すべてのパスが間違っているため機能しません (すべてがパブリック フォルダーに対して相対的に設定されているため)。
  • 私は何をすべきか?サーバー上のホーム パスに関連するすべてのパスを設定することは可能ですか? この状況でアプリケーションを任意のコントローラーにリダイレクトするにはどうすればよいですか? または、サーバー上に仮想ホストを作成する必要があるだけかもしれませんが、それを行う権限がありません:/?

アドバイスが必要です、ありがとう


アプリケーション.ini:

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"


resources.view[] =

resources.db.isDefaultTableAdapter = true
resources.db.adapter = PDO_MYSQL
resources.db.params.charset = "utf8"
resources.db.params.host = HOST
resources.db.params.username = "p"
resources.db.params.password = "***"
resources.db.params.dbname = "p"

[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

Index.php:

<?php

// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

defined('DESTINATION_IMAGES') || define('DESTINATION_IMAGES', './usersImages/');
defined('TRUE_STORY_EMAIL') || define('TRUE_STORY_EMAIL', 'mmm@gmail.com');
defined('TRUE_STORY_NAME') || define('TRUE_STORY_NAME', 'True story team');

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path(),
)));

/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'

);
$application->bootstrap()
            ->run();

.htaccss:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

phpinfo();

w ロードされたモジュール mod_rewrite があるので、おそらく有効になっています。

------------------------------

--------編集 04.05.2011 -----

サーバーにプロジェクトをもう一度デプロイし、RewriteBase /~user2/Project2/public を設定しました

そして今、URL マッピングが機能しています (おそらく、初めてデプロイしたときにエラーが発生したため、機能していませんでした)。

しかし、私はまだプロジェクトに問題があります。Authコントローラーに行くと:

public function indexAction() {
        // action body

        $form = new Application_Form_Login();
        $request = $this->getRequest();
        if ($request->isPost()) {
            if ($form->isValid($request->getPost())) {
                try {
                    if ($this->_process($form->getValues())) {
                        $userDT = new Application_Model_DbTable_User();
                        $idUser = Zend_Auth::getInstance()->getIdentity()->id;
                        if ($userDT->isConfirmed($idUser)) {
                            $this->_helper->redirector->gotoRoute(
                                    array(
                                        'controller' => 'index',
                                        'action' => 'index'
                                    )
                            );
                        } else {
                            $form->setDescription('Your account is not confirmed!');
                            Zend_Auth::getInstance()->clearIdentity();
                            $this->_helper->redirector->gotoRoute(
                                    array(
                                        'controller' => 'Registration',
                                        'action' => "step",
                                        'idUser' => $idUser
                                    )
                            );
                        }
                    } else {
                        $form->setDescription('There was an error. Try to log in once again please');
                    }
                } catch (Exception $e) {
                    echo $e->getMessage();
                }
            }
        }
        $this->view->form = $form;
    } 

私が見ることができるページでは:  そして、別のコントローラーでのリダイレクトが機能していることを確認すると、それが何を意味するのかわかりません。つまり、プロジェクトが zend ライブラリを参照しているため、フォームが作成されない理由がわかりません。ビューで?

景色:

<?php $this->headTitle('Login'); ?>
<h1>Login</h1>
<?php echo $this->form->setAction($this->url()); ?>
4

1 に答える 1

2

プロジェクトをサーバーにコピーし、ドメイン ディレクトリ ポインターを public フォルダーに設定するだけです。ほとんどの場合、それでうまくいくはずです。

もう 1 つの方法は、vhostファイルをセットアップし、ドキュメント ルートを設定することです。サブドメインで zf プロジェクトにアクセスできるようにする場合は、これが必要です。

しかし、これはサーバー構成の問題です。

アプリケーション.ini:

[production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules = ''

resources.frontController.params.displayExceptions = 1
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.frontController.defaultControllerName = "home"
resources.frontController.params.prefixDefaultModule = "1"

//some db setup

[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

.htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

index.php ファイルを変更していないことを願っています。

// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path(),
)));

/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
            ->run();
于 2011-04-04T04:47:26.747 に答える