31

Having just updated to the newest Windows 10 release (build 14316), I immediately started playing with WSL, the Windows Subsystem for Linux, which is supposed to run an Ubuntu installation on Windows.

Maybe I'm trying the impossible by trying to install Apache on it, but then someone please explain me why this won't be possible.

At any rate, during installation (sudo apt-get install apache2), I received the following error messages after the dependencies were downloaded and installed correctly:

initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: No such file or directory
runlevel:/var/run/utmp: No such file or directory
 * Starting web server apache2                                                 *
 * The apache2 configtest failed.
Output of config test was:
mktemp: failed to create directory via template '/var/lock/apache2.XXXXXXXXXX': No such file or directory
chmod: missing operand after '755'
Try 'chmod --help' for more information.
invoke-rc.d: initscript apache2, action "start" failed.
Setting up ssl-cert (1.0.33) ...
Processing triggers for libc-bin (2.19-0ubuntu6.7) ...
Processing triggers for ureadahead (0.100.0-16) ...
Processing triggers for ufw (0.34~rc-0ubuntu2) ...
WARN: / is group writable!

Now, I understand that there seem to be some folders and files missing for Apache2 to work. Before I start changing anything that will mess with my Windows installation, I want to ask whether there's a different way? Also, should I worry about / being group writable or is this just standard Windows behaviour?

Cydrick Trudel
  • 9,957
  • 8
  • 41
  • 63
bluppfisk
  • 2,538
  • 3
  • 27
  • 56

4 Answers4

63

In order to eliminate this warning

Invalid argument: AH00076: Failed to enable APR_TCP_DEFER_ACCEP

Add this to the end of /etc/apache2/apache2.conf

AcceptFilter http none
Ahmad Alfy
  • 13,107
  • 6
  • 65
  • 99
Alberto.d72
  • 639
  • 1
  • 4
  • 2
18

Note the following in your output

failed to create directory via template '/var/lock/apache2.XXXXXXXXXX': No such file 

I tried listing /var/lock. It points to /run/lock, which doesn't exist.

Create the directory with

mkdir -p /run/lock

The install should now work (you may need to clean the installation first)

apache running on Windows Ubuntu

Erez A. Korn
  • 2,697
  • 3
  • 24
  • 32
  • Thanks. I tried this, but it still gives me errors, most notably: initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: No such file or directory [Mon Apr 11 01:30:25.532677 2016] [core:crit] [pid 3046:tid 140694537176960] (22)Invalid argument: AH00069: make_sock: for address [::]:80, apr_socket_opt_set: (IPV6_V6ONLY) (22)Invalid argument: AH00072: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down AH00015: Unable to open logs – bluppfisk Apr 11 '16 at 01:32
  • Is it possible you have another server listening on port 80? I know it's trivial, but it happens to the best of us. Try changing the listening socket in the conf file? – Erez A. Korn Apr 12 '16 at 08:42
  • 1
    You are approach is working for me. However, I still got these two errors, but apache is up and running :)!: `[Tue Apr 12 12:31:22.726611 2016] [core:crit] [pid 979:tid 140694537176960] (22)Invalid argument: AH00069: make_sock: for address [::]:80, apr_socket_opt_set: (IPV6_V6ONLY)` and `[Tue Apr 12 12:31:22.726611 2016] [core:warn] [pid 979:tid 140694537176960] (22)Invalid argument: AH00076: Failed to enable APR_TCP_DEFER_ACCEPT` – Laurens Apr 12 '16 at 12:34
  • Running it on port 100 worked. Yielding the same errors as reported by Laurens, but still, working. However, I can't see what runs on port 80. lsof -i :80 doesn't return anything (nor does lsof -i). – bluppfisk Apr 13 '16 at 10:42
  • I'm guessing it's on the Windows machine itself, rather than a process in WSL. Do you have IIS installed? – Erez A. Korn Apr 14 '16 at 06:08
  • 2
    You were right, Skype was listening on port 80. Many thanks – bluppfisk Apr 14 '16 at 10:38
  • How can you view the files on this apache on the browser when localhost open the IIS locahost? – indago Aug 02 '16 at 07:06
16

You have to start bash.exe in administrator mode to avoid a lot of problems related to network. i installed Lamp (Apache/MySQL/Php) without any problem :

  • Start bash.exe in administrator mode

  • type : sudo apt-get install lamp-server^

  • add these 2 lines in /etc/apache2/apache2.conf :

Servername localhost

AcceptFilter http none

then you can start apache : /etc/init.d/apache2 start

cetipabo
  • 453
  • 5
  • 12
  • 2
    Thanks for the info. This works for me even **without administrator mode.** The only difference, I **restarted Apache right after install.** – Maris B. Jan 24 '17 at 12:53
  • @MarisB. is completely right. You'll need to restart the service right after install to make it work. – NullPointerException Oct 26 '17 at 15:34
  • I tried sudo apt-get install lamp-server but it fails to get the php packages and there seems to be no apache2 directory so I think the entire thing fails once it can't get the remaining 30% of packages. `404 Not Found [IP: 91.189.88.149 80] Err:7 http://security.ubuntu.com/ubuntu bionic-updates/main amd64 php7.2-mysql amd64 7.2.17-0ubuntu0.18.04.1 404 Not Found [IP: 91.189.88.149 80] E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/p/php7.2/php7.2-common_7.2.17-0ubuntu0.18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.149 80] ` – RiCHiE Jun 07 '19 at 12:43
  • `E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/p/php7.2/libapache2-mod-php7.2_7.2.17-0ubuntu0.18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.149 80] E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/p/php7.2/php7.2-mysql_7.2.17-0ubuntu0.18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.149 80] E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?` – RiCHiE Jun 07 '19 at 12:46
4

Following the great advice here I edited apache2.conf and inserted the following to end of file after receiving all the various errors above and apache2 then worked great on the debian wsl package:

Servername localhost
AcceptFilter http none
AcceptFilter https none
brandeded
  • 2,080
  • 6
  • 25
  • 52
Alpha
  • 41
  • 1