Posts Tagged ‘server’

Getting two domains on one IP

I recently had a request from someone on how to setup multiple domains on a single IP address. This is something that I’ve thought about doing before, but haven’t taken the time to stop and set it up. After getting sub-domains working, this was a breeze, as it’s the same process. I’m working on an Ubuntu server, so this may be a little different for you.

DNS

First setup the DNS, since it will probably take about an hour for that to update anyway, depending on the TTY that you use. If you’re setting this up and you want to make sure it works, you can edit your /etc/hosts file on a mac or linux machine. I think there’s a way to do this in windows as well, but I’m not sure of what file you’d be looking for. Just remember to delete that entry after you know it works.

To setup the DNS you first need to find the DNS control for the domain registrar that you use. In GoDaddy the option would be called Total DNS. Change the A record to the IP address you want to use as a server and you’re done.

Configuration

Now you need to create a new file in /etc/apache2/sites-available/. Call it whatever you want. I will call it NEWSITE.TLD. In this file you will create a new file that looks similar to this, only substituting information specific to your server:


NameVirtualHost *:80


	ServerAdmin you@your-domain.tld
	ServerName your-domain.tld

	DocumentRoot /var/www/your-root/

	
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Order allow,deny
		allow from all
	

	ErrorLog /var/log/apache2/error.log
	LogLevel warn
	CustomLog /var/log/apache/access.log combined
	ServerSignature On


Now we enable the site with:


sudo a2ensite /etc/apache2/sites-available/NEWSITE.TLD

Reload the apache configuration and you should be good to go.

Published: August 25th, 2009 in Tech, Web | Tags: , , , ,

Trac and SVN on subdomains

I finally figured out how to get trac and svn on their own subdomains since when I originally setup the web server awhile ago. The only thing that changes is the vhosts file. In that example it was “/etc/apache2/sites-available/svntrac”. Here’s what the file should look like now:


NameVirtualHost *:80


ServerAdmin you@domain.com
ServerName domain.com

DocumentRoot /var/www/

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all


ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On



  ServerName svn.domain.com
   
   DAV svn
   SVNParentPath /svn

   AuthType Basic
   AuthName "Subversion Repository"
   AuthUserFile /path/to/svnauth


   Require valid-user


#   AuthzSVNAccessFile /path/to/svnaccess
  




   ServerName trac.domain.com

   

    SetHandler mod_python
    PythonHandler trac.web.modpython_frontend
    PythonOption TracEnvParentDir /trac
    PythonOption TracUriRoot /

   

   

    AuthType Basic
    AuthName "Trac"
    AuthUserFile /path/to/svnauth
    Require valid-user

   

Published: July 19th, 2009 in Tech, Web | Tags: , , ,

My Perfect Server

After getting everything setup how I want on my web server I want to record how I did it. I know the right thing to do would be to create an image, but I’m just going to write it down instead. That way you can use it if you ever need it.

Install Trac and SVN

Thanks to Anant Garg for this part. I’m only going to make a few changes to update things and such.


sudo apt-get install apache2 libapache2-mod-python libapache2-svn python-setuptools subversion python-subversion
sudo easy_install http://ftp.edgewall.com/pub/trac/Trac-0.11.4.tar.gz
sudo mkdir /svn
sudo mkdir /trac
sudo htpasswd -cm /etc/svnauth myname
sudo htpasswd -m /etc/svnauth myfriendsname

Create a permissions file, “/etc/svnaccess”


[groups]
developers = myname, myfriendsname
[ / ]
@developers = rw
* = r

Now create the Apache config file, “/etc/apache2/sites-available/svntrac”




 ServerAdmin your@email.com
 ServerName 

 DocumentRoot /var/www/
 
 Options FollowSymLinks
 AllowOverride None
 
 
 Options Indexes FollowSymLinks MultiViews
 AllowOverride None
 Order allow,deny
 allow from all
 

 ErrorLog /var/log/apache2/error.log
 LogLevel warn
 CustomLog /var/log/apache2/access.log combined
 ServerSignature On



 DAV svn
 SVNParentPath /svn

 AuthType Basic
 AuthName "Subversion Repository"
 AuthUserFile /etc/svnauth


 Require valid-user


AuthzSVNAccessFile /etc/svnaccess




 SetHandler mod_python
 PythonHandler trac.web.modpython_frontend
 PythonOption TracEnvParentDir /trac
 PythonOption TracUriRoot /trac




 AuthType Basic
 AuthName "Trac"
 AuthUserFile /etc/svnauth
 Require valid-user




Now I have to activate the new config file and change the permissions.


sudo a2ensite svntrac
sudo /etc/init.d/apache2 reload
sudo chown -R www-data /trac

Now create, “/etc/trac.ini”


[header_logo]
alt = Logo
height = -1
link =
src = /trac-files/logo.png
width = -1

The logo.png file will go in “/var/www/trac-files”.

Now I create a perl script called init.pl. I wouldn’t have done this, but it was on the tutorial and it is actually really handy.


#!/usr/bin/perl
$sName = $ARGV[0];
$lName = $ARGV[1];
if ($lName eq "") {
 $lName = $sName;
}
$sName =~ tr/A-Z/a-z/;
$path = "sudo svnadmin create /svn/$sName";
system ($path);
$path = "sudo chown -R www-data /svn/$sName";
system ($path);
$path = "sudo trac-admin /trac/$sName initenv '$lName' 'sqlite:db/trac.db' 'svn' '/svn/$sName' --inherit=/etc/trac.ini";
system ($path);
$path = "sudo chown -R www-data /trac/$sName";
system ($path);
$path = "sudo trac-admin /trac/$sName permission add yourusername TRAC_ADMIN permission list yourusername";
system ($path);
print "Done!\n\n";

Now, when you run this it will look something like this.


sudo perl init.pl 'short' 'long'

The ‘short is obviously the short name and the ‘long’ is the long name. If you don’t have a long name you can leave that part out, the script will just use the short name.

Thanks to Anant Garg, for this part of the tutorial. My only real reason for posting this part is to make sure I don’t lose it.

Finishing the LAMP setup

The first thing I want to do now is make the IP address static. I can’t forget to do that. So I have to open the “/etc/network/interfaces” file.

Change this:


auto eth0
iface eth0 inet dhcp

to this:


auto eth0
iface eth0 inet static
 address 192.168.1.100
 netmask 255.255.255.0
 network 192.168.1.0
 broadcast 192.168.1.255
 gateway 192.168.1.1

Make sure to change “dhcp” to “static”. Then restart networking.


sudo /etc/init.d/networking restart

Now Let’s install the MP part of LAMP.


sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo /etc/init.d/apache2 restart
sudo apt-get install mysql-server
sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin

Now let’s add the following to “/etc/apache2/apache2.conf”:


# Include phpmyadmin configuration
Include /etc/phpmyadmin/apache.conf

and restart apache. Then finish setting upu phpMyAdmin:


sudo apt-get install php5-mysql mysql-client

and add “extensions=mysql.so” to “/etc/php5/apache2/php.ini” and restart apache 1 last time.

Finally, Let’s add an FTP server:


sudo apt-get install proftpd ucf

Select ‘standalone‘ when asked to chose between ‘inetd’ and ‘standalone’.

Add the “DefaultChdir” as “/var/www” and restart the web server.

Thanks to HowtoForge for this part of the tutorial.

Published: April 13th, 2009 in Tech | Tags: , , , , ,

Email Server?

Anyone know how to set up an email server? I’m trying to set up a server on my domain but I can’t find any free software to use. I think i want SMTP and POP3.

Published: June 2nd, 2006 in Web | Tags: ,