现在我已经挣扎了5个多小时了,我似乎无法find解决问题的方法。 基本上,我在Fedora Core服务器上(在自定义端口55555上)设置了虚拟主机。 任何时候我尝试通过input浏览器访问php文件例如111.111.111.111:55555/somefile.php浏览器强制此文件下载。 我想要parsingphp文件。
以下是我的httpd.conf附加部分:
Listen 55555 <VirtualHost *:55555> DocumentRoot "/var/www/vhosts/example.com/httpdocs/app/" ServerName 111.111.111.111:55555 CustomLog "/var/log/app/access.log" combined ErrorLog "/var/log/app/error.log" <Directory "/var/www/vhosts/example.com/httpdocs/app/"> Options Indexes MultiViews FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
任何人都知道为什么PHP文件被迫下载和如何parsing它们?
那么,关键是,当我build立在plesk下的PHP文件parsing没有任何问题。
在httpd.conf中,只有3行提到phpconfiguration:
DirectoryIndex at_domains_index.html index.html index.html.var index.shtml index.cfm index.php index.htm index AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
在php.conf文件的conf.d文件夹中,我有以下内容:
# # PHP is an HTML-embedded scripting language which attempts to make it # easy for developers to write dynamically generated webpages. # LoadModule php5_module modules/libphp5.so # # Cause the PHP interpreter to handle files with a .php extension. # AddHandler php5-script .php AddType text/html .php # # Add index.php to the list of files that will be served as directory # indexes. # DirectoryIndex index.php # # Uncomment the following line to allow PHP to pretty-print .phps # files as PHP source code: # #AddType application/x-httpd-php-source .phps
通过启用php模块解决问题。 以下是我的虚拟主机configuration如何:
Listen 55555 <VirtualHost *:55555> DocumentRoot "/var/www/vhosts/example.com/httpdocs/app/" ServerName 111.111.111.111:55555 CustomLog "/var/log/app/access.log" combined ErrorLog "/var/log/app/error.log" <Directory "/var/www/vhosts/example.com/httpdocs/app/"> Options Indexes MultiViews FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> <Directory /var/www/vhosts/example.com/httpdocs/app> <IfModule sapi_apache2.c> php_admin_flag engine on php_admin_flag safe_mode on php_admin_value open_basedir "/var/www/vhosts/example.com/httpdocs/app:/tmp" </IfModule> <IfModule mod_php5.c> php_admin_flag engine on php_admin_flag safe_mode on php_admin_value open_basedir "/var/www/vhosts/example.com/httpdocs/app:/tmp" </IfModule> </Directory> </VirtualHost>