Is it possible to have WAMP run httpd.exe as user [myself] instead of local SYSTEM? - apache

I run a django application over apache with mod_wsgi, using WAMP.
A certain URL allows me to stream the content of image files, the paths of which are stored in database.
The files can be located whether on local machine or under network drive (\\my\network\folder).
With the development server (manage.py runserver), I have no trouble at all reading and streaming the files.
With WAMP, and with network drive files, I get a IOError : obviously because the httpd instance does not have read permission on said drive.
In the task manager, I see that httpd.exe is run by SYSTEM. I would like to tell WAMP to run the server as [myself] as I have read and write permissions on the shared folder. (eventually, the production server should be run by a 'www-admin' user having the permissions)
Mapping the network shared folder on a drive letter (Z: for instance) does not solve this at all.
The User/Group directives in httpd.conf do not seem to have any kind of influence on Apache's behaviour.
I've also regedited : I tried to duplicate the HKLM\[...]\wampapache registry key under HK_CURRENT_USER\ and rename the original key, but then the new key does not seem to be found when I cmd this
> httpd.exe -n wampapache -k start
or when I run WAMP.
I've run out of ideas :)
Has anybody ever had the same issue?

Win+R, services.msc
edit wampapache and wampmysqld to log on as some user.
the tray icon is a convenient front end to "net start wampapache" and "net start wampmysqld"

The User/Group directives in httpd.conf do not seem to have any kind of influence on Apache's behaviour.
httpd.exe is started by the root user (this is probably why you see it running under SYSTEM). The user and group lines in httpd.conf determine what user the child processes (that httpd spawns) will run under. These forks are what actually handle page requests, etc. so it is possible that your configuration is already doing what you want it to, it is just unclear from looking at task manager.
You could also try using runas to start WAMP/Apache, though your mileage may vary.

I've just found that executing httpd.exe myself works for me... I just loose all the funky WAMP tray icon, and the "restart apache" menu item, really handy whenever I update my application code...
I'll have to make do with this for the moment...

Related

Where can I find httpd.conf file for Apache on my windows?

I am trying to fix one venerability on my production web server(Apache), Venerability is "The HTTP headers sent by the remote web server disclose information that can aid an attacker, such as the server version and technologies used by the web server"
For this I have gone for some solutions , some where I found that to solve the above Venerability we need to edit the httpd.conf file on server but I did not find httpd.conf file in my entire system (using windows 10 os) can any one please let me know hot find that file or how to resolve that Venerability on production ?
You can find httpd.conf in
installed folder ex Apache24
Apache24/conf/httpd.conf
On Windows, I have seen people run Apache from all kinds of weird and wonderful places.
You need to track down where your Apache instance is running from, normally its running as a service on windows. If you open the properties on the service and look at the Path to executable, it should be something similar to the below.
"C:\Program Files\Apache24\bin\httpd.exe" -k runservice
Or it could be
"D:\Some Application\Version\WEB\tool\SOFTS\HTTPD\bin\httpd.exe" -k runservice
Unless there is an -f flag, setting the location of the conf. There will be a "conf" folder at the same level as the "bin" folder regardless of the path. This location is set at compile time so unless you have bespoke version off Apache this should be the location.
If you are struggling to find the service or a launcher that is running Apache. You can use WMI with a WQL query to look for processes which are called httpd.exe and get its executable path.
wmic process WHERE name="httpd.exe" GET ExecutablePath
In Xampp Control panel, in apache row, click on "config" button and then you see the term Apache(httpd.conf).

Apache server isn't starting on Xampp portable

