221

Use python2 -m SimpleHTTPServer 80 or 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.


177

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/...


148

Shutting down apache2 first before installing nginx should fix this problem: sudo service apache2 stop


139

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 ...


130

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. Include /etc/apache2/httpd.conf You don't need that file to configure ...


98

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 cd /my/html/files python -m http.server 8080 Should you want to use an ...


87

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 ...


83

Quick way From server to local machine: ssh user@server "sudo cat /etc/dir/file" > /home/user/file From local machine to server: cat /home/user/file | ssh user@server "sudo tee -a /etc/dir/file"


64

For security. 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 ...


50

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: python -m http.server 8000 Ruby: ruby -run -ehttpd . -p8000 Node: npm install -g http-server http-server -p 8000 Php: php -S 127.0.0.1:8000


48

Enter this command: sudo update-rc.d mysql defaults


35

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 ...


31

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 NOTE: The comma in the -i HOST, ...


29

For VSFTPD 3, Go to: /etc/vsftpd.conf and add this: allow_writeable_chroot=YES Just add it if it does not exist yet. Restart the vsftpd service: service vsftpd restart And it should work.


29

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.


28

Andrew Chan provided the right answer for me. To extend his answer a bit, here's what you can do on the commandline; stop apache2 sudo systemctl stop apache2.service prevent apache2 to start at boot sudo systemctl disable apache2.service Reinstall nginx sudo apt-get install nginx


20

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: ...


18

if you are more ruby minded, the serve gem is great serve or for i different port: serve 9000 install with gem install serve


18

A very simple solution which I (the linux noob) had to dig up... is to create the file. nano /etc/mysql/my.cnf.fallback 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 ...


18

httpd.conf will be in /etc/apache2/. /etc/apache2$ ls apache2.conf envvars mods-available ports.conf sites-enabled conf.d httpd.conf mods-enabled sites-available :/etc/apache2$ more httpd.conf :/etc/apache2$ I need to change it No, you do not. The documentation states: httpd.conf: historically the main Apache2 configuration file, ...


16

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/ login@srv01.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@...


16

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 ...


16

This is also possible in Ruby without installing a gem. ruby -run -e httpd . -p5000


15

You're mostly there. Just fix your syntax: if curl -s "$webserv" | grep "$keyword" then # if the keyword is in the conent echo " the website is working fine" else echo "Error" fi Note the then and fi.


14

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 ...


10

You can add a /etc/hosts entry like the following: 127.0.0.2 my-domain.com 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


10

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 ...


Only top voted, non community-wiki answers of a minimum length are eligible