How do I install Apache as a “service unit”?

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











up vote
0
down vote

favorite












I wanted to run Apache as a service so it will start on bootup, so I tried:



sudo systemctl start apache2.service



but got the error:




Failed to start apache2.service: Unit apache2.service not found.




So, apparently I need to install apache as a "service unit". The Apache documentation does not appear to have information on how to do this, just the old confusing init.d instructions which do not work anymore.










share|improve this question



















  • 1




    Did you actually install apache2?
    – Nasir Riley
    yesterday










  • @NasirRiley Yes, works fine. I usually start it with apachectl but I would like to start it as a service now (or some kind of startup script) so that it starts automatically on boot.
    – Tyler Durden
    yesterday










  • What Debian is that?
    – Tomasz
    yesterday






  • 1




    What do you get from systemctl list-unit-files | grep apache? Also, did you install it via apt or did you compile it from source?
    – Nasir Riley
    yesterday











  • @NasirRiley I get nothing when I enter that. I built it from source, but added many features. Possibly I missed the one that automatically enables it to run as a service?
    – Tyler Durden
    yesterday














up vote
0
down vote

favorite












I wanted to run Apache as a service so it will start on bootup, so I tried:



sudo systemctl start apache2.service



but got the error:




Failed to start apache2.service: Unit apache2.service not found.




So, apparently I need to install apache as a "service unit". The Apache documentation does not appear to have information on how to do this, just the old confusing init.d instructions which do not work anymore.










share|improve this question



















  • 1




    Did you actually install apache2?
    – Nasir Riley
    yesterday










  • @NasirRiley Yes, works fine. I usually start it with apachectl but I would like to start it as a service now (or some kind of startup script) so that it starts automatically on boot.
    – Tyler Durden
    yesterday










  • What Debian is that?
    – Tomasz
    yesterday






  • 1




    What do you get from systemctl list-unit-files | grep apache? Also, did you install it via apt or did you compile it from source?
    – Nasir Riley
    yesterday











  • @NasirRiley I get nothing when I enter that. I built it from source, but added many features. Possibly I missed the one that automatically enables it to run as a service?
    – Tyler Durden
    yesterday












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I wanted to run Apache as a service so it will start on bootup, so I tried:



sudo systemctl start apache2.service



but got the error:




Failed to start apache2.service: Unit apache2.service not found.




So, apparently I need to install apache as a "service unit". The Apache documentation does not appear to have information on how to do this, just the old confusing init.d instructions which do not work anymore.










share|improve this question















I wanted to run Apache as a service so it will start on bootup, so I tried:



sudo systemctl start apache2.service



but got the error:




Failed to start apache2.service: Unit apache2.service not found.




So, apparently I need to install apache as a "service unit". The Apache documentation does not appear to have information on how to do this, just the old confusing init.d instructions which do not work anymore.







debian apache-httpd






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday

























asked yesterday









Tyler Durden

1,48641849




1,48641849







  • 1




    Did you actually install apache2?
    – Nasir Riley
    yesterday










  • @NasirRiley Yes, works fine. I usually start it with apachectl but I would like to start it as a service now (or some kind of startup script) so that it starts automatically on boot.
    – Tyler Durden
    yesterday










  • What Debian is that?
    – Tomasz
    yesterday






  • 1




    What do you get from systemctl list-unit-files | grep apache? Also, did you install it via apt or did you compile it from source?
    – Nasir Riley
    yesterday











  • @NasirRiley I get nothing when I enter that. I built it from source, but added many features. Possibly I missed the one that automatically enables it to run as a service?
    – Tyler Durden
    yesterday












  • 1




    Did you actually install apache2?
    – Nasir Riley
    yesterday










  • @NasirRiley Yes, works fine. I usually start it with apachectl but I would like to start it as a service now (or some kind of startup script) so that it starts automatically on boot.
    – Tyler Durden
    yesterday










  • What Debian is that?
    – Tomasz
    yesterday






  • 1




    What do you get from systemctl list-unit-files | grep apache? Also, did you install it via apt or did you compile it from source?
    – Nasir Riley
    yesterday











  • @NasirRiley I get nothing when I enter that. I built it from source, but added many features. Possibly I missed the one that automatically enables it to run as a service?
    – Tyler Durden
    yesterday







1




1




Did you actually install apache2?
– Nasir Riley
yesterday




Did you actually install apache2?
– Nasir Riley
yesterday












@NasirRiley Yes, works fine. I usually start it with apachectl but I would like to start it as a service now (or some kind of startup script) so that it starts automatically on boot.
– Tyler Durden
yesterday