It may seems as a repeated question but my problem is that I couldn't be able to start Apache server on XAMPP Portable, I'm am aware of the issues that some aplications can cause since they can use the ports where apache is supposed to work, so I decide to change the apache running ports on httpd.conf and httpd-ssl.conf files to Listen on 8080 and 8001 respectively, here are some screenshots of the changes,
http-conf1, http-conf2, httpssl-conf1, httpssl-conf2
In adition to that I also chage the configuration of the "Service & Port Settings" under XAMPP Control Panel, as shown in the folowing image,
xampp-ports
Although, I did all these changes I still can´t get the apache instance running, and keep getting the following error xampp-error, it's important to notice that I´m trying to start apache service in a company workstation and I don't have any admin rights, but I read that ports above 1250 didn't need any admin rigths to run services on them, so I don´t know what to do at this point, any suggestion from you guys would be really appreciated.
Thanks.
There are lot's of answer to this problem here, in particular I think that this is the answer you are looking for:
Have you executed "setup_xampp.bat" script?
It's inside XAMPP folder and it must be executed every time you change XAMPP folder.
(Bolds are mine)
While not explicitly stated in any "immediate" and "easily" visible warning or message, this is also stated in the readme_en.txt file inside the XAMPP portable main folder.
Step 1: Unpack the package into a directory of your choice. Please start the
"setup_xampp.bat" and beginning the installation.
Note: XAMPP makes no entries in the windows registry and no settings for the system variables.
I'd also say there is a not-so-clear note section right above this step:
[NOTE: Unpack the package to your USB stick or a partition of your choice.
There it must be on the highest level like E:\ or W:. It will
build E:\xampp or W:\xampp or something like this. Please do not use the "setup_xampp.bat" for an USB stick installation!]
I've installed it in a random folder (not root) and after running the setup_xampp.bat script everything ran correctly.
If you are using xampp in USB Drive and having issue at different Windows PC/Laptop then Assign a relevant letter to USB according to installation PC/Laptop USB Letter.
Suppose You install xampp in USB at computer Alpha and Computer Alpha assign it letter F to USB and Now You are at other PC/Laptop Bravo and that PC/Laptop assign it to letter W by default then change that letter to F using Bravo system control panel.
Problem: xampp Portable won’t start, failed or just doesn’t work!
Error: Apache shutdown unexpectedly.
[Apache] This may be due to a blocked port, missing dependencies,
[Apache] improper privileges, a crash, or a shutdown by another method.
[Apache] Press the Logs button to view error logs and check... ...
Solution:
Option 2
Step 1: Open Apache "httpd.conf" from xampp control panel. The file will open in notepad.
image-xampp-config
Step 2: Scroll down or search for “ServerRoot”. If result => ServerRoot "/xampp/apache" follow next step. If not follow (Option 2)
image-xammp-ServerRoot
If 'httpd.conf' not like this image follow #Option 2
Step 3: For portable version of xampp don't any other folder name like 'xampp56'
Use only "xampp" And put this on root directory.
No Sub folder/directory
Step 4: Open your USB drive and go to xampp folder, then start the xampp-control-panel with ‘run as administrator’ mode.
Done.
Option 2
Step 1: Open your ‘My Computer’ or ‘This PC’ to confirm your USB drive label on your current PC. E:, F:, G:…
Step 2: Open Apache "httpd.conf" from xampp control panel. The file will open in notepad. Now Scroll down or search for “ServerRoot”
image-changing-file-httpd
Step 3: There’s a file address path after the ServerRoot should change with your current USB drive address path if path not matches with this current PC.
image-notepade-replace-function
Step 4: Repeat the same process for Apache 'httpd-ssl.conf', 'httpd-xampp.conf',
'php.ini'(Please note that php using the backslash “\” instead of forward slash “/”)
image-php-ini-config-update
and
{…your usb…}\xampp\apache\conf\extra\
File name: 'httpd-autoindex.conf', 'httpd-multilang-errordoc.conf'.
Note: If xampp Portable Apache "httpd.conf" like Option 2 you have to Repeat this process Every time. I recommend you to download new version of 'xampp-portable-win32-... .zip'.
Otherwise total of 7 files need to be updated everytime you change
PC!! Apache ('httpd.conf', 'httpd-ssl.conf', 'httpd-xamp.conf')
'php.ini', 'my.ini', 'httpd-autoindex.conf',
'httpd-multilang-errordoc.conf'
Step 5: Open your USB drive and go to xampp folder, then start the xampp-control-panel with ‘run as administrator’ mode.
Done.

Easy Hosting Control Panel creates multiple backup

I have a server that's running Ubuntu 16.04. and apparently Easy Hosting Control Panel keeps on creating multiple back-ups like 50 times a day which fills the 50 gb disk space and it's causing the server to crash.
The backup is creating multiple directories named Apache2.backupbyehcp inside /etc directory.
I've tried deleting the backups one by one and after a day there it is again.
I want to disable or limit the backups created.
Any help is greatly appreciated.
Here's a screen shot of the backup directories that are being created:
This is caused by:
Ehcp trying to recover webserver config, each time it detects that the webserver config is broken or webserver not responding.
This may result in such unexpected/unwanted behaviour.
What to do:
1st, check the problem in webserver configs, like, tail -f /var/log/ehcp.log
so that you can understand what is going wrong.
This is sometime caused by incorrect webserver custom configurations by admin or reseller. You may disable custom webserver configs via ehcp gui-> options.
(I strongly suggest finding the cause of this.)
If everything regarding the webserver is okay, but you just need to disable this backup,
open install_lib.php in ehcp dir, search for backupbyehcp and disable that line.
Hope this helps.

