Apache and Cakephp application - apache

I am running into issues with cakephp application running with CentOs. I did not change any setting in the default config other than added a file under conf.d which content as :
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/portal/
ServerName abc.mydomain.com
</VirtualHost>
When accessed, home page works i.e. app.mydomain.com shows up but none of the CSS,JS and img files are loaded which are under default structure
i.e. /var/www/portal/app/webroot/img
/var/www/portal/app/webroot/css
/var/www/portal/app/webroot/js
So I tried moving them right under /var/www/portal/ and that worked for homepage but clicking on any link on homepage just does 404. e.g. If link is abc.mydomain.com/test
In apache log I see the errors as 'File Does not exist : /var/www/portal/test' . It seems that apache is not sending the request to cakephp to process the url.
What could be wrong here? Most likely with the apache security settings but am not sure where to lool.

Is your AllowOverride set to all? Only then the CakePHP rewrite directives which are in .htaccess files start working. Alternatively, you can move them to the virtual host configuration and get them to work.

Ok, this is a common mistake. you should enable "rewrite" --> module rewrite. (this is of course a php module). in ubuntu you usually type sudo a2enmod rewrite. Check for CentOS command.

Related

Allow Cachet to run with other sites

I have installed the open source status page Cachet on my macbook's local web server and it works perfectly but during the set up it tells you to change your apache's virtual host to route all traffic to Cachet. I am trying to allow Cachet to run by going to the main domain but if I go to domain/test I would like it to go to another web page. I tried adding another vhost like this:
<VirtualHost *:80>
ServerName http://domain/test
DocumentRoot /Users/macbook/Sites/
</VirtualHost>
but this does not work, I just get error 404 when trying to reach /test page.
Cachet is built using the Laravel framework, so there is a front controller in the public/ directory. That's why you need to route all the requests to this file. But you do not need to route all the traffic of your server to Cachet, that's just the traffic of the site (Cachet), in order to /setup and others are executed by /public/index.php.
Your vhost file may be simple, below an example of what it could be.
It is a simple vhost configured in Mamp, on OSX.
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/Cachet/public"
ServerName status.mysite.com
<Directory /Applications/MAMP/htdocs/Cachet/public>
AllowOverride All
</Directory>
</VirtualHost>
The routing to the public/index.php file is performed by a .htaccess file, so you don't have to write this configuration in your vhost. All you need to do in your vhost is to allow the .htaccess execution.
Note for local web server
If you want to use a custom domain name, you'll need to
update the /etc/hosts file to match the domain with your loopback IP
address.

Apache upgrade 2.2 -> 2.4 issue

I have got a problem with an update of Apache (from 2.2 to 2.4). I keep getting the same message while trying to access 'localhost'
.htaccess: RewriteEngine not allowed here
Also the result that I get from browser is 500 Internal Server Error.
I have completely change old authorization tags from Allow from all to Require all granted, still the same. Tried to load mod_access_compat - still the same.
Any ideas? My httpd.conf is almost a default one at the moment, the only changes are DocumentRoot and Directory.
I got confused while editing my old httpd.conf - it had configured DocumentRoot as follows:
DocumentRoot "web/"
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "web/">
...
With this configuration, new Apache would not like to work. I changed Directory to "/" and it worked.
It is also neccessary to load mod_rewrite module and setup AllowOverride to All (or FileInfo).

XAMPP server document root for specific website

I just installed XAMPP, and I've found how to change the document root in the Apache config file, but I only want to change it for a specific site. The reason I need this is because all of my links are absolute links (i.e. /url not just url).
I tried changing it with .htaccess, but that gave me errors saying the limited recursion had been exceeded. So I went and changed that to 200, and it too a really long time, and then said that the recursion had been exceeded.
I would use aliases, but that would mean saying that any request to / goes somewhere else.
So is there anyway for me to specify that files inside of directory dir should have their document root as dir?
Thanks.
I found the solution, but it's a bit involved. You have to change the Apace config file, and the hosts file.
In the Apache config file, I added this:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/absolute path/from/C/drive"
ServerName site.local
</VirtualHost>
Then I had to add this in the hosts file:
127.0.0.1 site.local
You can read up more on the virtual host here: http://httpd.apache.org/docs/2.2/vhosts/examples.html

ec2/apache not able to locate files on public web from /var/www/html folder

I just followed the instructions from this page (http://www.alexkorn.com/blog/2011/03/getting-php-mysql-running-amazon-ec2/) to setup apache and mysql on an ec2 instance. I couldn't get their custom file structure to point to my files, so I changed the structure to /var/www/html and change changed the bottom of the http.conf file to show this change. When I do that, I get an Amazon Linux AMI Test Page test page on the server, but when I try to test /index.html or /index.php, I get a file not found error - even though I created the /var/www/html directories and placed both files there - what can I be doing wrong?
Page location: http://ec2-107-20-234-28.compute-1.amazonaws.com/
It based on the Linux OS and how Apache has been setup, as per your statement, it looks you have configured the <VirutalHost> something similar to below (correct me if I am wrong):
<VirtualHost *>
ServerName localhost
DocumentRoot /var/www/html
</VirtualHost>
Then, you restarted Apache (? - confirm), if this is correct, then I am sure you see what you want.
Update:
If you are using Debian/Ubuntu don't mind looking at the following URL for configuring an OS for web-development: http://rakesh.sankar-b.com/2010/09/10/install-setup-debian-os-server-machine/

setting a default apache virtual host

Is there any better way of setting the default apache virtual host other than it just picking the first config it finds?
I have a server with many domains, of which only some are configured with httpd but the default virtual host severed up is for example is aaa.com where as really I would like it to default to mmm.com instead?
Something like parking domains without going through the hassle of setting up a config for each one - then I can serve a "content this domain has not been created yet" page?
Cheers
You can create a default virtual host and name it something like 000-default so that it loads first and is used unless another vhost matching the requested domain is found. Here's the bare-bones 000-default:
<VirtualHost *:80>
DocumentRoot /var/www
<Directory /var/www >
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Then you can setup a PHP file under /var/www to create a domain parking page (this is a very simplified example):
<?php
printf('The domain <b>%s</b> is being parked',
htmlentities($_SERVER['HTTP_HOST']));
?>
The first sites-available conf file is default (alphabetically). There should be a 000-default.conf file already, if not create it.
Edit this one to your liking and then make sure it's enabled a2ensite 000-default.conf. And apache2 is reloaded sudo service apache2 reload.
Then any request that isn't caught by your other vhosts will come here.
Use ServerAlias in a name-based VirtualHost, you will only have to add one line per each new domain.