###前提・実現したいこと
MAMP Ver3.5
macOS Sierra 10.12.4
Zend Framework 2
【Zend Framework 2 入門】Zend Framework 2 でHelloWorldが出るまで
を参考にMAMPにてZend Framework 2を動作させたい.
###発生している問題・エラーメッセージ
実際にアクセスするとWelcome to Zend Framework 2が出ず,HTTP ERROR 500となり,サーバーにエラーが起きている.
apache_error.logは以下のとおりです.
[Sun Apr 30 13:00:02 2017] [notice] caught SIGTERM, shutting down [Sun Apr 30 13:00:08 2017] [notice] Digest: generating secret for digest authentication ... [Sun Apr 30 13:00:08 2017] [notice] Digest: done [Sun Apr 30 13:00:08 2017] [notice] FastCGI: process manager initialized (pid 46914) [Sun Apr 30 13:00:08 2017] [notice] Apache/2.2.29 (Unix) mod_wsgi/3.5 Python/2.7.10 PHP/7.0.0 mod_ssl/2.2.29 OpenSSL/0.9.8zh DAV/2 mod_fastcgi/2.4.6 mod_perl/2.0.9 Perl/v5.22.0 configured -- resuming normal operations
設定
Helloworld>public>index.php の内容は以下のとおりですがこれであっているのでしょうか?(上に貼り付けるの意味がわからない)
※ユーザーネームはしっかり設定してあります.
<?php $paths = array("/Users/USERNAME/zend/ZendFramework-2.4.11/library","."); set_include_path(implode(PATH_SEPARATOR, $paths)); // ライブラリ本体へのパスを指定 $path ="/Users/USERNAME/zend/ZendFramework-2.4.11/library"; // 環境変数を追加 putenv("ZF2_PATH=".$path); use Zend\Mvc\Application; use Zend\Stdlib\ArrayUtils; /** * This makes our life easier when dealing with paths. Everything is relative * to the application root now. */ chdir(dirname(__DIR__)); // Decline static file requests back to the PHP built-in webserver if (php_sapi_name() === 'cli-server') { $path = realpath(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)); if (__FILE__ !== $path && is_file($path)) { return false; } unset($path); } // Composer autoloading include __DIR__ . '/../vendor/autoload.php'; if (! class_exists(Application::class)) { throw new RuntimeException( "Unable to load application.\n" . "- Type `composer install` if you are developing locally.\n" . "- Type `vagrant ssh -c 'composer install'` if you are using Vagrant.\n" . "- Type `docker-compose run zf composer install` if you are using Docker.\n" ); } // Retrieve configuration $appConfig = require __DIR__ . '/../config/application.config.php'; if (file_exists(__DIR__ . '/../config/development.config.php')) { $appConfig = ArrayUtils::merge($appConfig, require __DIR__ . '/../config/development.config.php'); } // Run the application! Application::init($appConfig)->run();
また,.htaccessはデフォルトで以下の通りです.(設定方法がよくわかりません)
RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [L] RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ RewriteRule ^(.*) - [E=BASE:%1] RewriteRule ^(.*)$ %{ENV:BASE}/index.php [L]
ちなみに,CakePHP3では以下で正常に動作しています.
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule>
よろしくお願いいたします.
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/04/30 04:04
2017/05/01 01:47