What's the difference between starting nginx with command “nginx”, “service start nginx” and...





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I have noticed that when ever I start nginx with ubuntu command "nginx" and I do systemctl status nginx. It shows that systemctl is disabled. More over if I first start nginx with command systemctl start nginx and i try to start nginx with command nginx, it check the availbility of the ports and then says nginx: [emerg] still could not bind(). So i thought there must be a differene and their purpose. When I strt nginx with command nginx the only way to stop nginx is by the means of force using killlall nginx or kill -9 (process id) or by clearing the port. So I am pretty sure there is some difference in them.










share|improve this question























  • Not only got confused by nginx. I think you maybe confused by all processes that could be managed by systemctl and native command script. You should get some knowledge about systemctl, do not focus on nginx.

    – Light.G
    Jan 3 at 12:38











  • Thnks it helped me a lot but still its not clear why it is possible to start a process saperately with these two commands. That was the main reason I asked this question is the first place, nginx and systemctl start nginx if one is used and then it also tried to start the same demon with other command why? Thx for reply

    – Mahad Ali
    Jan 4 at 15:11


















0















I have noticed that when ever I start nginx with ubuntu command "nginx" and I do systemctl status nginx. It shows that systemctl is disabled. More over if I first start nginx with command systemctl start nginx and i try to start nginx with command nginx, it check the availbility of the ports and then says nginx: [emerg] still could not bind(). So i thought there must be a differene and their purpose. When I strt nginx with command nginx the only way to stop nginx is by the means of force using killlall nginx or kill -9 (process id) or by clearing the port. So I am pretty sure there is some difference in them.










share|improve this question























  • Not only got confused by nginx. I think you maybe confused by all processes that could be managed by systemctl and native command script. You should get some knowledge about systemctl, do not focus on nginx.

    – Light.G
    Jan 3 at 12:38











  • Thnks it helped me a lot but still its not clear why it is possible to start a process saperately with these two commands. That was the main reason I asked this question is the first place, nginx and systemctl start nginx if one is used and then it also tried to start the same demon with other command why? Thx for reply

    – Mahad Ali
    Jan 4 at 15:11














0












0








0








I have noticed that when ever I start nginx with ubuntu command "nginx" and I do systemctl status nginx. It shows that systemctl is disabled. More over if I first start nginx with command systemctl start nginx and i try to start nginx with command nginx, it check the availbility of the ports and then says nginx: [emerg] still could not bind(). So i thought there must be a differene and their purpose. When I strt nginx with command nginx the only way to stop nginx is by the means of force using killlall nginx or kill -9 (process id) or by clearing the port. So I am pretty sure there is some difference in them.










share|improve this question














I have noticed that when ever I start nginx with ubuntu command "nginx" and I do systemctl status nginx. It shows that systemctl is disabled. More over if I first start nginx with command systemctl start nginx and i try to start nginx with command nginx, it check the availbility of the ports and then says nginx: [emerg] still could not bind(). So i thought there must be a differene and their purpose. When I strt nginx with command nginx the only way to stop nginx is by the means of force using killlall nginx or kill -9 (process id) or by clearing the port. So I am pretty sure there is some difference in them.







nginx nginx-location nginx-reverse-proxy






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 3 at 6:23









Mahad AliMahad Ali

1




1













  • Not only got confused by nginx. I think you maybe confused by all processes that could be managed by systemctl and native command script. You should get some knowledge about systemctl, do not focus on nginx.

    – Light.G
    Jan 3 at 12:38











  • Thnks it helped me a lot but still its not clear why it is possible to start a process saperately with these two commands. That was the main reason I asked this question is the first place, nginx and systemctl start nginx if one is used and then it also tried to start the same demon with other command why? Thx for reply

    – Mahad Ali
    Jan 4 at 15:11



















  • Not only got confused by nginx. I think you maybe confused by all processes that could be managed by systemctl and native command script. You should get some knowledge about systemctl, do not focus on nginx.

    – Light.G
    Jan 3 at 12:38











  • Thnks it helped me a lot but still its not clear why it is possible to start a process saperately with these two commands. That was the main reason I asked this question is the first place, nginx and systemctl start nginx if one is used and then it also tried to start the same demon with other command why? Thx for reply

    – Mahad Ali
    Jan 4 at 15:11

















Not only got confused by nginx. I think you maybe confused by all processes that could be managed by systemctl and native command script. You should get some knowledge about systemctl, do not focus on nginx.

– Light.G
Jan 3 at 12:38





Not only got confused by nginx. I think you maybe confused by all processes that could be managed by systemctl and native command script. You should get some knowledge about systemctl, do not focus on nginx.

– Light.G
Jan 3 at 12:38













Thnks it helped me a lot but still its not clear why it is possible to start a process saperately with these two commands. That was the main reason I asked this question is the first place, nginx and systemctl start nginx if one is used and then it also tried to start the same demon with other command why? Thx for reply

– Mahad Ali
Jan 4 at 15:11





Thnks it helped me a lot but still its not clear why it is possible to start a process saperately with these two commands. That was the main reason I asked this question is the first place, nginx and systemctl start nginx if one is used and then it also tried to start the same demon with other command why? Thx for reply

– Mahad Ali
Jan 4 at 15:11












2 Answers
2






active

oldest

votes


















0














The difference between the examples you have provied is how the processes are being started.



Running the command nginx will start the application and wait for your user action to stop it.



The systemctl or service commands are nearly the same thing and running service nginx start or systemctl start nginx will start a service in the background running the Nginx daemon.



You can also use this to do a service nginx restart or systemctl restart nginx to restart the service, or even a service nginx reload / systemctl reload nginx to reload the configuration without completely stopping the Nginx server.



The reason why you can't do both nginx and systemctl start nginx is due to the nginx configuration already listening port 80, and you can't listen on the same port on a single IP address at the same time.



You can also force the nginx service to start on boot by running systemctl enable nginx which will be why your systemctl status nginx returns 'disabled'.



Hope this makes sense.






share|improve this answer
























  • Yes it did helped a lot. Thnks can you also pls ans that why of nginx is already running with command nginx and why is that it is possible to start it with command systemctl start nginx? I mean if its already running why the system even attempts to start again?

    – Mahad Ali
    Jan 11 at 11:40











  • This is due to the fact that the computer will only perform the tasks it's told to do. So if you tell it to start nginx, it will start nginx for you and run into an error once it has failed to bind the ports.

    – Steven T
    Jan 12 at 12:16











  • Perhaps there is nothing to check as the command to execute the programs gets run , to check if the program can even run or not and hence it actually attempts to run the program. So now I am clear. Thnx

    – Mahad Ali
    Jan 15 at 20:39



















0














service command is just a simple script which basically abstract choosing the underlying init system (upstart, systemmd , /etc/init.d or systemctl).



since it being a very concise script, it only supports a very limited set of operations (start | stop | reload .. ).



However, if you actually want to perform the additional operation you need to make use of the actual init system in this case systemctl



An apt example would be starting the service on boot time using systemctl sudo systemctl enable the-name-of-service which is not possible using service






share|improve this answer
























  • Thnks but why is it possible to start the same demon with two commands? By that it means that when I try to start nginx with command nginx then it is also possible to initiate a pre running deamon with systemctl start nginx. Off course it doesn't work due to port being not free but still it makes me question. thnx for reply

    – Mahad Ali
    Jan 4 at 15:14












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
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',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2fstackoverflow.com%2fquestions%2f54017277%2fwhats-the-difference-between-starting-nginx-with-command-nginx-service-star%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














The difference between the examples you have provied is how the processes are being started.



Running the command nginx will start the application and wait for your user action to stop it.



The systemctl or service commands are nearly the same thing and running service nginx start or systemctl start nginx will start a service in the background running the Nginx daemon.



You can also use this to do a service nginx restart or systemctl restart nginx to restart the service, or even a service nginx reload / systemctl reload nginx to reload the configuration without completely stopping the Nginx server.



The reason why you can't do both nginx and systemctl start nginx is due to the nginx configuration already listening port 80, and you can't listen on the same port on a single IP address at the same time.



You can also force the nginx service to start on boot by running systemctl enable nginx which will be why your systemctl status nginx returns 'disabled'.



Hope this makes sense.






share|improve this answer
























  • Yes it did helped a lot. Thnks can you also pls ans that why of nginx is already running with command nginx and why is that it is possible to start it with command systemctl start nginx? I mean if its already running why the system even attempts to start again?

    – Mahad Ali
    Jan 11 at 11:40











  • This is due to the fact that the computer will only perform the tasks it's told to do. So if you tell it to start nginx, it will start nginx for you and run into an error once it has failed to bind the ports.

    – Steven T
    Jan 12 at 12:16











  • Perhaps there is nothing to check as the command to execute the programs gets run , to check if the program can even run or not and hence it actually attempts to run the program. So now I am clear. Thnx

    – Mahad Ali
    Jan 15 at 20:39
















0














The difference between the examples you have provied is how the processes are being started.



Running the command nginx will start the application and wait for your user action to stop it.



The systemctl or service commands are nearly the same thing and running service nginx start or systemctl start nginx will start a service in the background running the Nginx daemon.



You can also use this to do a service nginx restart or systemctl restart nginx to restart the service, or even a service nginx reload / systemctl reload nginx to reload the configuration without completely stopping the Nginx server.



The reason why you can't do both nginx and systemctl start nginx is due to the nginx configuration already listening port 80, and you can't listen on the same port on a single IP address at the same time.



You can also force the nginx service to start on boot by running systemctl enable nginx which will be why your systemctl status nginx returns 'disabled'.



Hope this makes sense.






share|improve this answer
























  • Yes it did helped a lot. Thnks can you also pls ans that why of nginx is already running with command nginx and why is that it is possible to start it with command systemctl start nginx? I mean if its already running why the system even attempts to start again?

    – Mahad Ali
    Jan 11 at 11:40











  • This is due to the fact that the computer will only perform the tasks it's told to do. So if you tell it to start nginx, it will start nginx for you and run into an error once it has failed to bind the ports.

    – Steven T
    Jan 12 at 12:16











  • Perhaps there is nothing to check as the command to execute the programs gets run , to check if the program can even run or not and hence it actually attempts to run the program. So now I am clear. Thnx

    – Mahad Ali
    Jan 15 at 20:39














0












0








0







The difference between the examples you have provied is how the processes are being started.



Running the command nginx will start the application and wait for your user action to stop it.



The systemctl or service commands are nearly the same thing and running service nginx start or systemctl start nginx will start a service in the background running the Nginx daemon.



You can also use this to do a service nginx restart or systemctl restart nginx to restart the service, or even a service nginx reload / systemctl reload nginx to reload the configuration without completely stopping the Nginx server.



The reason why you can't do both nginx and systemctl start nginx is due to the nginx configuration already listening port 80, and you can't listen on the same port on a single IP address at the same time.



You can also force the nginx service to start on boot by running systemctl enable nginx which will be why your systemctl status nginx returns 'disabled'.



Hope this makes sense.






share|improve this answer













The difference between the examples you have provied is how the processes are being started.



Running the command nginx will start the application and wait for your user action to stop it.



The systemctl or service commands are nearly the same thing and running service nginx start or systemctl start nginx will start a service in the background running the Nginx daemon.



You can also use this to do a service nginx restart or systemctl restart nginx to restart the service, or even a service nginx reload / systemctl reload nginx to reload the configuration without completely stopping the Nginx server.



The reason why you can't do both nginx and systemctl start nginx is due to the nginx configuration already listening port 80, and you can't listen on the same port on a single IP address at the same time.



You can also force the nginx service to start on boot by running systemctl enable nginx which will be why your systemctl status nginx returns 'disabled'.



Hope this makes sense.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 3 at 6:35









Steven TSteven T

1544




1544













  • Yes it did helped a lot. Thnks can you also pls ans that why of nginx is already running with command nginx and why is that it is possible to start it with command systemctl start nginx? I mean if its already running why the system even attempts to start again?

    – Mahad Ali
    Jan 11 at 11:40











  • This is due to the fact that the computer will only perform the tasks it's told to do. So if you tell it to start nginx, it will start nginx for you and run into an error once it has failed to bind the ports.

    – Steven T
    Jan 12 at 12:16











  • Perhaps there is nothing to check as the command to execute the programs gets run , to check if the program can even run or not and hence it actually attempts to run the program. So now I am clear. Thnx

    – Mahad Ali
    Jan 15 at 20:39



















  • Yes it did helped a lot. Thnks can you also pls ans that why of nginx is already running with command nginx and why is that it is possible to start it with command systemctl start nginx? I mean if its already running why the system even attempts to start again?

    – Mahad Ali
    Jan 11 at 11:40











  • This is due to the fact that the computer will only perform the tasks it's told to do. So if you tell it to start nginx, it will start nginx for you and run into an error once it has failed to bind the ports.

    – Steven T
    Jan 12 at 12:16











  • Perhaps there is nothing to check as the command to execute the programs gets run , to check if the program can even run or not and hence it actually attempts to run the program. So now I am clear. Thnx

    – Mahad Ali
    Jan 15 at 20:39

















Yes it did helped a lot. Thnks can you also pls ans that why of nginx is already running with command nginx and why is that it is possible to start it with command systemctl start nginx? I mean if its already running why the system even attempts to start again?

– Mahad Ali
Jan 11 at 11:40





Yes it did helped a lot. Thnks can you also pls ans that why of nginx is already running with command nginx and why is that it is possible to start it with command systemctl start nginx? I mean if its already running why the system even attempts to start again?

– Mahad Ali
Jan 11 at 11:40













This is due to the fact that the computer will only perform the tasks it's told to do. So if you tell it to start nginx, it will start nginx for you and run into an error once it has failed to bind the ports.

– Steven T
Jan 12 at 12:16





This is due to the fact that the computer will only perform the tasks it's told to do. So if you tell it to start nginx, it will start nginx for you and run into an error once it has failed to bind the ports.

– Steven T
Jan 12 at 12:16













Perhaps there is nothing to check as the command to execute the programs gets run , to check if the program can even run or not and hence it actually attempts to run the program. So now I am clear. Thnx

– Mahad Ali
Jan 15 at 20:39





Perhaps there is nothing to check as the command to execute the programs gets run , to check if the program can even run or not and hence it actually attempts to run the program. So now I am clear. Thnx

– Mahad Ali
Jan 15 at 20:39













0














service command is just a simple script which basically abstract choosing the underlying init system (upstart, systemmd , /etc/init.d or systemctl).



since it being a very concise script, it only supports a very limited set of operations (start | stop | reload .. ).



However, if you actually want to perform the additional operation you need to make use of the actual init system in this case systemctl



An apt example would be starting the service on boot time using systemctl sudo systemctl enable the-name-of-service which is not possible using service






share|improve this answer
























  • Thnks but why is it possible to start the same demon with two commands? By that it means that when I try to start nginx with command nginx then it is also possible to initiate a pre running deamon with systemctl start nginx. Off course it doesn't work due to port being not free but still it makes me question. thnx for reply

    – Mahad Ali
    Jan 4 at 15:14
















0














service command is just a simple script which basically abstract choosing the underlying init system (upstart, systemmd , /etc/init.d or systemctl).



since it being a very concise script, it only supports a very limited set of operations (start | stop | reload .. ).



However, if you actually want to perform the additional operation you need to make use of the actual init system in this case systemctl



An apt example would be starting the service on boot time using systemctl sudo systemctl enable the-name-of-service which is not possible using service






share|improve this answer
























  • Thnks but why is it possible to start the same demon with two commands? By that it means that when I try to start nginx with command nginx then it is also possible to initiate a pre running deamon with systemctl start nginx. Off course it doesn't work due to port being not free but still it makes me question. thnx for reply

    – Mahad Ali
    Jan 4 at 15:14














0












0








0







service command is just a simple script which basically abstract choosing the underlying init system (upstart, systemmd , /etc/init.d or systemctl).



since it being a very concise script, it only supports a very limited set of operations (start | stop | reload .. ).



However, if you actually want to perform the additional operation you need to make use of the actual init system in this case systemctl



An apt example would be starting the service on boot time using systemctl sudo systemctl enable the-name-of-service which is not possible using service






share|improve this answer













service command is just a simple script which basically abstract choosing the underlying init system (upstart, systemmd , /etc/init.d or systemctl).



since it being a very concise script, it only supports a very limited set of operations (start | stop | reload .. ).



However, if you actually want to perform the additional operation you need to make use of the actual init system in this case systemctl



An apt example would be starting the service on boot time using systemctl sudo systemctl enable the-name-of-service which is not possible using service







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 3 at 6:40









ahhmarrahhmarr

95611524




95611524













  • Thnks but why is it possible to start the same demon with two commands? By that it means that when I try to start nginx with command nginx then it is also possible to initiate a pre running deamon with systemctl start nginx. Off course it doesn't work due to port being not free but still it makes me question. thnx for reply

    – Mahad Ali
    Jan 4 at 15:14



















  • Thnks but why is it possible to start the same demon with two commands? By that it means that when I try to start nginx with command nginx then it is also possible to initiate a pre running deamon with systemctl start nginx. Off course it doesn't work due to port being not free but still it makes me question. thnx for reply

    – Mahad Ali
    Jan 4 at 15:14

















Thnks but why is it possible to start the same demon with two commands? By that it means that when I try to start nginx with command nginx then it is also possible to initiate a pre running deamon with systemctl start nginx. Off course it doesn't work due to port being not free but still it makes me question. thnx for reply

– Mahad Ali
Jan 4 at 15:14





Thnks but why is it possible to start the same demon with two commands? By that it means that when I try to start nginx with command nginx then it is also possible to initiate a pre running deamon with systemctl start nginx. Off course it doesn't work due to port being not free but still it makes me question. thnx for reply

– Mahad Ali
Jan 4 at 15:14


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54017277%2fwhats-the-difference-between-starting-nginx-with-command-nginx-service-star%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







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith