I am running LAMP config on CentOS 5.6
Now, the question is how do I add a domain name to the server? I have already pointed the domain name to the server.
I think the next steps would be something like this.
Create a user on centos
Create a folder for the domain name within that users directory
Create a virtual host on apache pointing the directory to the users directory
Add content to the directory of the domain name specified in the virtual host
Voila! A new domain name created.
Am I missing something from the list? Also, any other methods to do this or just use ssh?
To change domain name, there are a couple config files you need to work with, with root permission. Make sure you backup all original files before making any changes:
"/etc/sysconfig/network" which you should replace the default hostname by your FQDN(Fully Qualified Domain Name), something like this: myHostName.myDomainName.
"/etc/hosts" which you should add your IP address(es) with corresponding hostname and FQDN, separate by whitespace, something like this: 192.168.1.1 myHostName myHostName.myDomainName
"/etc/sysconfig/network-scripts/ifcfg-eth0" which is a config file for your ethernet interface 0, replace default IP address, network, network mask, gateway, etc. to a proper value. And if your server has more than one interface, you should config all of them. They are in the same directory with the above file I mentioned. Look at the name and you should know which one to amend.
Finally, restart your server.
I recommend this book which I am using as a quick reference. For those steps you mentioned, it depends what you want to achieve. But I suggest you open a new thread for them.
You create a user, then you create a domain directory and put your files in there, then you add a virtual domain to apache and restart apache and that should be it.
Obviously dont forget to setup your dns or ask your hosting to set it up for you.
Related
I am switching our site from one server to another, but need to test its all working without changing the domain, how can I change it so it accepts connections to the IP?
You have tagged Cpanel so if it is Cpanel/WHM,it includes facility of temp URL which generally goes like http://IPaddress/~cpanelusername
This should load the webcontents of your "publichtml" of Cpanel account.
Please specify the details of your controlpanel on both servers if you are not referring to Cpanel-WHM.
I think you are trying to check your site from new server without changing domain nameserver.
To check our domain from new server, You need to update your local PC host file ( C:\Windows\System32\drivers\etc\hosts ) with new IP and your domain so that you can test your domain from new server.
My company has a LAMP server, and I am not an expert at web hosting but I manage basic tasks.
My server currently hosts about twelve different domains. Each domain has a .conf file in the sites-enabled directory, and they work fine. Let's say we have example1.com, example2.com, and example3.com, just to hopefully help explain this question.
Recently, a person I work with registered a bunch of new domains. With the domain registrar, they pointed the domains to our IP address. I believe this is called "parking" a domain. I have not set up a .conf file or enabled any of these new domains on our server yet. Let's say they are newsite1.com, newsite2.com, etc...
What's puzzling to me is that if one types one of the new domains into a browser, one of our existing domain shows up. Let's say it's example1.com. So, if you go to a browser and type in newsite1.com, or newsite2.com, you are taken to example1.com. Also, in the address bar at the top of the browser, it will be displayed as example1.com.
This is not the desired behaviour. For one thing, we did not choose, as far as I know, for example1.com to be the default, and it's not necessarily the website we would want to be the default. In any case, I don't know why the system is going to example1.com as opposed to example2.com or any of our other sites.
The desired behaviour would be for there to just be a general error, "this domain does not exist" or something like that. If there has to be a default website, we'd like to be able to choose it.
I've seen questions on Stack Oveflow that are similar, but they all presume one wants to set a default. When I look at the configuration files they reference, for example /etc/httpd/conf/httpd.conf, they are empty, so in my case, there is nothing to unset.
How do I stop browsers from being redirected to the website that they are currently being directed to? How can I set it so that Apache just returns a "site not found" error instead of serving up a website?
The easiest way to fix this is name your .conf files starting with a number.
If you look at the default apache configs, you'll notice a file called "000-default.conf". Apache will load the files in number order - so just make your default virtual host .conf file be 000-whatever.conf.
I suppose you're using name based virtual hosts and the <VirtualHost> directive and this is what docs have to say:
If no matching name-based virtual host is found, then the first listed virtual host that matched the IP address will be used. As a consequence, the first listed virtual host for a given IP address and port combination is the default virtual host for that IP and port combination.
So when you say:
I've seen questions on Stack Oveflow that are similar, but they all
presume one wants to set a default.
... all I can add is that that's the way Apache works. I don't think it's inherently wrong to have a default host that serves a this domain does not exist page. I always do so in my Windows development box, typically by commenting out the default hosts at conf/extra/httpd-vhosts.conf file and adding my default host there.
If you ask for my opinion, it's rather questionable that Apache basically serves an arbitrary site when there's no match, thus making this customisation mandatory—and I've seen lots of live sites that don't do it.
I've got Apache installed via XAMPP on my Windows machine, I've forwarded port 80 so that it's accessible from outside the local network, and everything is good.
However, I'm working with laravel and am trying to make it so that each of my sites are accessible via a different path.
For example, site 1's public directory would be C:\xampp\htdocs\site1\public which I would like to be able to access from http://<public_ip>/site1 or http://<public_ip>/~site1. Similarly, if I created another project, I'd like to be able to access it in the same way using an alias on my public IP address.
Would I use vhosts for this? Alias'? Or how would I accomplish it?
I'm new to configuring apache, I've tried reading the docs but they have only managed to confuse me even further.
You will have to modify your httpd.vhosts.conf file in the "config/extra" folder. Also you will have to modify the hosts file. I'm not sure where that is in Windows.
Here is something that might help.
http://sawmac.com/xampp/virtualhosts/
I'm a complete newbie when it comes to servers, so I need some help. Basically, I want to have a subdomain on my VPS. I'm not too concerned where the files reside, though of course I would like them separated if possible.
I found a guide to doing this that basically sums the procedure up in five steps:
Create directories to host the content of a new virtual site.
Make a copy of the /etc/apache2/sites-available/defaults file with a site appropriate name.
Change the two /var/www/ entries to the actual directory of the new site.
Add the ServerName line with the real domain name you will be hosting.
Use a2ensite to enable the new site, and finally reload Apache2 so it knows about the new site
I tried all of this, but I can't get it to work. I didn't get any errors at any point during this process, but when I enter the address with the subdomain into my browser, I get a "Server not found" error.
The company that hosts my VPS has an admin page where I can set up subdomains. Stupid question: do I have to do reconfigure the DNS records or something while doing this, or is it likely that the problem is caused by something else?
Additional note: I followed a guide on howtoforge.com when setting up the server, which in hindsight may not have been the brightest move on my part. It is possible that I made a mistake there that is somehow affecting me now?
Assuming you've setup the subdomain correctly in your VPS' admin page, the only thing left to check here is that you've actually created the subdomain in your DNS administration page (have you?). For example, I use afraid.org to manage my DNS records and to add a subdomain, it's essentially:
Type: A
Subdomain: sparky
Domain: example.com
Destination: 120.34.2.3 (this would be your VPS' IP address)
In general, you add a (sub)domain by:
sparky.example.com A 120.34.2.3
Please keep in mind that you want to add an A record (this is important!).
I'm trying to setup a server at www.domain.com that will allow me to create hosting accounts for each user I add.
Basically my goal is to create a user and map a name-based vhost to their home dir, so:
"joe.domain.com" would point to "/home/joe"
I've tried setting up vhosts in httpd.conf but I'm not having any luck and wondering if there's a way to either 1. script this process or 2. setup some sort of variable in a generic vhost entry that will automatically create this entry.
Without knowing the details of your setup, I can tell you that:
Yes, you can script the process.
Apache configuration files are just text files, so it's very easy to generate the programatically.
Yes, you can configure some sort of generic virtual host entry.
The Dynamically configured mass virtual hosting documentation from Apache addresses this case quite nicely.