#1 2013-07-07 21:25:43

dimitrisp
ROCK & ROLL!!!!!!!
From: /dev/null
Registered: 2013-07-06
Posts: 65

Setting up a small web server [complete guide with first steps]

You just got your 3 euro/year VPS, and you probably don't know what to do with it. Don't feel bad. I have one for a little bit more than 24 hours, and I feel like getting one more although I won't need it anytime soon!

What if you use it to offload your main VPS or website? I mean, use it for static content (images, css files and other stuff like this). It will be a little bit painful in the beginning, but you could save some bandwidth on the other side.

Before I tell you anything more, I, hereby inform you that I have no responsibility if your VPS gets closed for violation of the ToS/AUP (although I didn't find anything suggesting that hosting static content can get your VPS disabled, still it's your own responsibility to make it 100% sure). If you continue doing anything below this line, means that you agree with this. Also, I stole mikho's content, and reordered it a little bit (sorry!)

Now that we got that out of the way, let's get started. As suggested on the "First steps to do when you get your VPS" thread, you should do these things to have a webserver on port 80 (if you want it on a different port, I will post a modified guide, it's a little bit tricky):
1. Change your SSH port. [Hint: the file is /etc/ssh/sshd_config]
2. Ask for the public IP of your VPS, by opening a ticket. (no longer needed as the IP is in the VPS Info email)
3. Create an A Record from a domain you own to that IP. If you don't have a domain, you can always get a free .TK domain.
4. Open a new ticket and supply the domain/subdomain you used on the previous step, and ask for the reverse proxy to be enabled for you.

I assume that you have disabled your root account and you are using sudo (and you should)
Since you have your Public IP you can use that, or the reverse proxy domain since it is pointing to your public IP, to SSH to your server instead of the IPv6 one in case you don't have native IPv6 connectivity and don't want to install a tunnel. You should nag your ISP to enable IPv6 though! big_smile You still have to use the new SSH Port though.

Now, let's get a little bit dirty wink

$: sudo apt-get update
$: sudo apt-get upgrade
$: sudo apt-get install lighttpd

These steps may take a while, so grab a cup of coffee or something refreshing.

We should secure it a little bit. What do I mean?

$: nano /etc/lighttpd/lighttpd.conf
you should now see the basic config. Locate "server.groupname", and on a new line type:
server.tag = "Need-To-Know-Basis-Only" (or something smarta$$-y like that.)
Why? We won't be giving this server too much attention, and if we don't put this "server.tag", anyone will be able to see the server name (lighttpd) & version.
Also, locate server.dir-listing, and change it to "disable". We don't need strangers pokinga around our files and, no, creating an empty "index.html" file on each folder we create may get time consuming.
Save & close the file. and restart lighttpd so that this will take effect.
$: sudo invoke-rc.d lighttpd restart

Actually that's it. Our small web server is ready. Now, to upload your files, you need an FTP client which supports SFTP (I would suggest FileZilla. Look around a bit to configure it and connect to SFTP)
The folder for your files is /var/www

Tip: Buy 1 mini vps on the NL node and 1 on the UK node and do a "round-robin" dns (that's 2 different A records on a hostname). Why? It will be something like offloading the work between those 2 servers. Not 100% efficient, but hey...


Love metal? http://www.distortionradio.gr/ | Powered by LowEndSpirit Hardware (at 50%)
GamePost.eu - New Gaming Community, with NMRiH & TF2 Servers (more to come soon)
If my posts have helped you in any way, send me some bitcoins: 1M5Vwki6qgwZKw3Q8wBQYC5cCy58UmGnM big_smile

Offline

#2 2013-07-07 21:26:50

dimitrisp
ROCK & ROLL!!!!!!!
From: /dev/null
Registered: 2013-07-06
Posts: 65

Re: Setting up a small web server [complete guide with first steps]

So, you want to use lighttpd on a different port than 80. Maybe you already use the reverse proxy for something else? Well, no worries. We just have to do 2 more small modifications!
$: sudo nano /etc/lighttpd/lighttpd.conf

On the top of the file append:
server.port = portnumber (I would suggest you set it to one of your public ports, so that it works on both IPv4 & IPv6)

Save it and close it. Now... We have another small modification to do.

$: sudo nano /usr/share/lighttpd/use-ipv6.pl

See that line? Yes, that's the one:
print qq/\$SERVER["socket"] == "[::]:80" { }\n/;

Change that nasty "80" to the same port number you used on "server.port". Save it and close it.

$: sudo invoke-rc.d lighttpd restart

Everything should have gone smooth, and your lighttpd server should now run on a different port. Should you encounter any problems, reply and I'll do my best to help you!

Well, you could have found all these information by searching the web, but what's better from having everything in the same place? wink

Last edited by dimitrisp (2013-07-07 21:34:14)


Love metal? http://www.distortionradio.gr/ | Powered by LowEndSpirit Hardware (at 50%)
GamePost.eu - New Gaming Community, with NMRiH & TF2 Servers (more to come soon)
If my posts have helped you in any way, send me some bitcoins: 1M5Vwki6qgwZKw3Q8wBQYC5cCy58UmGnM big_smile

Offline

#3 2013-07-07 21:42:40

Backtogeek
Low End Boss
From: ~/
Registered: 2013-02-13
Posts: 3,547
Website

Re: Setting up a small web server [complete guide with first steps]

Thanks, I will make this a sticky, I am all for rewarding a bit of effort so just order another one if you want but do not pay the invoice and I will push it through smile


http://LittleHappyCloud.net KVM VPS with 1TB Bandwidth for €3.00

Offline

#4 2013-07-07 21:51:48

dimitrisp
ROCK & ROLL!!!!!!!
From: /dev/null
Registered: 2013-07-06
Posts: 65

Re: Setting up a small web server [complete guide with first steps]

Right now I don't need it and it will be a waste of resources (and money) on your side! Thank you very much for the offer though! smile


Love metal? http://www.distortionradio.gr/ | Powered by LowEndSpirit Hardware (at 50%)
GamePost.eu - New Gaming Community, with NMRiH & TF2 Servers (more to come soon)
If my posts have helped you in any way, send me some bitcoins: 1M5Vwki6qgwZKw3Q8wBQYC5cCy58UmGnM big_smile

Offline

#5 2013-07-07 22:03:18

mikho
Low End Mod
From: Hell and gore == Sweden
Registered: 2013-03-02
Posts: 1,356
Website

Re: Setting up a small web server [complete guide with first steps]

Nice guide!

Offline

#6 2013-07-07 22:11:07

Spittie3
Trusted Member
Registered: 2013-06-30
Posts: 62

Re: Setting up a small web server [complete guide with first steps]

Nice tutorial smile
I'm more of an nginx guy myself (not that i've used both a lot) but this might still get useful if I ever need for some reasons to use lighttpd.

Just a question, why hide the server type and version? Just to fool script kiddies using some automatic tool to search for vulnerable version of lighttpd in an exploit goes in the wild?

Offline

#7 2013-07-08 04:03:56

dimitrisp
ROCK & ROLL!!!!!!!
From: /dev/null
Registered: 2013-07-06
Posts: 65

Re: Setting up a small web server [complete guide with first steps]

Thank you both. smile
@Spittie3
Well, I've used both and there is no major difference. But I've found out lighttpd usually takes 2-3 mb less RAM than nginx on a busy website. At least that's what I got, right? And on 64mb RAM VPSes, even 1mb could make a difference!
In my lowendspirit vps I have:
- A shoutcast server
- lighttpd
- php-cgi
I haven't seen the RAM usage go higher than 9mb, and the average is 6.

As for the server type/version, yeap, that's exactly. They [the script kiddies] are becoming more and more each day that passes by smile


Love metal? http://www.distortionradio.gr/ | Powered by LowEndSpirit Hardware (at 50%)
GamePost.eu - New Gaming Community, with NMRiH & TF2 Servers (more to come soon)
If my posts have helped you in any way, send me some bitcoins: 1M5Vwki6qgwZKw3Q8wBQYC5cCy58UmGnM big_smile

Offline

#8 2014-08-08 16:28:21

FonFon
Trusted Member
Registered: 2014-08-07
Posts: 5

Re: Setting up a small web server [complete guide with first steps]

Hi,

I already following your guide, but the webserver isnt running.

DONE -> 1. Change your SSH port. [Hint: the file is /etc/ssh/sshd_config]
DONE -> 2. Ask for the public IP of your VPS, by opening a ticket. (no longer needed as the IP is in the VPS Info email)
DONE -> 3. Create an A Record from a domain you own to that IP. If you don't have a domain, you can always get a free .TK domain.
DONE -> 4. Open a new ticket and supply the domain/subdomain you used on the previous step, and ask for the reverse proxy to be enabled for you.

My best regards,

Offline

#9 2014-08-08 21:02:12

mikho
Low End Mod
From: Hell and gore == Sweden
Registered: 2013-03-02
Posts: 1,356
Website

Re: Setting up a small web server [complete guide with first steps]

Did you get a reply on your ticket that the reverse proxy was setup?
Do your webserver listen on port 80?

One thing I noticed when my site http://snap.sx was reported offline, if you are running nginx, is that the listen [::]:80 is no longer working for ipv4 with the latest version of nginx.

If you want it to listen on both ipv4 and ipv6 you need to add one extra "listen" row.
Listen 80;
Listen [::]:80 ipv6only;

Theres even a bug report about this.

Offline

#10 2014-08-09 20:27:24

FonFon
Trusted Member
Registered: 2014-08-07
Posts: 5

Re: Setting up a small web server [complete guide with first steps]

mikho wrote:

Did you get a reply on your ticket that the reverse proxy was setup?
Do your webserver listen on port 80?

One thing I noticed when my site http://snap.sx was reported offline, if you are running nginx, is that the listen [::]:80 is no longer working for ipv4 with the latest version of nginx.

If you want it to listen on both ipv4 and ipv6 you need to add one extra "listen" row.
Listen 80;
Listen [::]:80 ipv6only;

Theres even a bug report about this.

Done, thx u. I reinstall the OS and currently the webserver working properly.

Offline

#11 2014-08-28 01:47:49

obakfahad
Careless Introvert Semi-Geek
From: Dhaka, Bangladesh
Registered: 2013-10-07
Posts: 20
Website

Re: Setting up a small web server [complete guide with first steps]

dimitrisp wrote:

So, you want to use lighttpd on a different port than 80. Maybe you already use the reverse proxy for something else? Well, no worries. We just have to do 2 more small modifications!
............................

Thanks. smile

Offline

#12 2015-04-08 19:26:21

valvalosch
Trusted Member
Registered: 2013-12-23
Posts: 8

Re: Setting up a small web server [complete guide with first steps]

Has anybody tried configuring https with this setup? I think i will give it a try this weekend.

Offline

Board footer