Installing Apache on Windows for manual use and multiple users

I installed Apache HTTP Server on our Windows system, to work on a home project; it's for use by "localhost" only. When I installed it, the two options were to install it as a service, for all users, using port 80; or to install it for just the current user, run manually, using port 8080. I selected the second. However, while I'd prefer for it to use port 8080 and be run manually, I'd like it to be set up so that my wife can run it as her user. (Allowing all users would be OK.) I don't see an httpd.conf entry for this. Is there a way to do this either through httpd.conf or a command-line option? I'm guessing I could do this in the registry but I don't want to mess with it if I don't have to. (P.S. There's no need to have multiple instances run simultaneously.)
There's nothing you can do from within httpd.conf; any settings in there affects the server itself and not how it is accessed by a program
Well, you have a few options:
1. Uninstall the software and re-install it choosing the all users option. That would be your best choice.
2. Found the location of the folder where it was installed (or where apache.exe is located as that is the needed file to run) and see if you can create a shortcut link into it from within your wife's account. Apache server doesn't care who runs it as long as that file can be executed. The problem you might face is Windows OS preventing you from running it, especially if it requires administrative rights.
3. Install a software such as WAMPServer for her. Of course, that means two similar software on the same machine.
If I have to do it, I would go the first route. Every other option is gonna be a little complicated to work with.
Hope the explanation is clear and the answer helps.

Is there a way to check if a directory exists in Apache configuration files?

Is there a way to include configuration settings in Apache based on if a directory exists? Basically I have a portable hard drive that I transport between work and home that has some stuff I'm developing on it. I only want the Apache config to load a particular virtual host if the folder exists.
Since Apache 2.4.34 you can now use <IfFile>...</IfFile> which will check to see if a file exists. There's more details on the <IfFile> page.
No, there seems to be no direct way to do this.
The only thing that might be a solution is the IfDefine directive. You can define defines using the -d parameter to when the server is started.
The parameter-name argument is a define as given on the httpd command line via -Dparameter-, at the time the server was started.
You might be able to check for the existence of a directory in a batch or bash file, and set the -d parameter accordingly.
Whether that is an option, will depend on how your server is started from the portable hard drive.
I've come up with a solution that seems to work for Linux and OS X, and it hinges on "mountpoints". It might be possible to emulate it within Windows, as well, but you would probably have to get creative with FUSE and/or Cygwin.
If you create an empty folder in your home directory, such as "/Users/username/ExtraVhosts", you can add an apache directive to "Include /Users/username/ExtraVhosts/*".
Then, when you insert your thumb drive, you can mount somewhere and then use mountpoint "binding" to cross-link the ExtraVhosts folder to a folder on the mobile device.
An OS X example:
I have a thumb drive called 'Cherrybomb'
When I insert it, it always gets mounted to /Volumes/Cherrybomb
I can then use bindfs (sudo port install bindfs) to mount a subfolder of it, like so:
sudo bindfs /Volumes/Cherrybomb/Projects/vhosts /Users/username/ExtraVhosts
Then I can restart apache to read in the updated configuration:
sudo /opt/local/apache2/bin/apachectl restart
At that point, it's just a matter of adding entries in /etc/hosts for server aliases to get picked up.
The linux equivalent would be using the "--bind" parameter of the mount command.
One caveat: This makes it difficult to quickly unmount the USB drive, since it is always marked as "in use" by apache. Here's a removal procedure:
Close all open files and terminal sessions that are using the drive (the present-working-directory in terminal can cause unmount issues)
Stop apache: sudo /opt/local/apache2/bin/apachectl stop
umount /Users/username/ExtraVhosts
Then you can either unmount it graphically or manually (umount /Volumes/Cherrybomb).
If your work and home machines mount the drive to different locations, you could have multiple vhosts folders - home_vhost, work_vhost, etc - and use that in the binding step.
I hope this helps someone out :)
If you point apache to the mountpoint only there shouldn't be an issue. Just don't point Directory directives to directories within the drive.
eg, if you mount /dev/somedisk /mnt/somevhost, the
/mnt/somevhost directory will be there whether or not you have the drive mounted and apache will start. Apache doesn't care if the directory is empty so a <Directory "/mnt/somevhost"/> won't cause server to not start if the drive isn't mounted.
Work with UNIX not against it :-p This solution should be sufficient for development.