httpd.conf always in use, even after killing apache processes? - apache

I am having the most frustrating time trying to edit my httpd.conf file for Apache server. I've done it numerous times on other machines, but on this one, it says it's always in use. I've killed the Apache service and the Apache monitor process.
Does anyone know what else would use this file? Let me know of any other info you need.

you can try the commands fuser or lsof to see/kill the process that uses the file. see this link for some examples (scroll down a bit): http://www.lunarforums.com/vps_hosting_at_lunarpages/useful_linux_scripts_lsof_ps_fuser_netstat-t41474.0.html

Related

I can't get Apache to work for some reason

For some reason Apache just doesn't seem to want to work. I have been trying so many things to try and fix it but with no luck. At first there was programs blocking port 80. A few of the programs I tried to stop on port 80 are skype, World Wide Web Publishing Service, IIS(Internet Information Services), and NT Kernal & System. Then I ran Apache in the cmd. I typed: cd:/apache/bin then I typed httpd.exe but nothing happened and the cursor just kept blinking on the next line. I also went to ApacheMonitor in the bin file and ran that, then went to the little icon on the bottom and clicked start but it just said The requested operation has failed! I don't know what to do now.
I have windows 7.
I would recommend to Install Apache as a service.
However, if you want to start Apache via command prompt. First thing you check if the syntax in your conf files is ok. Open a command prompt as an Administrator. Change to Apache bin directory and use below command.
httpd -t
If it returns Syntax OK, that's a good news. Errors will be displayed if any. Fix all errors.
Once syntax looks ok, run below command to start Apache.
httpd -k start
It should start your Apache. If it doesn't check /logs/error.log and see what's going on.
Good Luck!

Can I execute a shell script when restarting (starting) apache webserver

I have an application with some cacheing backend and I want to clear the cacheing whenever the webserver is been restarted.
Is there a apache configuration directive or any other way to execute a shell script upon webserver (re)start?
Thanks,
Phil
Adding some more information, as asked by some answers already:
Base system is ofc linux based, in this exact situation: CentOs
Modifying the startup script is unfortunately no option as pointed out by one of the comments already, due to it beeing not configuration file within the respective RPM packages and therefor beeing replaced by updates. Also I think modifying the startup script would be a bad thing in general
I see, that actually linking both "restarting the webserver" and "clearing my app cache" is not exactly what should be tied together. I will consider other alternatives
My situation is as follows: I can define how the virtual host config looks like, but I can not define how the rest of the servers configuration looks like.
The application is actually PHP based (and runs on the symfony framework). Symfony pre-compiles alot of stuff into dynamic php files from what it finds in the static configuration files. We deploy our apps via RPM and after deployment, an webserver restart is actually initiated already, so I thought it might make sense to tie the cache-cleanup to it. But I think after getting all your feedback, it looks like it is better to put the cache cleanup process into the installation process itself.
You haven't provided a lot of detail here, so it's hard to give a concrete answer, but I would suggest that your best option is to write a script which handles restarting apache, and clearing your cache. It would look something like this:
#!/bin/sh
# restart apache
/etc/init.d/httpd graceful
# whatever needs to be done to clear cache
rm -rf /my/cache/dir
Ramy suggests modifying the system startup script for Apache -- this is a bad idea! If and when you update Apache on your server, there is a good chance that your change will be lost.
Dirk suggests that what you are trying to do is probably misguided, and I think he's right. You haven't told us what platform you are running, but I can think of few situations where restarting your webserver and clearing a cache actually need to happen together.
You can modify Startup script for the Apache Web Server in /etc/init.d/httpd and write your own syntax inside it.
chattr +i /etc/init.d/httpd
If you have (root) access to the server you could do this by shell scripts but I would consider if it is the best way of cache management to rely on apache restarts.

How does the apache lifecycle looks like?

As part of my learning process, I thought it would be good if I expand a little more knowledge on what I know about apache. I have several questions, and while I know some of the stuff may require a rather lengthy explanation, I hope you can provide an overview so I know where to go looking. (preferably reference to mod_wsgi)I have read some resources after searching on google, and what I know arrive from there, so please bear with me.
What does the apache lifecyle looks like before, during, and after it receives a http request? Does it spawns a new child process to do the work, or creates a thread in one of the child process?
Does apache by default runs under www-data? So if that's the case, if I want a directory under my project folder to be used for logs, I can change just the folder group to www-data and allows write access?
What user will the python interpreter run under, after being invoked by apache? And what will processes created by Popen or multiprocessing from there run under?
I ran ps U www-data. Why are there so many processes with
S 0:00 /usr/sbin/apache2 -k start
The Apache mpm prefork module handles one connection in one process. To handle connections fast and not spawn processes on demand, apache maintains a process-pool. This explains why you see so many processes in the process-list. If a connection comes in, it is handed to one of the already existing processes.
Some more information is here: http://httpd.apache.org/docs/2.0/en/mod/prefork.html
The answer to question 2) is yes, apache always runs as www-data und you can grant access to any directory by changing it's group permissions to www-data.
Read:
http://www.fmc-modeling.org/category/projects/apache/amp/Apache_Modeling_Project.html
http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading
http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide#Delegation_To_Daemon_Process
http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess
The first one will tell you all the gory details of how Apache works internally. The latter relate to mod_wsgi specifically and process/threading model.

How to "reload" just one vhost file

I have a question about apache configuration. Please help me!
My server run multi virtual hosts (multi domains). But, every time I edit a vhost file, I have to restart apache, and, server have to reload all configuration files. That is expensive. Is there any way to "restart" or "reload" just one vhost configuration file? I googled but haven't found the solution.
I'm not 100% sure, but I think the answer is "No". I've been looking for this for a while, too. Although, you say "restart apache", what command are you running? Are you using the apache restart or reload command? You should only have to use reload.

Lamp with mod_fastcgi

I am building a cgi application, and now I would like it to be like an application that stands and parses each connection, with this, I can have all session variables saved in memory instead of saving them to file(or anyother place) and loading them again on a new connection
I am using lamp within a linux vmware but I can't seem to find how to install the module for it to work and what to change in the httpd.conf. I tried to compile the module, but I couldn't because my apache isn't a regular instalation, its a lamp already built one, and it seems that the mod needs the apache directory to be compiled. I saw some coding examples out there, so I guess is not that hard once its runing ok with Apache
Can you help me with this please?
Thanks,
Joe
Using FastCGI just means that you spawn a number of processes which will handle requests they get from the actual webserver instead of the webserver spawning a new process whenever a request arrives.
Use something like memcached if you want to keep stuff like sessions in memory.