Windows Subsystem for Linux Autoload Apache2 and MySql

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
0
down vote

favorite












I have activated the Developer Platform in Windows and installed Ubuntu VIA Windows Store which works fabulous! Only thing I need is when I "Activate" Ubuntu Apache2 and MySql does not autostart.



Is there a simple way to make this happen under this Platform? When I open Bash, I can just manually start the Services but Auto Start would be preferred. I have tried using a cron job but the services never started, perhaps my syntax was wrong?



PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
@reboot . $HOME/.profile; /usr/sbin/sshd -D
@reboot . $HOME/.profile; service mysql start
@reboot . $HOME/.profile; service apache2 start









share|improve this question























  • superuser.com/questions/1112007/…
    – Panther
    Mar 31 at 13:20










  • First step of that process yeilded this.... Steve@steve:~$ sudo dpkg-reconfigure openssh-server invoke-rc.d: could not determine current runlevel
    – EODCraft Staff
    Mar 31 at 13:25







  • 2




    You may need to file a bug report with Microsoft. See links in that discussion.
    – Panther
    Mar 31 at 13:34














up vote
0
down vote

favorite












I have activated the Developer Platform in Windows and installed Ubuntu VIA Windows Store which works fabulous! Only thing I need is when I "Activate" Ubuntu Apache2 and MySql does not autostart.



Is there a simple way to make this happen under this Platform? When I open Bash, I can just manually start the Services but Auto Start would be preferred. I have tried using a cron job but the services never started, perhaps my syntax was wrong?



PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
@reboot . $HOME/.profile; /usr/sbin/sshd -D
@reboot . $HOME/.profile; service mysql start
@reboot . $HOME/.profile; service apache2 start









share|improve this question























  • superuser.com/questions/1112007/…
    – Panther
    Mar 31 at 13:20










  • First step of that process yeilded this.... Steve@steve:~$ sudo dpkg-reconfigure openssh-server invoke-rc.d: could not determine current runlevel
    – EODCraft Staff
    Mar 31 at 13:25







  • 2




    You may need to file a bug report with Microsoft. See links in that discussion.
    – Panther
    Mar 31 at 13:34












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have activated the Developer Platform in Windows and installed Ubuntu VIA Windows Store which works fabulous! Only thing I need is when I "Activate" Ubuntu Apache2 and MySql does not autostart.



Is there a simple way to make this happen under this Platform? When I open Bash, I can just manually start the Services but Auto Start would be preferred. I have tried using a cron job but the services never started, perhaps my syntax was wrong?



PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
@reboot . $HOME/.profile; /usr/sbin/sshd -D
@reboot . $HOME/.profile; service mysql start
@reboot . $HOME/.profile; service apache2 start









share|improve this question















I have activated the Developer Platform in Windows and installed Ubuntu VIA Windows Store which works fabulous! Only thing I need is when I "Activate" Ubuntu Apache2 and MySql does not autostart.



Is there a simple way to make this happen under this Platform? When I open Bash, I can just manually start the Services but Auto Start would be preferred. I have tried using a cron job but the services never started, perhaps my syntax was wrong?



PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
@reboot . $HOME/.profile; /usr/sbin/sshd -D
@reboot . $HOME/.profile; service mysql start
@reboot . $HOME/.profile; service apache2 start






16.04 bash apache2 mysql windows-subsystem-for-linux






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 31 at 21:52

























asked Mar 31 at 13:15









EODCraft Staff

367316




367316











  • superuser.com/questions/1112007/…
    – Panther
    Mar 31 at 13:20










  • First step of that process yeilded this.... Steve@steve:~$ sudo dpkg-reconfigure openssh-server invoke-rc.d: could not determine current runlevel
    – EODCraft Staff
    Mar 31 at 13:25







  • 2




    You may need to file a bug report with Microsoft. See links in that discussion.
    – Panther
    Mar 31 at 13:34
















  • superuser.com/questions/1112007/…
    – Panther
    Mar 31 at 13:20










  • First step of that process yeilded this.... Steve@steve:~$ sudo dpkg-reconfigure openssh-server invoke-rc.d: could not determine current runlevel
    – EODCraft Staff
    Mar 31 at 13:25







  • 2




    You may need to file a bug report with Microsoft. See links in that discussion.
    – Panther
    Mar 31 at 13:34















superuser.com/questions/1112007/…
– Panther
Mar 31 at 13:20




superuser.com/questions/1112007/…
– Panther
Mar 31 at 13:20












First step of that process yeilded this.... Steve@steve:~$ sudo dpkg-reconfigure openssh-server invoke-rc.d: could not determine current runlevel
– EODCraft Staff
Mar 31 at 13:25





First step of that process yeilded this.... Steve@steve:~$ sudo dpkg-reconfigure openssh-server invoke-rc.d: could not determine current runlevel
– EODCraft Staff
Mar 31 at 13:25





2




2




You may need to file a bug report with Microsoft. See links in that discussion.
– Panther
Mar 31 at 13:34




You may need to file a bug report with Microsoft. See links in that discussion.
– Panther
Mar 31 at 13:34










1 Answer
1






active

oldest

votes

















up vote
2
down vote













Found It!!!!! Although not elegant.



Instead of looping or sleeping just add "bash" to the end of the shell script. Here are my scripts for apache and mysql to run on startup.



VBS file (runs on startup) Win + r shell:startup create autostart.vbs



