Lập Trình Linux

How to Start Apache from Command Line




Learn how to disable apache service. Furthermore, learn how to re-enable it with the help of command line by changing the httpd configuration file.

Don’t forget to check out our site for more free how-to videos!
– our feed
– join us on facebook
– our group in Google+

In this tutorial, we will guide you on how to start apache from command line. In this tutorial, we will teach you how to check whether the apache service is working or not. Furthermore, we will teach you how to work with apache in the command line, how to make changes to the httpd configuration file, etc.

Step 1 — type localhost

Follow this detailed step by step guide in order to learn how to start apache from command line.
First of all, open up the browser and in the address bar, type localhost before you hit the “enter” key. With that done, you will see “it works” being displayed on your screen. This means that the apache services are running.

Step 2 — Open Services.msc

Now move on to the services window by opening up the run command, typing in services.msc and hitting the enter key.

Step 3 — Stop apache service

With that done the services window will open up. Over there, let’s stop the Apache service for now.

Step 4 — Check if apache is running

Now let’s go back to the browser and refresh the page. You will notice that this time, the localhost page doesn’t open up. This means that the apache server has stopped.

Step 5 — Open command prompt

Now let’s open up the command prompt. With that done, let’s go to the bin directory in the apache folder.

Step 6 — Locate httpd.exe

Over there in the bin directory, you can see the httpd.exe file.

Step 7 — Resume service

If we type httpd and hit the enter key, you will see that the service starts but prompts an error in the process. The error is displayed because the domain name used is not a qualified one. None the less, the service has started.

Step 8 — Open config file

Now let’s move to the configuration directory in the apache folder. Over there, let’s open the httpd.conf file in the notepad.

Step 9 — Make changes to config file

Over there, find the “localhost:80” text in the notepad and remove the hash from the beginning of that line. With that done, save the file and close the notepad.

Step 10 — Apache will start

Now let’s go back to the command prompt, type httpd once again and hit the enter key.
With that done, you will see that the apache has started in command line without prompting any error.

Step 11 — Check if apache is working

In the browser, let’s refresh the page again and you will see this web page will open up. This means that you have successfully started the apache server from the command line.

Nguồn: https://ftlinuxcourse.com

Xem thêm bài viết khác: https://ftlinuxcourse.com/lap-trinh-linux

Ẩm Thực
CÁCH LÀM MỰC NƯỚNG SA TẾ NGON TUYỆT | MÓN NGON MỖI NGÀY
Lập Trình Linux
Cấu hình pfsense sau khi cài đặt xong | Phần 3
Tin HOT
Giảm tối đa hơn 2.500 đồng/lít, giá xăng xuống sát 15.000 đồng/lít(MỘC TV)
  • ❗ Subscribe To Our Main YouTube Channel

    https://www.youtube.com/user/howtechpc


  • How to imagine that I did not find this in Google search?


  • The solution was very very simple. You get the error message when you manually try to start the webserver by "httpd -k start", but no service was defined yet.

    just do a "httpd -k install" and the windows service is added to the registry. after that, the "httpd -k start" works without error message.


  • thanx, you're too good


  • thank you man


  • Ty <3


  • WAROWL is that you???


  • thanx man 4 ur help


  • Hi, I don't know where my brother got this Apache HTTP Server test page powered by centos. The problem is I can't open some website because this webpage from Apache blocking the webpage. I can't find it on my computer, there is no Apache2 installed..will it be solve if i download and uninstall apache? thanks advance


  • Woot, I love the speed he speaks. 


  • Dear 
    I don,t know why apache web server dosen,t start  i tried to start service using ( start all services ) it did not work then i go to apache  > services > start/resume service  also no way 
    i tried to start it using services .msc  i always get a message ( window couldn.t start the wampapache on local computer for more information review the sysatem eventlog  if this is a non microsoft service  contact the service vendow and refer to service -specific  error code1  ) i tried alot to start apache using service.msc but it did not work and i always get this message  need your help with this problem 
    Thank you


  • yep


  • have you installed apache? this video shows how to do it /watch?v=SwbJppuPADE


  • if you can't open localhost when you type it in your browser's address bar, that's another story) You need to set up apache first


  • You don't need to type localhost in cmd. It's the server address (just like yotube[dot]com) so it can't be opened directly from cmd. You can only open localhost from yor browser (e.g. firefox ot chrome)


  • same for meee will this help me to open local host ? we 3 have same problem when we type local host in cmd says this error what we have to do? and i cant find appache 32