# [Solved] Local host site.

## The_Document

I would like to add a local site accessable to me via localhost in the same way cups has its web interface on my machine its http://localhost:631/ how do I configure things so I can have maybe http://localhost:<my-site>

were do files go and how do I add this?Last edited by The_Document on Fri Mar 02, 2018 9:26 pm; edited 1 time in total

----------

## pjp

You would need to install a web server such as Apache or Nginx.

You'd then need to "create a website" and tell the web server how to serve the website.

You can find examples of how to create a "Hello World" website, but depending on what you wan to do, it can be a very involved project.

----------

## The_Document

 *pjp wrote:*   

> You would need to install a web server such as Apache or Nginx.
> 
> You'd then need to "create a website" and tell the web server how to serve the website.
> 
> You can find examples of how to create a "Hello World" website, but depending on what you wan to do, it can be a very involved project.

 

I already have cups web admin ui didn't it come with an http server?

----------

## pjp

I don't use cups. If it requires a separate package, then yes, it should have pulled something in.

Do you have any web servers installed?

----------

## The_Document

 *pjp wrote:*   

> I don't use cups. If it requires a separate package, then yes, it should have pulled something in.
> 
> Do you have any web servers installed?

 

Nope, wonder how cups web ui works.

----------

## pjp

Providing a server isn't necessarily that difficult (the trick is doing it well). It's just something they've built into the app. The back-end generates the "web page," the browser renders / displays it. (I'm guessing).

For example, you could -- but shouldn't unless you "know what you're doing" -- do this with python:

```
$ python -m http.server 8080 --bind 127.0.0.1

Serving HTTP on 127.0.0.1 port 8080 ...

127.0.0.1 - - [28/Feb/2018 22:09:52] "GET / HTTP/1.1" 200 -
```

```
$ curl localhost:8080

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>

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

<title>Directory listing for /</title>

</head>

<body>

<h1>Directory listing for /</h1>

<hr>

<ul>

</ul>

<hr>

</body>

</html>
```

----------

## 1clue

I don't use cups either, but I believe it used to contain its own web server. At any rate you probably don't want to mess with it.

I'd stick with apache2 or nginx. Compare features of them and see what appeals most. I've only ever used apache2, which can do pretty much anything. I've heard nginx is easier to configure, but apache2 is ready to go for basic stuff, only a small amount of configuration to get it working.

----------

## fedeliallalinea

There is also www-servers/lighttpd

----------

## khayyam

The_Document ... it depends a little on what you intend to serve, but if your needs are minimal then the following will suffice:

```
# mkdir -p /var/www/localhost

# busybox httpd -u nobody -p 127.0.0.1:80 -h /var/www/localhost

# netstat -plnt | grep ':80'

tcp   0   0 127.0.0.1:80   0.0.0.0:*   LISTEN  32471/busybox

# touch /var/www/localhost/index.html

# wget --spider localhost

Spider mode enabled. Check if remote file exists.

--2018-03-01 12:02:27--  http://localhost/

Resolving localhost... 127.0.0.1, 127.0.0.1

Connecting to localhost|127.0.0.1|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 0 [text/html]

Remote file exists and could contain further links,

but recursion is disabled -- not retrieving.
```

HTH & best ... khay

----------

## cwr

I'd go with Lighttpd - I use it for a number of odd jobs, serving Mercurial projects and documentation

among them, and it's very easy to set up, a lot easier than Apache.

Will

----------

## 1clue

It's not really a good idea to recommend a specific web server without knowing something of the nature of the material being served.

If it's all static content, then the lightest and simplest option will likely be a good choice.

If it's going to link to some sort of web application then the correct choice depends on what language the webapp is written in. For example, if you're using Java-based wars you might consider Apache Tomcat. If you're using PHP then you might consider nginx or apache2.

I could go on but would rather not fill up the thread with useless junk.

----------

