Problems with deploying Kohana to a cloud machine - 404 - php

I have uploaded all my project files onto my cloud machine in the drectory /var/www/html/.
When I visit the IP address of this machine through a browser, it shows me the expected page, which routes to MyCtrl/index.
However, if I manually go to IPAddr/MyCtrl/index, I get an apache server 404 error.
None of the other routes work either. eg. IPAddr/MyCtrl/someOtherAction results in a 404 as well.
The fact that the homepage loads means that the default configuration for MyCtrl/index is working, but maybe URL rewriting is not being done right?
Can someone tell me whether the problem is with my bootstrap.php file or with my .htaccess file, along with a possible fix?
It's the first time I'm deplying an application onto a cloud machine, so I'm not really sure what the problem is.

So if anyone has the same issue, here's the fix:
(This is considering that all project files are in /var/www/html/
Changes have to be made in /etc/apache2/apache2.conf
From:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
To:
<Directory /var/www/>
Options All
AllowOverride All
Require all granted
</Directory>
This answer helped me out:
Kohana The requested URL /home was not found on this server

Related

Cannot navigate to CodeIgniter site

I have a Ubuntu server with 2 websites on it. I can navigate to one, but not to the other. Here are the details:
Each website has a user with the same name as the group and as the subfolder. Sites are hosted under
/home/site1/public_html and
/home/site2/public_html
Now in my case site1 is called from a subdomain, but it works just fine, so if I navigate to site1.mydomain.com it opens up the CodeIgniter page and I can navigate with no issues (I have .htaccess here to get rid of index.php in the url).
However when I try to navigate to www.site2.com which points to /home/site2/public_html it gives me a 404 error. So to troubleshoot, I added a /home/site2/public_html/index.html simple file and I can see that if I navigate to www.site2.com, however I can't see it if I navigate to www.site2.com/index.html. Also, in my case, I have a subfolder (with same name as the site = "site2") where CodeIgniter code/folder structure is and I just can't get tot that index.php from code igniter at all (path to it is /home/site2/public_html/site2/index.php). I tried to navigate as www.site2.com/site2/index.php or www.site2.com/index.php with or without htaccess file but with no help. I tried to remove the .htaccess in this site, I tried to create a test.html in /home/site2/public_html/site2 but I can't navigate to it, I get 404 if I do www.site2.com/site2/test.html
in terms of user access I used $ chmod -R 755 /home/site2
Is it an access right that I am missing? Or a conflict with the other .htaccess from the other virtual folder? No clue... and I am just running out of ideas
V Host Settings
ServerName site1.mydomain.com
ServerAlias site1.mydomain.com
DocumentRoot "/home/site1/public_html"
<Directory "/home/site1/public_html">
AllowOverride All
allow from all
Options Indexes FollowSymLinks MultiViews
Require all granted
</Directory>
and for the one I've trouble with
ServerName www.site2.com
ServerAlias www.site2.com
DocumentRoot "/home/site2/public_html"
<Directory "/home/site2/public_html">
AllowOverride All
allow from all
Options Indexes FollowSymLinks MultiViews
Require all granted
</Directory>
NOTE : I just made a subdomain site2.mydomain.com (domain registered with FatCow) and that seems to be working, it does not work only when I call it with www.site2.com (register under GoDaddy - which gives a GoDaddy "Destination unknown" page which I assumed it is a 404 error and always asks me to Accept cookies ... and I am on a diet :P )
Thanks anyone in advance!
oh darn thing, you were right #sintakonte, one site was pointing somewhere else. Go daddy had a A record with old IP address, I added another A record and asked them to park the original (as I had no rights to do so from their website). And problem got resolved. Thank you!

Updates to DocumentRoot in httpd.conf do not update in phpinfo

My localhost was working without issue when I tried to follow this guide (https://davidsword.ca/development/setting-up-localhost-apachephp-on-icloud-drive/#comment-1974) to set iCloud as the localhost folder instead of /User/myusername/Sites. To be safe I copied the httpd.conf and username.conf files just in case. I didn't get iCloud working as localhost so deleted the updated httpd.conf and username.conf files and reverted to old ones.
Since then I can only get onto my localhost via http://localhost/~myusername/ and get a 403 error when accessing http://http://localhost (which always worked previously)
The phpinfo file is still showing the DOCUMENT_ROOT to be the iCloud one from the guide, even though in the httpd.conf file it shows the following:
DocumentRoot "/Users/myusername/Sites/"
<Directory "/Users/myusername/Sites/">
Options FollowSymLinks Multiviews
MultiviewsMatch Any
AllowOverride All
Require all granted
</Directory>
I've restarted Apache and the macbook several times but it won't update. Is there somewhere else this is stored or a cache of something I can clear to force it to update?
I understand I can set up a virtual host to work around this but I'd rather update the documentroot if possible - thanks

The permalinks in WordPress returns 404

I imported a wordpress production website into my local server to modify it and learn how to wordpress. I use LAMP and my WordPress project is located on a different Hard Drive than my Ubuntu 16.04 partition. But even if I can access to the main page, all the other links (except /wp-admin) are returning a 404 not found error.
As I could read, the problem could be that the .htaccess file was not read by apache2. To enable this option, I needed to enable the plugin rewrite with sudo a2enmode rewrite and to change in /etc/apache2/sites-enabled/000-default.conf the :
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
</Directory>
by :
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
If this may correct the error 404, it creates an internal server error...
Is anyone have an idea of how to handle this problem ?
Thank you !
Have you flushed the rewrite rules yet?
Go to Settings -> Permalinks and hit save.
Alternatively, you can do it from your theme by calling the flush_rewrite_rules() function.
As I needed to use the directory on my other HDD for every dev project, I changed the Server root of Apache2 and it resolves my problems

apache url rewrite connection reset on root directory

in my apache sites-available/default file i had change the config to folowing:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All //originally was AllowOverride None
FallbackResource rewrite.php //i added this line, too
Order allow,deny
allow from all
</Directory>
i wanted to handle all url calls in my own rewrite.php file. this works, when i visit my site at http://192.168.1.104:4567/web/knxzkcha but doesnt work when i go for http://192.168.1.104:4567/web/. i got this problem in firefox : The connection to the server was reset while the page was loading.
the index site http://192.168.1.104:4567/web/index.php works flawlessly and shows me my index.php file. all i want is to let me show the index file when visiting the root directory, too. /var/www points to the /web directory. i have some ubuntu 12.04 server 64 LTS edition
when i rewert the config lines, the root gives me the index file by default.
You do not need to add AllowOverride All, telling apache to avoid IO by checking existence of .htaccess files in current directory and all parents directories with AllowOverride None is a good recipe for speed. Avoid .htaccess files if you can edit Apache configuration.
Now FallbackResource is a quite new feature and may have some bugs. Did you check the ErrorLog for details? Could you try that with LogLevel debug?
It seems you problems is with directories, maybe you could fix it by enforcing usage of your fallback when a Directory is requested, try to add:
DirectoryIndex rewrite.php

VIrtualHost Options returns an index of the site folder

I am not sure why this is happening as I am not very knowledgeable when it comes to Apache. Below is a copy of my VirtualHost.
If this gives any extra help as to how to get it to work, I am trying to run a CakePHP site. I know the site itself has no issues as I have another location I manage the code from and can get it running locally through Apache there.
<virtualhost *:80>
DocumentRoot "C:/sites/sitename"
ServerName dev.sitename.com
ErrorLog "logs/sitename.com-error.log"
CustomLog "logs/sitename.com-access.log" common
<directory "C:/sites/sitename">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order Allow,Deny
Allow from all
</directory>
</virtualhost>
I am running this on Apache 2.0 and Win7sp1
UPDATE
I never found the real solution using the route I was on. I downloaded a fresh copy of WAMP and was soon able to get everything up and running, no problem.
In order to prevent apache from showing the directory listing, you need to disable indexes. Also, it's best to disable MultiViews as that will enable content-negotiating, which may produce unwanted side-effects
Change the options to;
Options -Indexes FollowSymLinks
Then, check that the .htaccess file is present inside your webroot (C:/Sites/Sitename), as that file is used to enable mod_rewrite
Additional pointers/hints
First of all, make sure that the DocumentRoot is pointing to the right directory of your application;
The standard directory structure of CakePHP looks like this;
app
/Config
/Controllers
/Views
......
/webroot
lib
/Cale
plugins
The DocumentRoot should point to your `app/webroot' directory, which contains all 'public' files.
Change the paths/directories in your virtual host to that directory and restart Apache.
If you're still getting a 403 error, change the URL you're visiting in your browser to this;
http://mywebsite.com/index.php
If this does work, check if the .htaccess file is present in that directory and mod_rewrite is installed in your Apache.
According to the answer from "thaJetzah" (sorry, can't comment yet:) )
403 Forbidden is better than having the index of the folder, because now you can see the logs/sitename.com-error.log log and hopefully it tells you, why it gives 403.
Just to make sure: The index.php is in the folder "C:/sites/sitename"?
If you can't isolate the error like this, it would be great to post here the output of the error.log when you try to access the page and it gives you 403.
Check this If you are running Ubuntu.

Categories