All Entries in the "Web-hosting" Category

When I got my new dedicated server setup with Ubuntu server 12.04 LTS, I wanted to use it both for website hosting and multiple users remote desktop work.
It took me some time to arrange all the steps to have the above completed, and as far as the hosting part was pretty easy, the multiple Ubuntu users desktop setup needed some jugs of coffee before start working as I wanted it.

So, I presume you have logged in to your server with some user already, so we will stat with updating the system:

Shell

1

sudo apt-getupdate

Next, as I want all Gnome desktop features, will install it completely with:

Shell

1

sudo apt-getinstall ubuntu-desktop

Unity looks fancy, but I want the old Gnome panel, and I do not need “compiz”, so:

Shell

1

2

3

sudo apt-getremove compix unity

sudo apt-getinstall gnome-panel

Next what we need is a VNC server.

Shell

1

sudo apt-getinstall vnc4server

The tricky part here is that you have to create several configuration files for the Ubuntu Remote Desktop user. This is really time consuming if you have to read all the settings and creating the files by yourself.

It is more easy to start the VNC server which will create the files automatically:

Shell

1

vnc4server:2

You will be asked for a password so enter it, and then kill the server as we have to make some configuration changes:

Shell

1

vnc4server-kill:2

Edit the xstartup configuration file:

Shell

1

vi.vnc/xstartup

And make it looks like this:

Shell

1

2

3

4

5

6

7

8

9

#!/bin/sh

[-x/etc/vnc/xstartup]&&exec/etc/vnc/xstartup

[-r$HOME/.Xresources]&&xrdb$HOME/.Xresources

xsetroot-solid grey

vncconfig-iconic&

x-window-manager&

gnome-panel&

gnome-session&

Now you can start the vnc server with this:

Shell

1

vnc4server:2-geometry1024x768-depth24

Certainly you can change the settings if you want different Remote Desktop geometry.

Now use your preferred VNC client – http://remmina.sourceforge.net/ (Linux) and http://www.tightvnc.com/download.php (Windows) are my suggestions – and connect to the Ubuntu Remote Desktop server using x.x.x.x:2 as (:2) is the number of display used to run for the client. If you have more than one running you should use different number at the end.

As I saying different desktops, I am going to add another user to my Ubuntu Remote Desktop server.
For this I will need to repeat the above steps for creating (and starting) the VNC profile for each user. This one is not yet automatically implemented, but it is not a big deal.
First I will add another user:

Shell

1

sudo adduser newuser

Complete the several steps for creating the user which is including creating the password and user personal information.
(A little trick when you want to add user with administrative privileges is to type the command as : adduser admin
)
Then start the VNC server once to create the VNC password:

Shell

1

2

sudo su newuser vnc4server:3

sudo su newuser vnc4server-kill:3

Open VNC startup file for the ‘newuser’

Shell

1

sudo vi/home/newuser/.vnc/xstartup

And paste the same configuration as for the first user:

C++

1

2

3

4

5

6

7

8

9

#!/bin/sh

[-x/etc/vnc/xstartup]&&exec/etc/vnc/xstartup

[-r$HOME/.Xresources]&&xrdb$HOME/.Xresources

xsetroot-solid grey

vncconfig-iconic&

x-window-manager&

gnome-panel&

gnome-session&

Save the file and start the service

Shell

1

sudo su newuser vnc4server:3-geometry1024x768-depth24

Now using VNC client you can connect to the new user Desktop as going to x.x.x.x:3 address.

The next step is to automate a little bit the start-up precess for these Ubuntu Remote Desktop users. Otherwise you have to start vnc4server for each user when the server is rebooted.

So, switch to root (it is just more easier) and then create vncserver folder and create file as vncservers.conf:

Shell

1

2

3

sudo su-

mkdir-p/etc/vncserver

vi/etc/vncserver/vncservers.conf

Inside put the following massive:

Shell

1

2

3

VNCSERVERS="2:user 3:newuser"

VNCSERVERARGS[2]="-geometry 1024x768 -depth 24"

VNCSERVERARGS[3]="-geometry 1024x768 -depth 24"

Where ‘user’ is the main user you are dealing with (the one we configured VNC for initially) and ‘newuser’ which is the second user are we have created. If you have more users created and the above steps for settings passwords and vnc4srver start-up completed, add more lines accordingly wit (:4),(:5) etc. screens.

I barely remember my first site and how it was created, but I still remember the filling when I saw the price for the webhosting I was searching for. Then I was a student and if I wanted to see my website live, I had to pay one third of my monthly budget. That was before more than ten years and the webhosting was pretty expensive than now.

Nowadays the hosting prices are way to low, but if you are familiar with webhosting and understand the services that some hosting companies provide – you probably know that even price of couple of bugs is too much for what you actually get. I am not going to fail into detailed discussion about hosting companies, plans etc.- so if you are at the point where you do not have much to spend on webhosting, and in the same time you want to start building websites and host them cheep you may use the method described bellow.

Certainly the main point here is that you have pretty much space, PHP and MySQL which allows you to do almost everything, and .. just one domain hosted. Here I have to say that the whole freetutorialssubmit.com website is not more than 600MB and if I decide to host it on such hosting, the rest of the 160GB space will remain unused. You may decide to use the rest of the space as a storage, but in most cases it just remain like that.

With the PHP script bellow you can host multiple domains on one hosting even it the hosting company allows only one domain to be hosted, which will allow you to use the rest of the hosting space for different websites.

Before that I have to mention that all domain you want hosted in this hosting should be set like CNAME for the main domain. The reason is that when a domain is set as a A CNAME record or Canonical Name record in the Domain Name System (DNS) – this specifies that the domain name is an alias of the other domain. This is rather simple and can be done in with the company where the domain is registered for free. (If not try GoDaddy ;)

Once a domain is set as CNAME it will do exactly the same as the first domain. Here comes my script which basically check as which domain the browser request is done and redirects to a particular folder where the according domain files are set. The script should be in the main index.php file, otherwise it will not be opened and will not redirect accordingly.

PHP

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<meta http-equiv="Content-Type"content="text/html; charset=UTF-8">

<title></title>

</head>

<body>

<?php

switch($_SERVER['HTTP_HOST'])

{

case"www.internal.com":

header("HTTP/1.1 301 Moved Permanently");

header("Status: 301 Moved Permanently");

header("Location: http://www.internal.com/index1.php");

exit(0);

break;

case"www.freetutorialssubmit.com":

header("HTTP/1.1 301 Moved Permanently");

header("Status: 301 Moved Permanently");

header("Location: http://www.freetutorialssubmit.com/index2.php");

exit(0);

break;

case"www.onlinehowto.net":

header("HTTP/1.1 301 Moved Permanently");

header("Status: 301 Moved Permanently");

header("Location: http://www.onlinehowto.net/home/");

exit(0);

break;

}

// Here the code of your main domain continues. You can also redirect if you wish

?>

</body>

</html>

Ok, it may looks confusing, but what is actually happening is when someone lands on your hosting, his browser opens the main index file. The script checks ‘HTTP_HOST’ global PHP variable which contains actually via which domain the server was reached and then redirects to its index (you can see it in the example as index2.php and index1.php ), or to a particular folder. If there is no match the visitor’s browser will stay in the same file and will continue with the main domain code.

Well that’s it … and yes, it is legal to host multiple domains on one hosting using this way!

This tutorial contains 301 redirect checker script which I have created after spending more than half an hour searching the Internet for something suitable I can use for my needs. While I was searching I found only separate web pages with fields where you can check one – two URLs or heavy applications that can be installed, and yet not covering my needs. Certainly, there were paid 301 redirect checker solutions which can be used to check 301 Permanent Redirect, but I am not sure whether it does worth to buy such. The purpose of this checker in most cases is only to see if a particular pages redirect permanent covering the SEO (Search Engine Optimization) requirements.

In my case part of the OnlineHowTo.net is moving over Free Tutorials Submit dot com, and from SEO perspective, the tutorials moved have to be with 301 redirect to their new URLs.

I decided to write it as Linux bash 301 redirect checker script because it can be run on almost any Linux machine with curl installed and easily added to the Crontab. I believe the script is rather easy to be understood and used, even by not so experienced administrators.

What the redirect script is doing is to gather the URLs you want to check from an external file (in my case: /opt/scripts/301URLs.txt ), where every URL is placed on a separate line like this:

I chose this way as most of the get-all-urls-from-domain applications provide the listing like this, but certainly you can choose (and then modify a little bit my script) different format.
Then using simple bash loop it reads every line one by one, processing it with CURL extracting the headers (curl -I option).
Every header contains information similar to:

XHTML

1

2

3

4

5

6

HTTP/1.1301MovedPermanently

Date:Thu,18Aug201117:23:57GMT

Server:Apache/2.2.3(CentOS)

Location:http://www.freetutorialssubmit.com/ftp-voyager/109

Connection:close

Content-Type:text/html;charset=iso-8859-1

Once we have this information we can easily egrep for the 301 Moved Permanently part and if it exist, the 301 redirect checker script continues with the next URL. If the redirect is something different it writes down the URL into the /tmp/301report.txt file.

Finally the script checks whether the /tmp/301report.txt file exist – it will be created only if there is even one different from 301 Moved Permanently redirect – and will send it via e-mail to the address you have set in the EMAIL variable. If there are no such file, the script will end with no report.

Here is the whole script which you can freely use and modify as per your needs:

Shell

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

#!/bin/bash

#The subject of the mail message - can be anything.

#For example something that triggers your e-mail client filters.

SUBJECT="301 Redirect Compromised"

#Here you must change with your e-mail address.

EMAIL="mail-to-report-to@yourdomain.com"

#Temporary file I am using to store non 301 redirected URLs.

LINKS=/tmp/301report.txt

#Here I make sure this file does not exist before processing the URLs.

rm-f/tmp/301report.txt

#All URLs which should be checked are in /opt/scripts/301URLs.txt one per line.

cat/opt/scripts/301URLs.txt|whilereadline;do

L=`curl-I-s$line|egrep'^HTTP\/1\.1 301'`

sleep5

if[-z"$L"]

then

echo$line>>$LINKS

fi

done

#Check if there were non 301 redirects stored and e-mail them if any

if[-f/tmp/301report.txt]

then

mail-s"$SUBJECT""$EMAIL"<$links

fi

#EOF

To be honest, I am using a little bit modified 301 redirect checker script, which is also checking whether the redirected URL is the one I need, but it is more complicated and may confuse you if you have to modify it.
Also, more elegant solution will be if you decide to use array, but this redirect checker script fits my needs perfect.
Also I have put sleep command as if the number of the URLs is too big, it may lead to server abuse and blocking the IP you are checking the redirect from. If you do not need the script to wait 5 seconds for every URL, just remove that line.

Hope this scrip will cover your needs as well. Your comments and suggestions are welcome.

As you certainly know eBay is: ‘online auction and shopping website in which people and businesses buy and sell a broad variety of goods and services worldwide‘.

These good people provide one really good marketplace, and certainly they want to earn money from it.
They have several taxes, but probably the most annoying (for me) is for the picture hosting.

That is why I prefer so called eBay Self Picture Hosting option, and this will be the matter of this tutorial: Free eBay Picture Hosting.

For that purpose I am using one really good site called AvatarHosting.net, and I think it is good because even it is free picture hosting site, also it is fast. I tried to host some pictures on imageshack but sometimes the pictures are loading so slowly, so I am sure I am loosing money because of this. They have separate eBay picture hosting section where your pictures are hosted and do not appear trough the site.

Open the home page of Avatar Hosting .net, then at left you will see the upload section.

Choose there browse and locate the picture you want to host for eBay Sales.
Then eBay pictures category, click on private if you do not want to share your images with others and write down your e-mail where the link codes will be send.

It should look similar to this(click on the image to enlarge it):

Tags

You will find this tutorial about how to set IP address for a domain name (website) manually in hosts file on Windows useful in case you are transferring your domain from one company to another, and the domain is still not pointed to the new hosting IP address. Basically this will allow you to preview website without DNS change.
Another case is if you just want to domain name instead of IP address. We all know that Onlinehowto.net is easiest to be remembered instead of 66.235.184.90 (the IP of the hosting).
Certainly you just can do a joke with someone as setting often used domains like Google.com, Yahoo.com, MSN.com to point to a different IP address.
Here I will tell that this is common trick used by hackers to set Yahoo.com (for example) to point to an IP on a server where exactly the same (as Yahoo’s) web page will be set, but the login form there will just still your password and generate error message line ‘Incorrect password’ and will forward you to the real website.

Anyway, how this can be done? How to preview website without IP change?

This can be done in a file called ‘hosts’, and all Windows OS’ are using it to define certain domains or IP addresses.

The mentioned file is always located into the ‘%SYSTEMROOT%\system32\drivers\etc’ folder. Usually this is ‘C:\WINDOWS\system32\drivers\etc’, but it depends on where your Windows is installed.

For example if you copy the next string:

%SYSTEMROOT%\system32\drivers\etc

And paste it into Windows Explorer like on the next picture, when you hit Enter, you will be directed to the ‘hosts’ file location.

The address will be converted as per the Windows installation location C:\WINDOWS\system32\drivers\etc\.

Now locate the file called ‘hosts’ and open it with your preferred text editor. My advice is to use Notepad to avoid any special characters in this file.

The Windows ‘hosts’ file content by default is:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

# Copyright (c) 1993-1999 Microsoft Corp.

#

# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.

#

# This file contains the mappings of IP addresses to host names. Each

# entry should be kept on an individual line. The IP address should

# be placed in the first column followed by the corresponding host name.

# The IP address and the host name should be separated by at least one

# space.

#

# Additionally, comments (such as these) may be inserted on individual

# lines or following the machine name denoted by a '#' symbol.

#

# For example:

#

# 102.54.94.97 rhino.acme.com # source server

# 38.25.63.10 x.acme.com # x client host

127.0.0.1localhost

192.168.0.169mywebsite.com

As you can see this file describe itself, and what it is doing is the mappings of IP addresses to host names.

There is always one record for the local host and as you can see I have set up mywebsite.com to point to a local IP address where I am running Web server.

If you open this domain in your browser, you will see the original website. In my case it will open a page which I am using for creating tutorials.
For example you can see how this trick is used in this tutorial:

Just add an entry to the hosts file and save it. Then all your browsers will open the new location allowing you to preview website without IP change, and all FTP clients, etc. will open it from the new IP address as well.

With this tutorial we will promote one excellent website for picture, image and of’ course avatars called AvatarHosting.net.

Recently we started a good relationship with this site as the image hosting method there is very fast and easy and do not require any kind of registration.
In the same time the site will provide you with ‘copy and paste’ links of the picture and its thumbnails, which can be used directly on your site, in forums, blogs, MySpace, Facebook, eBay picture hosting etc.
Also you can simply upload and share funny images or pictures of yours with few clicks.

This advantage is well used with our site helping us with some of the images included in our tutorials.

This tutorial will explain how you can forward a web page to other URL using PHP forwarding.
It will be useful when you do not want to use other way of forwarding, like .htaccess permanent redirect, META redirect, Java redirect, etc.
This type of forwarding can be used only on a server with running PHP on it.