Apache: Configuring Virtual host - virtualhost

i've been tinkering about codeigniter and trying to create a virtual host for the website but when i start and browse local.jpcs.com
it gives me a 404 Page not Found error
This is the path im aiming the xampp/htdocs/jpcs

Use forward slashes in your file paths.
Have you included vhosts in httpd.conf?
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

Related

Two domains with same name different tld? Apache VirtualHosts

So I am following the Ubuntu default style of hosting domains on a LAMP server, and as per widely available knowledge, For each domain to be hosted, I have to create a file with same name but with .conf as the extension, inside the following directory.
/etc/apache2/sites-available
So if I have to host example.com I will be creating a file example.conf with all the Apache directives for that specific domain. So far so good, now if I have to host an additional domain with same name but a different extension, say example.org what should I do?
One solution that is occurring to me is add the virtual host config to that same file beneath the previous code, so is this the way to go or is there any "correct" way?
You create your virtual host with the fqdn, eg, example.com.conf and example.org.conf

How do I find out where my root URL is being served from in Apache?

I've recently got a VPS server and it came installed with CentOS, WHM and cPanel. I'm trying to find where the physical folder location the root URL of the server IP is being served. When I go to the root IP in a browser, I get a redirect to "/cgi-sys/defaultwebpage.cgi" with "SORRY!" and some error resolve details.
The server has a web-site running under "/cPanel" and also WHM runs on ":2083".
I'm trying take control of the content served directly at the /, and replace that defaultwebpage.cgi with an index.html.
I've tried httpd -V to check where the httpd.conf, is and then spotted a <VirtualHost *> in that config file, which points to a DocumentRoot of /use/local/apache/htdocs . But if I place index.html in this folder and try to hit it via /index.html, I still get routed to that defaultwebpage.cgi. Can anyone help me understand why its rerouting and not picking up that index.html?
Thanks.
You may want to try /var/www/html, at least that's in Ubuntu
If it's not it, then try going to /etc/apache2/apache2.conf and find the DocumentRoot option.
Hope this helps!

Apache2 rewriting without rules

So i've a Wordpress site on my domain and i want to add subdomains with their own php code. I'm using mod_rewrite for wordpress and want to use it for my own projects but weirdly i can access urls that should result in a 404 error. For example i can access test/somestuff/morestuff and get test.php (without any $_GET set). But i have no .htaccess file in the directories for the virtual hosts. I then tried to delete the .htaccess from wordpress, restart apache2, and try again but i get the same behavior on the virtual host and wordpress doesn't work with permalinks (like i thought it would). My sites-available configs don't have any rewrite rules in them. Why can i access URLs that shouldn't work? Am i missing some feature of apache?
So after some more trying i've discovered the error was that i've had MultiViews enabled for the virtual host. I've disabled it and now it works.

404 with VirtualHost and Subdirectories with Apache (httpd)

Note: apparently there's a collision on the ServerName in my virtualhost entries and I need to make some changes to my /etc/hosts files. Looking into this but any insight is appreciated. Thanks
=======================================
(note I replaced http:// with hxxp:// to allow stackoverflow to let me post this)
I have a server, 10.1.1.1 that I am going to host multiple WordPress installations on in subdirectories. Specs on the server:
OS: RHEL 6.2 Santiago
Apache version: Apache/2.2.15 (Unix)
PHP version: 5.3.9
MySQL version 5.5.20
The first WordPress Installation I want to run from the virtual directory site_one (i.e. hxxp://10.1.1.1/site_one) -- the code for this site is to reside in /var/www/sites/site_one
The second WordPress Installation I want to run from the virtual directory site_two (i.e. hxxp://10.1.1.1/site_two) -- the code for this site is to reside in /var/www/sites/site_two
I have also dropped a dummy hello world index.html file in /var/www/sites
--
I have made the following changes to my httpd.conf:
DocumentRoot for the entire site is set to /var/www/sites i.e.:
DocumentRoot "/var/www/sites"
at the very bottom of httpd.conf I have the following VirtualHost directives (I replaced < and > with [ ] because I couldn't get stack overflow to output < blocks >:
NameVirtualHost *:80
[VirtualHost *:80]
ServerName 10.1.1.1
DocumentRoot /var/www/sites/site_one
Alias /site_one /var/www/sites/site_one/
[/VirtualHost]
[VirtualHost *:80]
ServerName 10.1.1.1
DocumentRoot /var/www/sites/site_two
Alias /site_two /var/www/sites/site_two/
[/VirtualHost]
I check the syntax of httpd (httpd -t) and the sytax is OK
I restart httpd
--
If I try to access hxxp://10.1.1.1/site_two it gives me a 404 and the error_log reports that it is looking in /var/www/sites/sites_one/site_two/ for the file... Obviously I want it to not look there but in /var/www/sites/site_two/ ... what am I doing wrong? Thanks for any and all help!
See the Apache documentation. http://httpd.apache.org/docs/2.2/vhosts/name-based.html
You are trying to use Name Based Virtual Host because you only have one IP address. This is fine but you are missing the DNS part of how this works. From the documentation: "you need only configure your DNS server to map each hostname to the correct IP address and then configure the Apache HTTP Server to recognize the different hostnames."
The first listed virtual host is always the default host. That is why your site_one will behave the way you "think" it is supposed to, however when you try to access site_two, it falls under the default virtual host.
You have the wrong idea about how Virtual Hosts work. What you are trying to do can be accomplished using aliases, however if anywhere in your code you refer to document root, you have to follow it up with which site you are referring to.
E.g. in PHP code something like this:
require($_SERVER['DOCUMENT_ROOT']."/site_one/directory/to/wherever

symlink or alias? Not sure what its called

I want to redirect request on my local webserver much like "http://localhost/" redirects to my ServerRoot. I have seen it done with "http://www/" and also with "http://helpdesk/" How would I go about adding my own?
Are you saying you want to redirect something like http://custom to your web server? If so you can do this by creating an entry in your hosts file, or configuring your local DNS server to return local addresses for those hostnames.
Add the following to your hosts file (On *nix /etc/hosts and C:\Windows\System32\drivers\etc\hosts on Windows)
127.0.0.1 custom www.custom
Then you can optionally configure a virtual host on your Apache server to handle requests for those hosts. If you don't create a virtual host, it will just serve up the same content as localhost. You can also have your local webserver host the site and add that entry to your local PC's hosts file and be able to browse it from that hostname as well.
If that isn't what you wanted, can you please clarify your question.