@NasirRiley Yes, works fine. I usually start it with apachectl but I would like to start it as a service now (or some kind of startup script) so that it starts automatically on boot.
– Tyler Durden
yesterday












What Debian is that?
– Tomasz
yesterday




What Debian is that?
– Tomasz
yesterday




1




1




What do you get from systemctl list-unit-files | grep apache? Also, did you install it via apt or did you compile it from source?
– Nasir Riley
yesterday





What do you get from systemctl list-unit-files | grep apache? Also, did you install it via apt or did you compile it from source?
– Nasir Riley
yesterday













@NasirRiley I get nothing when I enter that. I built it from source, but added many features. Possibly I missed the one that automatically enables it to run as a service?
– Tyler Durden
yesterday




@NasirRiley I get nothing when I enter that. I built it from source, but added many features. Possibly I missed the one that automatically enables it to run as a service?
– Tyler Durden
yesterday










1 Answer
1






active

oldest

votes

















up vote
2
down vote













Building apache2 from source does not create a service for it. That is why you are getting the error that the service isn't found.



You will either need to create one manually or install apache2 via apt. The latter is much easier and you can also install all of the features that you added. To get it to run at boot, you will need to use systemctl enable apache2 after creating the service or installing apache2 via apt.






share|improve this answer




















  • Ok, so how do I manually create a service unit for Apache? That is the question?
    – Tyler Durden
    yesterday






  • 2




    You could just copy the apache2.service file from the Debian source, replace the paths to represent your source install, and place it in /etc/systemd/system/. After systemctl daemon-reload it should be available
    – GracefulRestart
    yesterday










  • @NasirRiley That's what systemctl enable apache2.service does (assuming the [Install] section has been correctly configured.) I'd recommend enabling it through systemctl enable rather than creating symbolic links by hand.
    – Filipe Brandenburger
    yesterday






  • 1




    Building it from the Debian source does include the service units, as well as a number of patches that make Apache use Debian paths and whatnot. The problem here is likely to be building from the wrong source.
    – JdeBP
    yesterday






  • 1




    @FilipeBrandenburger You are correct. It even says so when you run systemctl enable service. I'll remove that comment since it's uneccessary redundant.
    – Nasir Riley
    yesterday










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f481823%2fhow-do-i-install-apache-as-a-service-unit%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote













Building apache2 from source does not create a service for it. That is why you are getting the error that the service isn't found.



You will either need to create one manually or install apache2 via apt. The latter is much easier and you can also install all of the features that you added. To get it to run at boot, you will need to use systemctl enable apache2 after creating the service or installing apache2 via apt.






share|improve this answer




















  • Ok, so how do I manually create a service unit for Apache? That is the question?
    – Tyler Durden
    yesterday






  • 2




    You could just copy the apache2.service file from the Debian source, replace the paths to represent your source install, and place it in /etc/systemd/system/. After systemctl daemon-reload it should be available
    – GracefulRestart
    yesterday










  • @NasirRiley That's what systemctl enable apache2.service does (assuming the [Install] section has been correctly configured.) I'd recommend enabling it through systemctl enable rather than creating symbolic links by hand.
    – Filipe Brandenburger
    yesterday






  • 1




    Building it from the Debian source does include the service units, as well as a number of patches that make Apache use Debian paths and whatnot. The problem here is likely to be building from the wrong source.
    – JdeBP
    yesterday






  • 1




    @FilipeBrandenburger You are correct. It even says so when you run systemctl enable service. I'll remove that comment since it's uneccessary redundant.
    – Nasir Riley
    yesterday














up vote
2
down vote













Building apache2 from source does not create a service for it. That is why you are getting the error that the service isn't found.



You will either need to create one manually or install apache2 via apt. The latter is much easier and you can also install all of the features that you added. To get it to run at boot, you will need to use systemctl enable apache2 after creating the service or installing apache2 via apt.






share|improve this answer




















  • Ok, so how do I manually create a service unit for Apache? That is the question?
    – Tyler Durden
    yesterday






  • 2




    You could just copy the apache2.service file from the Debian source, replace the paths to represent your source install, and place it in /etc/systemd/system/. After systemctl daemon-reload it should be available
    – GracefulRestart
    yesterday










  • @NasirRiley That's what systemctl enable apache2.service does (assuming the [Install] section has been correctly configured.) I'd recommend enabling it through systemctl enable rather than creating symbolic links by hand.
    – Filipe Brandenburger
    yesterday






  • 1




    Building it from the Debian source does include the service units, as well as a number of patches that make Apache use Debian paths and whatnot. The problem here is likely to be building from the wrong source.
    – JdeBP
    yesterday






  • 1




    @FilipeBrandenburger You are correct. It even says so when you run systemctl enable service. I'll remove that comment since it's uneccessary redundant.
    – Nasir Riley
    yesterday












