Installing Apache Server on Ubuntu on Windows 10

Just some notes I wrote down when installing Apache Server running in the Ubuntu subsystem on Windows 10. This will assume that you have already got Ubuntu up and running on Windows. If you have not installed Ubuntu visit https://docs.microsoft.com/en-gb/windows/wsl/install-win10

Start up Ubuntu; which will open a terminal.

sudo -i

Typing sudo -i at the start will eliminate the need to type it for the rest of the commands. *If you don’t do sudo -i it just means you need to type sudo before the commands.

apt-get update
apt-get upgrade

We need to set up an ssh server, this might be installed already.

apt-get install openssh-server

It is best to take a copy of your openssh config before modifying. I use nano to edit conf files as I find it a simple to use interface. https://wiki.gentoo.org/wiki/Nano/Basics_Guide

cp -v /etc/ssh/sshd_config /etc/ssh/sshd_config.orig
nano /etc/ssh/sshd_config

We need to make the following changes to the conf file.

port 22 -> port 2222
PermitRootLogin Yes -> PermitRootLogin No

This change is only required if you are NOT using SSH keys.

PasswordAuthentication no   -> If you are using SSH keys
PasswordAuthentication yes  -> If you are using a Password and NOT using SSH keys

Uncomment the following:


Add the following lines:

AllowUsers userName
UseDNS no

Save Conf file and restart SSH

service ssh --full-restart

Next we install Apache

apt-get install apache2

Restart Apache Server and test your localhost

service apache2 restart

Install URL rewrite and headers mods

a2enmod rewrite
a2enmod headers
service apache2 restart

Local host should be up and running now with basic Apache index.html file. We can test this by typing localhost into a browser. We can also test the Apache configuration via the command line.

apache2ctl configtest

Apache is now up and running, you can test it in a web browser with http://localhost

Setting up Virtual Hosts in Apache?

I have written a blog post covering the topic of setting up multiple domains with vhost files in Apache. https://aimeemaree.com/virtual-sites-apache-ubuntu-windows-10/

Where does Ubuntu File system live?

I have written a blog post covering the topic of Ubuntu file location in Windows and Windows file system in Ubuntu. https://aimeemaree.com/ubuntu-files-on-windows-10/