python2 -m SimpleHTTPServer 80
python3 -m http.server 80
to start a simple HTTP server.
Replace 80 with another number if you want it to listen on a different port. For ports < 1024 it needs to run with root privileges.
To expound on the answer by @33833 you can get some very detailed info, for example:
$ lsof -i :8000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
squid3 1289 proxy 15u IPv6 14810490 0t0 TCP *:8000 (LISTEN)
$ ps -fp 1289
UID PID PPID C STIME TTY TIME CMD
proxy 1289 1 0 09:48 ? 00:00:00 /usr/sbin/...
From man ln:
By default, each destination (name of new link) should not already exist.
As you already have a directory named html, the link will be created inside /var/www/html having the name of the target i.e. project.
If you want to have a symlink /var/www/html pointing to /home/user/project then you should not have the directory html present ...
Ubuntu doesn't use httpd.conf as standard, instead global configuration stuff for apache is found in /etc/apache2/apache2.conf. You can create a httpd.conf in the apache2 directory, and load any further configuration from it by including the following line in /etc/apache2/apache2.conf.
You don't need that file to configure ...
Ubuntu ships using python3 as its default, and they have gone to great lengths to make this extremely easy for us :D
To start the http server on port port simply type
python -m http.server port
If you want to share files and dirs, cd into whichever directory you want to serve
python -m http.server 8080
Should you want to use an ...
You should never have to run a website from within your home directory. EVER. You would otherwise have to give the web server the ability to traverse through /home/ to see the directory structure, but also into /home/$USER/ (your user's home directory, where we can try and see what else exists in your user directory), as well as any other subfolders in ...
The files are not world writeable. They are restricted to the owner of the files for writing.
The web server has to be run under a specific user. That user must exist.
If it were run under root, then all the files would have to be accessible by root and the user would need to be root to access the files. With root being the owner, a ...
Here is a list of HTTP server in one line. I'm sure there is one that will fit your purposes/existing tooling.
Hereafter is a subset of the link, that contains in my opinion the most convenient ones.
python -m http.server 8000
ruby -run -ehttpd . -p8000
npm install -g http-server
http-server -p 8000
php -S 127.0.0.1:8000
www-data is the user that web servers on Ubuntu (Apache, nginx, for example) use by default for normal operation. The web server process can access any file that www-data can access. It has no other importance.
From the base-passwd documentation (/usr/share/doc/base-passwd/users-and-groups.txt.gz):
Some web servers run as www-data. Web content should not ...
You can also use ansible to accomplish this.
Copy to remote host using ansible's copy module:
ansible -i HOST, -b -m copy -a "src=SRC_FILEPATH dest=DEST_FILEPATH" all
Fetch from remote host using ansible's fetch module:
ansible -i HOST, -b -m fetch -a "src=SRC_FILEPATH dest=DEST_FILEPATH flat=yes" all
The comma in the -i HOST, ...
I also like to use PHP for this purpose, as it enables me to run stuff like WordPress on the fly and develop themes more easily (you still need MySQL, though):
php -S 0.0.0.0:8000
In the same script that starts this I also start guard, which auto-refreshes the browser on file change.
Andrew Chan provided the right answer for me. To extend his answer a bit, here's what you can do on the commandline;
sudo systemctl stop apache2.service
prevent apache2 to start at boot
sudo systemctl disable apache2.service
sudo apt-get install nginx
I had this problem recently with a nodejs HTTPS server, and the solution to it was not to use "localhost", "127.0.0.1" or even the domain name. It was to use "0.0.0.0"
I believe this acts as a wildcard, now allowing for public resolution via the domain name and it also works with "localhost"
Edit: Here's a link to a serverfault page on the 0.0.0.0 topic: ...
A very simple solution which I (the linux noob) had to dig up... is to create the file.
and fill it with the default content from the mysql-common 5.7.11-0ubuntu6 package.
# The MySQL database server configuration file.
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set ...
httpd.conf will be in /etc/apache2/.
apache2.conf envvars mods-available ports.conf sites-enabled
conf.d httpd.conf mods-enabled sites-available
:/etc/apache2$ more httpd.conf
I need to change it
No, you do not. The documentation states:
httpd.conf: historically the main Apache2 configuration file, ...
May be the best way is to use rsync (Cygwin/cwRsync in Windows) over SSH?
For example, to upload files with owner www-data:
rsync -a --rsync-path="sudo -u www-data rsync" path_to_local_data/ email@example.com:/var/www
In your case, if you need root privileges, command will be like this:
rsync -a --rsync-path="sudo rsync" path_to_local_data/ login@...
Based on the versions of those packages, this appears to be Ubuntu Hardy 8.04 LTS. That's over five years old. Despite its age, official support only ended in May 2013 but it's never going to get security updates any longer and that's a problem.
The versions listed above were published in 2010 and that should highlight the urgency of the task at hand. This ...
Ubuntu Server is designed to be a scale out server operating system for professionals.
It's a stripped down OS with no frills attached. The target audience for Ubuntu Server is someone who is comfortable with the command line. Some would even make the argument that it's not designed for the command line, it's so stripped down that it's designed to be driven ...
You can add a /etc/hosts entry like the following:
Make sure to use a lo address unused before.
Then you add an iptables rule to redirect the traffic incoming into 127.0.0.2:8080 to 127.0.0.1:80.
iptables -t nat -A OUTPUT -d 127.0.0.2 -p tcp --dport 80 -j REDIRECT --to-port 8080
Get your ip address by googling "what is my ip address". Then take that ip address and add an A record for your domain that points to that ip.
If the computer that's hosting the site connects to the internet through a router then you will need to log into the admin gateway for that router by typing your default gateway ip address into the address bar in any ...