up vote
2
down vote










up vote
2
down vote









Building apache2 from source does not create a service for it. That is why you are getting the error that the service isn't found.



You will either need to create one manually or install apache2 via apt. The latter is much easier and you can also install all of the features that you added. To get it to run at boot, you will need to use systemctl enable apache2 after creating the service or installing apache2 via apt.






share|improve this answer












Building apache2 from source does not create a service for it. That is why you are getting the error that the service isn't found.



You will either need to create one manually or install apache2 via apt. The latter is much easier and you can also install all of the features that you added. To get it to run at boot, you will need to use systemctl enable apache2 after creating the service or installing apache2 via apt.







share|improve this answer












share|improve this answer



share|improve this answer










answered yesterday









Nasir Riley

2,126239




2,126239











  • Ok, so how do I manually create a service unit for Apache? That is the question?
    – Tyler Durden
    yesterday






  • 2




    You could just copy the apache2.service file from the Debian source, replace the paths to represent your source install, and place it in /etc/systemd/system/. After systemctl daemon-reload it should be available
    – GracefulRestart
    yesterday










  • @NasirRiley That's what systemctl enable apache2.service does (assuming the [Install] section has been correctly configured.) I'd recommend enabling it through systemctl enable rather than creating symbolic links by hand.
    – Filipe Brandenburger
    yesterday






  • 1




    Building it from the Debian source does include the service units, as well as a number of patches that make Apache use Debian paths and whatnot. The problem here is likely to be building from the wrong source.
    – JdeBP
    yesterday






  • 1




    @FilipeBrandenburger You are correct. It even says so when you run systemctl enable service. I'll remove that comment since it's uneccessary redundant.
    – Nasir Riley
    yesterday
















  • Ok, so how do I manually create a service unit for Apache? That is the question?
    – Tyler Durden
    yesterday






  • 2




    You could just copy the apache2.service file from the Debian source, replace the paths to represent your source install, and place it in /etc/systemd/system/. After systemctl daemon-reload it should be available
    – GracefulRestart
    yesterday










  • @NasirRiley That's what systemctl enable apache2.service does (assuming the [Install] section has been correctly configured.) I'd recommend enabling it through systemctl enable rather than creating symbolic links by hand.
    – Filipe Brandenburger
    yesterday






  • 1




    Building it from the Debian source does include the service units, as well as a number of patches that make Apache use Debian paths and whatnot. The problem here is likely to be building from the wrong source.
    – JdeBP
    yesterday






  • 1




    @FilipeBrandenburger You are correct. It even says so when you run systemctl enable service. I'll remove that comment since it's uneccessary redundant.
    – Nasir Riley
    yesterday















Ok, so how do I manually create a service unit for Apache? That is the question?
– Tyler Durden
yesterday




Ok, so how do I manually create a service unit for Apache? That is the question?
– Tyler Durden
yesterday




2




2




You could just copy the apache2.service file from the Debian source, replace the paths to represent your source install, and place it in /etc/systemd/system/. After systemctl daemon-reload it should be available
– GracefulRestart
yesterday




You could just copy the apache2.service file from the Debian source, replace the paths to represent your source install, and place it in /etc/systemd/system/. After systemctl daemon-reload it should be available
– GracefulRestart
yesterday












@NasirRiley That's what systemctl enable apache2.service does (assuming the [Install] section has been correctly configured.) I'd recommend enabling it through systemctl enable rather than creating symbolic links by hand.
– Filipe Brandenburger
yesterday




@NasirRiley That's what systemctl enable apache2.service does (assuming the [Install] section has been correctly configured.) I'd recommend enabling it through systemctl enable rather than creating symbolic links by hand.
– Filipe Brandenburger
yesterday




1




1




Building it from the Debian source does include the service units, as well as a number of patches that make Apache use Debian paths and whatnot. The problem here is likely to be building from the wrong source.
– JdeBP
yesterday




Building it from the Debian source does include the service units, as well as a number of patches that make Apache use Debian paths and whatnot. The problem here is likely to be building from the wrong source.
– JdeBP
yesterday




1




1




@FilipeBrandenburger You are correct. It even says so when you run systemctl enable service. I'll remove that comment since it's uneccessary redundant.
– Nasir Riley
yesterday




@FilipeBrandenburger You are correct. It even says so when you run systemctl enable service. I'll remove that comment since it's uneccessary redundant.
– Nasir Riley
yesterday

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f481823%2fhow-do-i-install-apache-as-a-service-unit%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown