ディレクトリの書込権限について

このQ&Aのポイント
  • レンタルサーバのSmartyのパーミッションでつまずいています
  • Bレンタルサーバでsmartyを利用したPHPのプログラムを設置すると書き込み権限エラーが発生しています
  • 同じパーミッションでレンタルサーバごとにエラーが出る出ないが違う理由はなんでしょうか?
回答を見る
  • ベストアンサー

ディレクトリの書込権限について

レンタルサーバのSmartyのパーミッションでつまずいています。 とあるAレンタルサーバでsmartyを利用したPHPのプログラムを設置するとなんの問題もなく設置できるのですが 別のBレンタルサーバでsmartyを利用したPHPのプログラムを設置すると以下のようなエラーがでます。 Fatal error: Smarty error: unable to write to $compile_dir '/virtual/xxx/public_html/xxx/templates_c'. Be sure $compile_dir is writable by the web server user. in /virtual/xxx/public_html/xxx/class/Smarty/libs/Smarty.class.php on line 1093 書き込み権限がtemplates_cディレクトリにないということらしいですが、Bレンタルサーバのtemplates_cディレクトリのパーミッションは、0755で、設置が成功したAレンタルサーバのtemplates_cディレクトリのパーミッションも、0755です。 実行しているSmarty.class.phpのパーミッションも、0644で同じです。 同じパーミッションでレンタルサーバごとにエラーが出る出ないが違う理由はなんでしょうか?サーバの設定に詳しくないのでよくわかりません。考えられる原因があれば教えてください。

  • PHP
  • 回答数2
  • ありがとう数1

質問者が選んだベストアンサー

  • ベストアンサー
  • agunuz
  • ベストアンサー率65% (288/438)
回答No.2

phpの実行モードはどうなっていますか?AサーバがCGI動作で、Bサーバがモジュール動作なんてオチがありそうなので・・・ モジュール動作ならApacheの権限でしか動作しませんからotherへの書き込み権限が必要です(606とか707とか)。

gothfotu
質問者

お礼

ヒントを下さりありがとうございます。 補足します。 phpinfo()でServer APIを調べました。 成功するAレンタルサーバは、CGI/FastCGI。 失敗するBレンタルサーバは、Apache。 検索して調べてみたところ、safe_modeという言葉があったので、 phpinfo()でsafe_modeを調べました。 成功するAレンタルサーバは、Off。 失敗するBレンタルサーバは、On。 CGIモードやセーフモードで検索したサイトを見たところどうやらエラー原因にヒットしたようです。糸口が見つかったのでこれから調べてみます。ありがとうございます。助かりました。

その他の回答 (1)

  • wormhole
  • ベストアンサー率28% (1622/5659)
回答No.1

パーミッションだけ見て、そのディレクトリの所有ユーザーと、phpの実行ユーザーは調べないのでしょうか?

gothfotu
質問者

補足

回答頂きありがとうございます。 補足します。 Aレンタルサーバのtemplates_cディレクトリの所有者と、phpの実行ユーザは同じです。 Bレンタルサーバのtemplates_cディレクトリの所有者と、phpの実行ユーザも同じです。 あと所属グループも同じです。 検索単語のヒントやサイトURLでもいいので何か教えて頂けたらありがたいです。