Set WshShell = CreateObject("WScript.Shell") 
WshShell.Run "C:WindowsSystem32bash.exe -c ~/autostart.sh",0
Set WshShell = Nothing


autostart.sh file (Just make this in your Home Folder, chmod +x runnable)



#!/bin/bash
sudo service mysql start
sudo service apache2 start
bash


and in /etc/sudoers (Append to the end of the file)



# Allow apache2 and mysql to start without a sudo password
%sudo ALL=(ALL) NOPASSWD: /usr/sbin/service apache2 *
%sudo ALL=(ALL) NOPASSWD: /usr/sbin/service mysql *


If I need to kill it all I can find the bash process in Task Manager and kill that.



Credit: https://github.com/mstrelan






share|improve this answer






















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1020837%2fwindows-subsystem-for-linux-autoload-apache2-and-mysql%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    Found It!!!!! Although not elegant.



    Instead of looping or sleeping just add "bash" to the end of the shell script. Here are my scripts for apache and mysql to run on startup.



    VBS file (runs on startup) Win + r shell:startup create autostart.vbs



    Set WshShell = CreateObject("WScript.Shell") 
    WshShell.Run "C:WindowsSystem32bash.exe -c ~/autostart.sh",0
    Set WshShell = Nothing


    autostart.sh file (Just make this in your Home Folder, chmod +x runnable)



    #!/bin/bash
    sudo service mysql start
    sudo service apache2 start
    bash


    and in /etc/sudoers (Append to the end of the file)



    # Allow apache2 and mysql to start without a sudo password
    %sudo ALL=(ALL) NOPASSWD: /usr/sbin/service apache2 *
    %sudo ALL=(ALL) NOPASSWD: /usr/sbin/service mysql *


    If I need to kill it all I can find the bash process in Task Manager and kill that.



    Credit: https://github.com/mstrelan






    share|improve this answer


























      up vote
      2
      down vote













      Found It!!!!! Although not elegant.



      Instead of looping or sleeping just add "bash" to the end of the shell script. Here are my scripts for apache and mysql to run on startup.



      VBS file (runs on startup) Win + r shell:startup create autostart.vbs



      Set WshShell = CreateObject("WScript.Shell") 
      WshShell.Run "C:WindowsSystem32bash.exe -c ~/autostart.sh",0
      Set WshShell = Nothing


      autostart.sh file (Just make this in your Home Folder, chmod +x runnable)



      #!/bin/bash
      sudo service mysql start
      sudo service apache2 start
      bash


      and in /etc/sudoers (Append to the end of the file)



      # Allow apache2 and mysql to start without a sudo password
      %sudo ALL=(ALL) NOPASSWD: /usr/sbin/service apache2 *
      %sudo ALL=(ALL) NOPASSWD: /usr/sbin/service mysql *


      If I need to kill it all I can find the bash process in Task Manager and kill that.



      Credit: https://github.com/mstrelan






      share|improve this answer
























        up vote
        2
        down vote










        up vote
        2
        down vote









        Found It!!!!! Although not elegant.



        Instead of looping or sleeping just add "bash" to the end of the shell script. Here are my scripts for apache and mysql to run on startup.



        VBS file (runs on startup) Win + r shell:startup create autostart.vbs



        Set WshShell = CreateObject("WScript.Shell") 
        WshShell.Run "C:WindowsSystem32bash.exe -c ~/autostart.sh",0
        Set WshShell = Nothing


        autostart.sh file (Just make this in your Home Folder, chmod +x runnable)



        #!/bin/bash
        sudo service mysql start
        sudo service apache2 start
        bash


        and in /etc/sudoers (Append to the end of the file)



        # Allow apache2 and mysql to start without a sudo password
        %sudo ALL=(ALL) NOPASSWD: /usr/sbin/service apache2 *
        %sudo ALL=(ALL) NOPASSWD: /usr/sbin/service mysql *


        If I need to kill it all I can find the bash process in Task Manager and kill that.



        Credit: https://github.com/mstrelan






        share|improve this answer














        Found It!!!!! Although not elegant.



        Instead of looping or sleeping just add "bash" to the end of the shell script. Here are my scripts for apache and mysql to run on startup.



        VBS file (runs on startup) Win + r shell:startup create autostart.vbs



        Set WshShell = CreateObject("WScript.Shell") 
        WshShell.Run "C:WindowsSystem32bash.exe -c ~/autostart.sh",0
        Set WshShell = Nothing


        autostart.sh file (Just make this in your Home Folder, chmod +x runnable)



        #!/bin/bash
        sudo service mysql start
        sudo service apache2 start
        bash


        and in /etc/sudoers (Append to the end of the file)



        # Allow apache2 and mysql to start without a sudo password
        %sudo ALL=(ALL) NOPASSWD: /usr/sbin/service apache2 *
        %sudo ALL=(ALL) NOPASSWD: /usr/sbin/service mysql *


        If I need to kill it all I can find the bash process in Task Manager and kill that.



        Credit: https://github.com/mstrelan







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 1 at 8:53









        pa4080

        12.2k52256




        12.2k52256










        answered Mar 31 at 21:46









        EODCraft Staff

        367316




        367316



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1020837%2fwindows-subsystem-for-linux-autoload-apache2-and-mysql%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            pylint3 and pip3 broken

            Missing snmpget and snmpwalk

            How to enroll fingerprints to Ubuntu 17.10 with VFS491