簡體   English   中英

無法訪問Apache上的php文件

[英]Can't access php files on apache

我在Ubuntu 10.04 x32上安裝了Apache,Php,Mysql。 安裝它們后,我無法訪問某些php文件。 APM已開啟。 以下是一些文件和.htaccess文件以解決問題。 如果在瀏覽器上看不到“可以訪問”文件,則服務器可能已關閉。

權限:phpinfo.php644,index.php 600,hello.php 600

[可以訪問]

http://222.118.53.30/phpinfo.php
http://222.118.53.30/phpmyadmin

[無法訪問]

http://222.118.53.30/index.php
http://222.118.53.30/hello.php

.haccess正在關注

SetEnv APPLICATION_ENV development



Options -Indexes

Options +FollowSymLinks

DirectoryIndex index.php index.html

<IfModule mod_rewrite.c>

RewriteEngine on

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)\?*$ index.php [L,QSA]

#remove www.

#RewriteCond %{HTTPS} off

#RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]

#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

#RewriteRule ^(.*\.(png|jpg|jpeg|gif))$ index.php?controller=minify&action=index&file_path=$1&ext=$2 [L,NC]

#RewriteRule ^(.*\.(css|js))$ index.php?controller=minify&action=jscss&file_path=$1&ext=$2 [L,NC]


</IfModule>

ErrorDocument 404 index.php

<ifModule mod_expires.c>

ExpiresActive On

ExpiresDefault "access plus 1 seconds"

ExpiresByType text/html "access plus 1 seconds"

ExpiresByType image/gif "access plus 2592000 seconds"

ExpiresByType image/jpeg "access plus 2592000 seconds"

ExpiresByType image/png "access plus 2592000 seconds"

ExpiresByType text/css "access plus 604800 seconds"

ExpiresByType text/javascript "access plus 216000 seconds"

ExpiresByType application/x-javascript "access plus 216000 seconds"

</ifModule>

<FilesMatch "\.(htaccess|htpasswd|ini|log|sh|inc|bak|cache)$">

Order Allow,Deny

Deny from all

</FilesMatch>

[hello.php]

<?php 
 echo "Hello World";
?>

[index.php]

<?php 

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

// Define base path
defined('BASE_PATH')
|| define('BASE_PATH', realpath(dirname(__FILE__)));

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

set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../JO/v.0.9b/'),
realpath(APPLICATION_PATH . '/library/'),
get_include_path(),
)));

require_once 'JO/Application.php';

// Create application, bootstrap, and run
$application = new JO_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/config/application.ini',
isset($argv) ? $argv : null
); 

// Set Routers links
$configs_files = glob(APPLICATION_PATH . '/config/config_*.ini');
if($configs_files) {
foreach($configs_files AS $file) {
    $config = new JO_Config_Ini($file);
    $application->setOptions($config->toArray());
    JO_Registry::set(basename($file, '.ini'), $config->toArray());
}
}

// Set Routers links
$routers_files = glob(APPLICATION_PATH . '/config/routers/*.ini');
if($routers_files) {
foreach($routers_files AS $file) {
    $config = new JO_Config_Ini($file, null, false, true);
    $application->setOptions($config->toArray());
    JO_Registry::set('routers_'.basename($file, '.ini'), $config->toArray());
}
}

//dispatch application
$application->dispatch();



// error handler function
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
if (!(error_reporting() & $errno)) {
    // This error code is not included in error_reporting
    return;
}

switch ($errno) {
case E_USER_ERROR:
    echo "<b>My ERROR</b> [$errno] $errstr<br />\n";
    echo "  Fatal error on line $errline in file $errfile";
    echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
    echo "Aborting...<br />\n";
    exit(1);
    break;

case E_USER_WARNING:
    echo "<b>My WARNING</b> [$errno] $errstr<br />\n";
    break;

case E_USER_NOTICE:
    echo "<b>My NOTICE</b> [$errno] $errstr<br />\n";
    break;

default:
    echo "Unknown error type: [$errno] $errstr<br />\n";
    break;
}

/* Don't execute PHP internal error handler */
return true;
}

您能幫我解決我的配置有什么問題嗎?

這些文件顯示HTTP 500 Internal server error 這意味着這些文件中的某些代碼不適用於您的PHP版本。 您需要查看這些文件中的代碼

您確定無法訪問文件嗎? 因為從此結束,我可以。 我剛收到一個內部服務器錯誤(500),這可能有很多原因。

最常見的一個是php文件中的語法錯誤。 因此,例如,請發布hello.php的源代碼。

我測試Htaccess是正確的,沒有問題。

通過評論htaccess的這一行來測試php

  RewriteCond %{REQUEST_FILENAME} !-f

  RewriteCond %{REQUEST_FILENAME} !-d

  RewriteRule ^(.*)\?*$ index.php [L,QSA] 

如果hello.php正常工作,則表示問題在索引php代碼上

如果問題不能解決,則意味着php索引正確,我認為問題出在虛擬主機部分的httpd.conf

一些其他的問題,也許會像權限這一問題,(你的PHP文件必須是655意思可以readexecute公共, readexecute由集團, readwrite的所有者)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM