[英]404 Page Not Found when run Codeigniter project inside var/www/html/ on Ubuntu 16.04 LTS?
I have installed LAMP (Linux, Apache2, MySQL, and PHP) stack.我已经安装了 LAMP(Linux、Apache2、MySQL 和 PHP)堆栈。
I have a project directory named 'mahasiswa'.我有一个名为“mahasiswa”的项目目录。 When i ran it on Windows 8 was working well (using XAMPP).当我在 Windows 8 上运行它时运行良好(使用 XAMPP)。 Then, when i run it on my Ubuntu 16.04 LTS inside var/www/html/
is not working anymore.然后,当我在我的 Ubuntu 16.04 LTS 上运行它时, var/www/html/
不再工作。
The screen shot of the result :结果的屏幕截图:
Is there special configuration to run CodeIgniter project on Ubuntu 16.04 LTS ?在 Ubuntu 16.04 LTS 上运行 CodeIgniter 项目是否有特殊配置?
:: Any help would be much appreciate. :: 任何帮助将不胜感激。 Thank you.谢谢。
My configuration files :我的配置文件:
The current result on browser:浏览器上的当前结果:
I don't know exactly what i've missing at this configuration.我不知道我在这个配置中缺少什么。 I've followed @eeya instruction / answer below.我已经按照下面的@eeya 说明/答案进行了操作。 Any body can help me, please :D任何机构都可以帮助我,请:D
For your question in setting up the apache
virtual host configuration: Here's how it goes.对于您在设置apache
虚拟主机配置方面的问题:这是如何进行的。 If you have [root] privilege, Open your [Terminal] and go to this directory: /etc/apache2/sites-available
如果您有 [root] 权限,请打开您的 [终端] 并转到此目录: /etc/apache2/sites-available
Then create a new virtual host configuration, For now, we will name this configuration the name of your project.然后创建一个新的虚拟主机配置,现在,我们将这个配置命名为您的项目名称。
sudo vim mahasiswa.conf
or sudo nano mahasiswa.conf
sudo vim mahasiswa.conf
或sudo nano mahasiswa.conf
<VirtualHost *:80>
ServerName local.mahasiswa.com
DocumentRoot /var/www/html/mahasiswa
<Directory /var/www/html/mahasiswa/>
AllowOverride All
Require all granted
Allow from all
</Directory>
</VirtualHost>
1) ServerName: serves as the the DNS (Think of it as another server name aside from http://localhost or http://127.0.0.1 ) 1)ServerName:作为DNS(可以将其视为除http://localhost或http://127.0.0.1之外的另一个服务器名称)
2) DocumentRoot: from the word itself, is your [project]'s directory (eg /var/www/html/mahasiswa) 2)DocumentRoot:从词本身来看,是你的[项目]的目录(例如/var/www/html/mahasiswa)
3) Directory: are used to enclose a group of directives that will apply only to the named directory, sub-directories of that directory, and the files within the respective directories. 3) 目录:用于包含一组仅适用于指定目录、该目录的子目录以及相应目录中的文件的指令。 In this case, we wanted to place control access rights to a directory:在这种情况下,我们希望对目录进行控制访问权限:
AllowOverride All (This can be either All or None) AllowOverride All(这可以是全部或无)
Require all granted要求所有授予
Allow from all所有人都允许
You can learn more of this here: http://httpd.apache.org/docs/current/mod/core.html#directory您可以在此处了解更多信息: http : //httpd.apache.org/docs/current/mod/core.html#directory
Going back, Once you've saved this new configuration, Go to your /etc/hosts
(hosts file) (eg sudo vim /etc/hosts
) and add the ff:回过头来,一旦你保存了这个新配置,去你的/etc/hosts
(主机文件)(例如sudo vim /etc/hosts
)并添加 ff:
127.0.0.1 localhost local.mahasiswa.com 127.0.0.1 本地主机 local.mahasiswa.com
Once you've saved these changes on your [hosts] file, Execute this command:将这些更改保存到 [hosts] 文件后,执行以下命令:
sudo a2ensite mahasiswa.conf
sudo a2enmod rewrite
This will now [enable] your new site configuration and enable the [url rewrite] module as well.这现在将 [启用] 您的新站点配置并启用 [url rewrite] 模块。 Then execute this afterwards:然后执行此之后:
sudo service apache2 reload
From the command itself, it means you need to reload [apache2] thus the configuration takes affect afterwards.从命令本身来看,这意味着您需要重新加载 [apache2],因此配置会在之后生效。
Then try to access your new domain name: local.mahasiswa.com.然后尝试访问您的新域名:local.mahasiswa.com。 You should be able to see your CI
pages you've needed.您应该能够看到您需要的CI
页面。
For further reference, check [Digital Ocean] guide here: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-16-04如需进一步参考,请在此处查看 [Digital Ocean] 指南: https : //www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-16-04
Hope this helps for your case.希望这对您的情况有所帮助。
Edit: In naming the [controller] file(s) (eg mahasiswa), You might need to set [UpperCase] instead of [lowercase] format to (eg Mahasiswa)编辑:在命名 [controller] 文件(例如 mahasiswa)时,您可能需要将 [UpperCase] 而不是 [lowercase] 格式设置为(例如 Mahasiswa)
Enable mod_rewrite启用 mod_rewrite
sudo a2enmod rewrite
sudo systemctl restart apache2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.