関連するQ&A

  • $smarty->compile_dir について

    Fatal error: Smarty error: the $compile_dir 'templates_c' does not exist, or is not a directory. 上記エラー表示となる理由が分かりません。誰か教えてください。 ▼質問したい内容 ・「templates_c」ディレクトリをドキュメントルートから外してはいけないのでしょうか? ・$smarty->compile_dirを指定しなくても、勝手に「templates_c」ディレクトリを探しにいくのでしょうか? ▼経緯 「templates」「templates_c」ディレクトリをドキュメントルートから外したら(public_htmlより上の階層に置くように変更したら)、上記エラーが出るようになりました。 「templates_c」ディレクトリをドキュメントルートへ戻すと、正常表示されます。 (但し、その際、$smarty->compile_dirは、public_htmlより上の階層を指定したままなのに、正常表示される理由が不明) 試しに、$smarty->compile_dir表記自体を外してみましたが、それでも、正常表示されてしまいます。 「templates_c」ディレクトリのパスは、$smarty->compile_dirで指定しているのでは、ないでしょうか? 「templates_c」ディレクトリのパスはどこで指定をすればよいか、 また、ドキュメントルートを外してもよいか、 この2点、誰か教えて~。 ※わざわざ「templates_c」ディレクトリを、ドキュメントルートから外さなくてもよいかとは思いますが、「templates」ディレクトリと同じところに置こうとも思ったら、出来なかったので、その理由を知りたいと思ってます。

    • ベストアンサー
    • PHP
  • smartyのディレクトリ指定について

    お世話になります。 現在下記のような構成になってます d:\www web公開フォルダ d:\smarty テンプレート等のフォルダ smartyフォルダには templates_c templates cache configs があります。 wwwに置いてあるphpに $smarty->cache_dir = "D:/smarty/templates_c"; $Smarty->display("file:d:/www/templates/list.tpl"); と指定しましたがPHPのエラーログに Smarty error: the $compile_dir 'templates_c' does not exist, or is not a directory. と表示されてしまいます。 よろしくお願いします。

    • 締切済み
    • PHP
  • define でのルートディレクトリの定義について・・・。パスが納得できません。

    宜しくお願いします。 Smarty を使用して PHPを勉強しています。 Smartyのデフォルトを変更しようと、 「MySmarty」として新規にクラスを作成しました。 ソースの先頭で、 define("ROOT_DIR",$_SERVER['DOCUMENT_ROOT']."/.."); として、ROOT_DIRにルートディレクトリまでのパスを記憶させています。 全ソースは下記をごらんくらさい。 そこで、  define("ROOT_DIR",$_SERVER['DOCUMENT_ROOT']."/.."); にある、最後の ."/.."); が納得いきません。。。 最初の . ピリオドは連結のためのものだとわかりますが、 あとの/.. はディレクトリの階層をあげる指示ですよね? てなると、クラスの定義のなかで使用するルートディレクトリへのパス が、 おかしく思えてきます。書籍の通りにやっているので、 この通りにやるとうまくいっていますが、自分的になっとくがいかなく・・。 ソースは下記のようになってます。 特に $this->template_dir  のテンプレートディレクトリへのパスを 再設定しているところですが、 ROOT_DIR."/templates" ということは、ルート/../templates  となりますよね? 作業フォルダの図はこの通りです。↓ C:\xampp   |   libs     |-MySmarty.class.php (下記のソースファイル)   |   |   templates       |-input.tpl   |  templates_c <省略> なんとなくですが、ルート/../templates  ではなくて、 ルート/templates なようなきがします。 わかりにくい説明だったかもしてませんが、何卒宜しくお願いいたします。 ______________________________ define("ROOT_DIR",$_SERVER['DOCUMENT_ROOT']."/.."); require_once("Smarty.class.php"); class MySmarty extends Smarty { function MySmarty (){ $this->template_dir = ROOT_DIR."/templates"; $this->compile_dir = ROOT_DIR."/templates_c"; $this->left_delimiter = "{{"; $this->right_delimiter = "}}"; $this->default_modifiers = array('escape'); $this->Smarty(); } } ____________________________

    • 締切済み
    • PHP
  • ロリポップでSmartyのtpl読み込みエラー

    下記のコードを実行すると、  Smarty error: unable to read resource: "template1.tpl"  というエラーが出てしまいます。 $smarty->template_dirで指定したディレクトリ名の中に  "template1.tpl"というファイルは配置してあります。  原因などわかればおしえていただけないでしょうか。 index.php <?php require_once("Smarty.class.php"); $smarty = new Smarty; $smarty->template_dir = './templates/'; $smarty->compile_dir = './templates_c/'; $smarty->config_dir = './configs/'; $smarty->cache_dir = './cache/'; $smarty->display("template1.tpl"); ?> 【サーバ】  ロリポップです。 【その他】 index.phpをホームディレクトリ配下におくとエラーは消えます。 【ディレクトリ構成】 modules/index.php と templates/template1.tpl をがあり、 index.php から template1.tpl を読み込もうとしています。  ・modules →index.php ・templates →template1.tpl

    • ベストアンサー
    • PHP
  • Smartyのtemplatesとtemplates_cのパスの基準について

    Windows環境でSmartyを動かしています。 動かしているサンプルソースがWindows用ではないため、パスなどを動くように直していたのですが、パスの設定でつまってしまいました。 サンプルのphpファイルはC:\xampp\htdocs\sample\に置いており、 Apacheのinclude_pathにC:\xampp\php\smarty\libs\を設定しました。 「templates_c」「templates」「configs」「cache」のフォルダを同じ場所に作成し、 それぞれディレクトリを指定しようとしたのですが、サンプルの「/home/~」というのをどのように直せばいいのか色々と試していて、 $smarty->template_dir = '../templates/'; $smarty->compile_dir = 'C:/xampp/php/smarty/templates_c/'; $smarty->config_dir = 'C:/xampp/php/smarty/configs/'; $smarty->cache_dir = 'C:/xampp/php/smarty/cache/'; で正常に動くのですが、 $smarty->template_dir = '../templates/'; $smarty->compile_dir = '../templates_c/'; とすると、templates_cが存在しないというエラーが出てきます。 compile_dirを"../"にするとhtdocsの直下にファイルができていたので、compile_dirはphpファイルからの相対パスで、template_dirはlibsからの相対パスになっているように思いますが、相対パスで指定する場合の基準パスが違うのでしょうか?

    • 締切済み
    • PHP
  • Smartyエラーについて

    いつもお世話になっております。 Smartyのエラーが解決できなくて困っています。 お手数ですが、後教授願えないでしょうか。 使用環境:Ubuntu Eclipse [エラー] Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'list.tpl'' in /home/mobapendev/public_html/Smarty/sysplugins/smarty_internal_template.php:163 Stack trace: #0 /home/mobapendev/public_html/Smarty/sysplugins/smarty_internal_template.php(550): Smarty_Internal_Template->isExisting(true) #1 /home/mobapendev/public_html/Smarty/Smarty.class.php(338): Smarty_Internal_Template->getRenderedTemplate() #2 /home/mobapendev/public_html/Smarty/Smarty.class.php(382): Smarty->fetch('list.tpl', NULL, NULL, NULL, true) #3 /home/mobapendev/public_html/mobapen/list.php(20): Smarty->display('list.tpl') #4 {main} thrown in /home/mobapendev/public_html/Smarty/sysplugins/smarty_internal_template.php on line 163 ディレクトリ構成 Smarty/Smarty.class.php Project/list.php Project/php/common.php project/smarty/templates/list.tpl project/smarty/templates_c project/smarty/cache project/smarty/configs となっており、 common.phpにて、 $dir = getcwd(); $smarty->template_dir=$dir .'/smarty/templates'; $smarty->compile_dir=$dir .'/smarty/templates_c'; $smarty->config_dir=$dir .'/smarty/configs'; $smarty->cache_dir =$dir .'/smarty/cache'; list.phpにて require_onceで取り込みまいしたが、 $smarty->display("list.tpl"); ディレクトリは間違っていないとは思っているのですが、 どこでload出来てていなか分からず、攻め上げいている状況です。 以上、宜しくお願い致します。

    • ベストアンサー
    • PHP
  • PHP+Smarty時エラー

    いつもお世話になっています。 現在、Smartyを学習しているのですが、 その際以下のエラーが発生します。 Fatal error: Smarty error: unable to write to $compile_dir '/usr/local/www/htdocs/brightsite/public_html/ goodsSystem/Company/goods/templates_c'. Be sure $compile_dir is writable by the web server user. in /usr/local/www/htdocs/brightsite/public_html/goodsSystem/ Company/goods/libs/Smarty.class.php on line 1092 原因は、Fatal errroのように、$compile_dirが書き込めない=禁止されているという気がするのですがよくわかりません。 このとき、原因はSmarty.class.phpにあると考えられるのでしょうか? 宜しくお願いします。

    • ベストアンサー
    • PHP
  • Smartのカスタマイズでエラー

    いつもお世話になっております。 Smartyのカスタマイズを行いたく 設置でエラーになってしまいました。 public_htmlと同じ階層にSmartyフォルダを作成しました。 (下記のような構造になっています。) /public_html/ /Smart/configs/ /Smart/lib/ /Smart/templates/ /Smart/templates_c/ ファイルには下記のように記述しております。 /Smart/lib/smarty_setup.php ---------------------------------------- require_once 'Smarty.class.php'; class SmartySetup extends Smarty {  function SmartySetup() {   $this->template_dir = SMARTY_DIR . "templates";   $this->compile_dir = SMARTY_DIR . "templates_c";   $this->cache_dir = SMARTY_DIR . "cache";   $this->config_dir = SMARTY_DIR . "configs";   $this->left_delimiter = "<!--{";   $this->right_delimiter = "}-->";  } } ---------------------------------------- /public_html/smarty.php ---------------------------------------- require_once("../../Smarty/libs/smarty_setup.php"); $smarty = new Smarty(); $smarty->display("smarty.tpl"); ---------------------------------------- 実行すると、下記のようなエラーが表示されてしまいます。 Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'smarty.tpl'' in C:\*****\Smarty\libs\sysplugins\smarty_internal_template.php:163 Stack trace: #0 C:\*****\Smarty\libs\sysplugins\smarty_internal_template.php(541): Smarty_Internal_Template->isExisting(true) #1 C:\*****\Smarty\libs\Smarty.class.php(337): Smarty_Internal_Template->getRenderedTemplate() #2 C:\*****\Smarty\libs\Smarty.class.php(381): Smarty->fetch('smarty.tp...', NULL, NULL, NULL, true) #3 C:\*****\smarty.php(26): Smarty->display('smarty.tp...') #4 {main} thrown in C:\*****\Smarty\libs\sysplugins\smarty_internal_template.php on line 163 どう対処すればいいでしょうか。 よろしくご教示お願いいたします。

    • ベストアンサー
    • PHP
  • Smartyの設置について教えてください。

    お名前.COMにて提供しているVPSサーバプランについてですが、どなたかSmartyを設置された方いらっしゃいますか? いつもの通りユーザ階層にSmartyフォルダを設置し、一通りの事を行って、いざアクセスするもページが真っ白で表示されません。 エラーログを見ても普通にSmarty.classには到達しているようで、何が原因なのかわかりません(泣) てすとで通常のPHPページを作成し、現在の日時を表示するよう書き込んでアップしてみましたところ、普通に表示されるので普通にPHPは使えるんだなって感じです。 では、なぜSmartyだけうまく表示できないのでしょうか? 恐らく私の基本的なミスが原因だと思いますが、一応どなたか設置経験のある方がいましたら、設置内容を改めて教えていただければと思います。 どうぞ、宜しくお願いします。 ちなみに設置階層は下記の通りです。 /httpdocs/Smarty/libs/Smarty.class.php /httpdocs/data/cache /httpdocs/data/configs /httpdocs/data/templates /httpdocs/data/templates_c また、トップにあたるindex.phpの中は以下の通りです。 <?php require_once('./Smarty/libs/Smarty.class.php'); $smarty = new Smarty(); $smarty->template_dir = './data/templates/'; $smarty->compile_dir = './data/templates_c/'; $smarty->config_dir = './data/configs/'; $smarty->cache_dir = './data/cache/'; $smarty->display('index.tpl'); ?> アドバイスで構いませんので宜しくお願いします。

    • 締切済み
    • PHP
  • tplを読みに行けません。

    PHP+smartyを学んでいます。 Apache2-htdocs-taro-hanako.php とファイルを置き、一方、 Apache2-php_libs-smarty の下に -libs/ (中にSmarty.class.php あり) と -templates/ (中にtest.tpl あり)を並列的におきました。 hanako.php に、 require_once "../../php_libs/smarty/libs/Smarty.class.php"; $smarty = new Smarty; $smarty->templete_dir = "../../php_libs/smarty/templates";   $smarty->compile_dir = "../../php_libs/smarty/templates_c"; $smarty->cache_dir = "../../php_libs/smarty/cache"; 以下省略・・・ と書いてブラウザで開くと、次のエラーが出て、tpl を読み込むことが出来ません。 Warning: Smarty error: unable to read resource: "test.tpl" in C:\Program Files\Apache Group\Apache2\php_libs\smarty\libs\Smarty.class.php on line 1088 どこを間違えているのでしょうか。

    • ベストアンサー
    • PHP