index.php codeigniter未加载到ubuntu上的虚拟主机apache2中

时间:2015-05-27 07:28:28

标签: apache .htaccess codeigniter ubuntu

我在ubuntu 14.04中安装了apache2。我的计划是将我的codeigniter应用程序的文件夹称为" tresnamuda"。我知道ubuntu中的默认虚拟主机是/ var / www /。所以,我把" tresnamuda"进入/ var / www / tresnamuda。

但是,它给了我空白页面。当我在互联网浏览器上右键时,index.php的包含就像这样加载:

<?php

/*
*---------------------------------------------------------------
* APPLICATION ENVIRONMENT
*---------------------------------------------------------------
*
* You can load different configurations depending on your
* current environment. Setting the environment also influences
* things like logging and error reporting...........

我不知道错误在哪里,因为/var/www/tresnamuda/.htaccess包含这样的代码:

RewriteEngine on
RewriteBase /tresnamuda/
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

在/etc/apache2/sites-available/tresnamuda.com.conf上的apache conf中,我这样写:

<VirtualHost *:80>
   ServerAdmin itjkt@tresnamuda.co.id
   ServerName 192.168.5.222
   ServerAlias http://192.168.5.222
   DocumentRoot /var/www/html/tresnamuda
   ErrorLog ${APACHE_LOG_DIR}/error.log
   CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

在/etc/apache2/apache2.conf中,我这样写:

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All   
    Require all granted
</Directory>

我已经尝试了很多次。我使用sudo a2ensite tresnamuda.com.conf ,当我访问互联网浏览器时仍然是空白页:http://192.168.5.222

请提出任何建议。

1 个答案:

答案 0 :(得分:0)

听起来好像没有安装PHP,或者至少PHP没有配置Apache。根文件夹中的PHP文件是否正确运行?

如果没有,则需要安装PHP

sudo apt-get install php5

然后,一旦完成,重新启动Apache

sudo service apache2 restart

如果安装了PHP,我在digital ocean上找到了一个可能有用的资源。我认为,相关部分将是:

  

将php添加到目录索引,提供服务也可能很有用   相关的php索引文件:

sudo nano /etc/apache2/mods-enabled/dir.conf 
  

将index.php添加到索引文件的开头。该页面现在应该如下所示:

<IfModule mod_dir.c>
           DirectoryIndex index.php index.html index.cgi index.pl index.php index.xhtml index.htm 
</IfModule>