Starting and Stopping Apache Web Server On Linux
Starting and Stopping Apache.
How to start and stopping Apache Web Server?
A script namedapachectl is available to control the server. By default, the script is stored in a subdirectory called bin in the directory where Apache is installed. Some Linux distributions may put it in another directory.
The script requires a keyword. The most common keywords are start,stop and restart. The general syntax is as follows:Path/apachectl keywordFor example, if Apache was installed in the default directory, type the following line to start Apache:/usr/local/apache2/bin/apachectl start
Starting Apache
The apachectl script starts the Apache server. The server then runs in the background , listening for HTTP requests. By default, the compiled Apache server is named httpd and is stored in the same directory as the apachectl script, although you can change the name and location when you install Apache.
The apachectl script serves as an interface to the compiled server, called httpd.You can run the httpd server directly, but it’s better to user apachectl as an interface.
The apachectl script manages and checks data that httpd commands require.
Use the apachectl script to start Apache with the following command:/usr/local/apache2/bin/apachectl start.
The apachectl script contains a line that runs httpd. By default, apachectl looks for httpd in the default location - /user/local/apache/bin
or /usr/local/apache2/bin.
If you installed Apache in a non standard location, you may need to editapachectl to use the correct path. Openapachectl and then search for the following line:HTTP=’/usr/local/apache2/bin/httpd’Change the path to the location where you installed httpd.For example, the new line might be this:HTTP=’/usr/mystuff/bin/httpd’After you start Apache, you can check whether Apache is running by looking at the processes on your computer. Type the following command to see what processes are running:Ps –AIf Apache is running, the list of processes displayed includes some httpd processes.
Restarting Apache
Whenever you change the configuration file, the new directives take effect the next time Apache starts. If Apache is shut down when you make the changes, you can start Apache as described earlier in “starting apache”. However, if Apache is running, you can’t use start to restart it.
Using start results in an error message saying that Apache is already running. You can use the following command to restart Apache when it’s currently running:/usr/local/apache2/bin/apachectl restart.
Although the restart
command usually works, sometimes it doesn’t. If you restart Apache and the new settings don’t seem to be in effect, try stopping Apache and starting it again. Sometimes this solves the problem.
Stopping Apache
To stop Apache, use the following command:/usr/local/apache2/bib/apachectl stop.
You can check to see that Apache is stopped by checking the processes that are running on your computer with the following command:Ps -AThe output from ps should not include any httpd processes.
- 225 reads
Recent popular content



















