logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Apache Network Hard Drive Mapping
Author
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Wed 02 Apr '14 16:17    Post subject: Apache Network Hard Drive Mapping Reply with quote

So i have question regarding apache on windows and hard drives.

I have a virtual rack what i connected all my servers upto, Then i mapped all my servers hard drives together so they can all communicate and share data from eachother.

But i have apache installed on 1 server hard drive C:/

Can i run apache from that mapped hard drive on the other servers ? Or would that cause problems ?

I have no idea how much testing you guys do and if you ever tried a method like this. But for me its useful.

Also they are all windows 2008 running the latest apache from here.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7294
Location: Germany, Next to Hamburg

PostPosted: Wed 02 Apr '14 16:46    Post subject: Reply with quote

Well it works under conditions. I got it running ... but ...

The mapping often lags behind the service start (so I started apache by hand).
if the document root is on the on a share, too, you have to run it (if it is a service) as a different user.

Since the apache config can be used with forward slashes I set all path without the drive letter. That made apache working no matter if started from a networkdrive or usb stick.

e.g.
Code:

ServerRoot "/Users/mario/Apache24"
Alias /workingcopies /Users/james/workingcopies


So the apache config is easy. Only start up problem gave me from time to time headaches.
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Wed 02 Apr '14 17:03    Post subject: Reply with quote

For me the mapped hard drive for the servers connect to containing the websites is Z:/

So my config would reflect this.

DocumentRoot "Z:/server/websites/sh/www/public_www"

But i was curious if it would have trouble loading it or slow it down. ?

I also enabled caching on the hard drive properties under advanced sharing.

My local area network connection accross each machine is 1gbps.

See: http://i633.photobucket.com/albums/uu52/C0nw0nk/Untitled9.png

If .php files are cached and I edit one will it cause problems ? or will the other machines deliever the cached file or the new edited one ?
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Fri 04 Apr '14 11:32    Post subject: Reply with quote

So does anyone know If .php files are cached and I edit one will it cause problems ? or will the other machines deliever the cached file or the new edited one ?

Perhaps i should post it on stack exchange.
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Sun 06 Apr '14 19:49    Post subject: Reply with quote

Also i have a question regarding mod_fcgi and this.

Code:
FcgidInitialEnv PHPRC "c:/server/xampp/php-5.5.7-nts"
FcgidInitialEnv PATH "c:/server/xampp/php-5.5.7-nts;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;"
FcgidInitialEnv SystemRoot "C:/Windows"
FcgidInitialEnv SystemDrive "C:"
FcgidInitialEnv TEMP "C:/WINDOWS/Temp"
FcgidInitialEnv TMP "C:/WINDOWS/Temp"
FcgidInitialEnv windir "C:/WINDOWS"
FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 0
FcgidInitialEnv PHP_FCGI_CHILDREN 0


So with the following setup my mapped drive is the z:/drive

How can i tell php to store sessions in the mapped hard drive ? What one of those configs should reflect that ?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7294
Location: Germany, Next to Hamburg

PostPosted: Tue 08 Apr '14 12:04    Post subject: Reply with quote

You can set in your php.ini session.save_path

session.save_path = "C:\Users\mario\php5\tmp"

But there you have to use a drive letter!

the caching of the files is ok as long the php code doesn't change Wink
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7294
Location: Germany, Next to Hamburg

PostPosted: Tue 08 Apr '14 12:05    Post subject: Reply with quote

To the performance I can't give a statement. I had fiber connections with 10 gb/s.
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Tue 08 Apr '14 18:49    Post subject: Reply with quote

James Blond wrote:
You can set in your php.ini session.save_path

session.save_path = "C:\Users\mario\php5\tmp"

But there you have to use a drive letter!

the caching of the files is ok as long the php code doesn't change Wink


And if it changes how can i tell it not to cache php then ?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7294
Location: Germany, Next to Hamburg

PostPosted: Tue 08 Apr '14 22:25    Post subject: Reply with quote

cache session data or PHP code / OPcache?
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Wed 09 Apr '14 0:11    Post subject: Reply with quote

I assume you are talking about my picture cache right ?

http://i633.photobucket.com/albums/uu52/C0nw0nk/Untitled9.png

The network sharing cache for windows.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7294
Location: Germany, Next to Hamburg

PostPosted: Wed 09 Apr '14 16:20    Post subject: Reply with quote

C0nw0nk wrote:
I assume you are talking about my picture cache right ?

Nope. I was talking about the internal PHP cache

C0nw0nk wrote:

The network sharing cache for windows.

That shouldn't be an issue.
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Thu 10 Apr '14 23:13    Post subject: Reply with quote

Also james in regards to the session php issue.

It turns out on windows that when apache is instaled as a service. Everything runs under the SYSTEM user. And the system user is actualy not allowed access to mapped network drives.

So there for all my php-cgi process are also SYSTEM users, and i can not access Z:/ drive with them Razz. It is a funny error any idea on how i can make Apache run as a user or under a command line from a batch file or something ?, So it will run under my root user instead of system to fix this error.

http://i633.photobucket.com/albums/uu52/C0nw0nk/Untitled-2.png
Back to top
KenD



Joined: 30 Jul 2013
Posts: 7
Location: US, Gainesville, FL

PostPosted: Fri 11 Apr '14 4:01    Post subject: Reply with quote

Here is a batch file I use to set my Apache service.

It should contain what you need to alter your existing service to log in as a different user that can access a network.



Code:
rem Batch file for setting up Apache as a service.

rem depending on OS, may need to be run from command window with "Run as Administrator" option
rem will also need to set up sharing and rights on remote machine if using network drives

rem # need to set dependency on LanmanServer if start as service using account that needs network access
rem # check current dependencies with Check current dependencies for Apache2.4 service
rem # sc qc Apache2.4
rem # create user for service for apache to use
rem # http://technet.microsoft.com/en-us/library/cc990290%28v=ws.10%29.aspx
rem # http://support.microsoft.com/kb/193888
rem # http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/sc.mspx?mfr=true

rem see "http://httpd.apache.org/docs/2.4/platform/windows.html#winsvc" for docs about starting httpd as service

rem AutoExNT and NTRights are included in the windows 2003 resource kit
rem download - http://www.microsoft.com/en-us/download/details.aspx?id=17657
rem docs - http://support.microsoft.com/kb/243486
rem AutoExNT is useful to load other programs or for using the choice command with a time delay to allow other programs/devices to start

rem ### begin user defined settings
rem Apache service cannot use LocalSystem account if accessing network drives 
set ApacheUserName=ApacheServer
set ApachePassword=Password


set InstallAutoExnt=N
set ApacheService=Apache2.4
set ApacheRoot=c:\Apache\al249vc11ssl1.0.1g


rem path to custom httpd.conf file
set ApacheConf=c:\webfiles\conf\httpd.conf

set ApacheLogRoot=%ApacheRoot%\logs


set Dependencies=LanmanWorkstation/Tcpip/Afd

rem ### end user defined settings

set RKToolsPath=

if Exist "C:\Program Files\Windows Resource Kits\Tools\ntrights.exe"   set RKToolsPath=C:\Program Files\Windows Resource Kits\Tools

if Exist "C:\Program Files (x86)\Windows Resource Kits\Tools\ntrights.exe" set RKToolsPath=C:\Program Files (x86)\Windows Resource Kits\Tools


rem check if service already installed
sc qc "%ApacheService%" | find "OpenService FAILED"

rem if ERRORLEVEL 1 goto :ExistingService
ECHO.%ERRORLEVEL%

pause



if %InstallAutoExnt%==N goto :EndAutoExNT

set Dependencies=AutoExNT/%Dependencies%
rem skip if AutoExNT setup service already installed

sc qc "AutoExNT" >nul
if not ERRORLEVEL 1 goto :EndAutoExNT

rem Create C:\windows\system32\AutoExNT.bat placeholder file if it does not already exist
if not Exist "C:\windows\system32\AutoExNT.bat" echo rem commands in this file will run on machine startup          >  C:\windows\system32\AutoExNT.bat

rem example commands for AutoExNT.bat -
rem create virtual S: drive to use on startup to allow Apache to start when actual S: drive is not ready
rem when actual drive is ready, delete the virtual S drive with "subst s: /D"
rem Subst S: c:\TempSDrive

rem copy autoexnt files to c:\windows\system32 (source path may be different depending on OS)
if not exist "C:\windows\system32\autoexnt.exe"  copy "%RKToolsPath%\autoexnt.exe" "C:\windows\system32"
if not exist "C:\windows\system32\servmess.dll"  copy "%RKToolsPath%\servmess.dll" "C:\windows\system32"
if not exist "C:\windows\system32\instexnt.exe"  copy "%RKToolsPath%\instexnt.exe" "C:\windows\system32"

rem use  "instexnt install /interactive" to allow applications to be interactive and display on the desktop when any user logs in
instexnt install
:EndAutoExNT

:InstallHttpdService
rem see http://httpd.apache.org/docs/2.4/platform/windows.html#winsvc

 %ApacheRoot%\bin\httpd.exe -k install -n "%ApacheService%" -f "%ApacheConf%"


:ApacheUser
rem set up User for service to use for login if not the default LocalSystem account
if "%ApacheUserName%"=="Localsystem" goto :EndApacheUser


rem Create user %ApacheUserName% with password %ApachePassword%
net user %ApacheUserName% %ApachePassword% /ADD

rem give %ApacheUserName% user read/write/execute/delete rights to the logs directory
rem should have read/write rights to %ApacheRoot% by default
icacls %ApacheLogRoot% /grant %ApacheUserName%:(OI)(CI)M

rem delete from users group
net localgroup Users %ApacheUserName% /delete

net localgroup "Remote Desktop Users" UserLoginName  %ApacheUserName%  /add

rem give "Log on as a service" and "Act as part of the operating system" rights to %ApacheUserName% user
rem note - NTRights is part of the 2003 resource kit tools
"%RKToolsPath%\NTRights" -u %ApacheUserName% +r SeServiceLogonRight
"%RKToolsPath%\NTRights" -u %ApacheUserName% +r SeTcbPrivilege

rem configure %ApacheService% service using sc command  - note that space must follow "=" sign when using sc

rem use %ApacheUserName% as username for %ApacheService% service
sc config %ApacheService% obj= .\%ApacheUserName% password= %ApachePassword%
:EndApacheUser



rem set dependencies for %ApacheService% service -
rem note depend= must have a space afer it and  old dependencies are overwritten
rem need to add LanmanWorkstation if mapping to network share
rem sc config %ApacheService% depend= "AutoExNT/LanmanWorkstation/Tcpip/Afd"
rem sc config %ApacheService% depend= "LanmanWorkstation/Tcpip/Afd"

echo off
echo.
echo End scripted setup
echo.
echo current dependencies for service %ApacheService%
sc qc %ApacheService%
echo.
echo note old dependencies are overwritten and that space must follow "=" sign
echo example dependency - sc config %ApacheService% depend= "%Dependencies%"
echo.
echo. may need to log in as %ApacheUserName% to set up shares
echo.   net use \\RemoteMachine\ShareName /USER:RemoteUserName RemotePassword /PERSISTENT:YES
echo.
echo need to give %ApacheUserName% rights to any other needed directories
echo.
echo start service - sc start "%ApacheService%"
goto :End


:ExistingService
echo Error - Service "%ApacheService%"  already exists
echo To uninstall existing service - httpd.exe -k uninstall -n "%ApacheService%"
reg query "%ApacheService%" /v "ImagePath"
sc queryex "%ApacheService%"

goto :End

:End
[/code]
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Tue 15 Apr '14 2:11    Post subject: Reply with quote

Funny thing is even with my hard drive mapped and php apache etc running under the root user account instead of system. I can not access sessions on the external hard drive.

Code:
session.save_path = "Z:/Windows/Temp"


Does anyone have any ideas ?
Back to top
KenD



Joined: 30 Jul 2013
Posts: 7
Location: US, Gainesville, FL

PostPosted: Fri 18 Apr '14 18:47    Post subject: Reply with quote

Are you running Apache as a service? If you can start the Apache service manually, but not on reboot, it could be a dependency issue.
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Sun 20 Apr '14 14:06    Post subject: Reply with quote

KenD wrote:
Are you running Apache as a service? If you can start the Apache service manually, but not on reboot, it could be a dependency issue.


I can do whats the command line i should put in my batch file to launch httpd.exe under ?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7294
Location: Germany, Next to Hamburg

PostPosted: Sun 20 Apr '14 19:11    Post subject: Reply with quote

C0nw0nk wrote:
Funny thing is even with my hard drive mapped and php apache etc running under the root user account instead of system. I can not access sessions on the external hard drive.

Code:
session.save_path = "Z:/Windows/Temp"


Does anyone have any ideas ?


You can't or the running apache can't?
Back to top
KenD



Joined: 30 Jul 2013
Posts: 7
Location: US, Gainesville, FL

PostPosted: Mon 21 Apr '14 15:17    Post subject: Reply with quote

From the command line, run
sc qc Apache2.4

If you see the following:

Code:
DEPENDENCIES       : Tcpip
                   : Afd

You just need to run (as administrator)

sc config Apache2.4 depend= "LanmanWorkstation/Tcpip/Afd"

more explanation is in the batch file I posted earlier in this thread.


Ken
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Tue 22 Apr '14 21:48    Post subject: Reply with quote

I took a screenshot of my output.

http://i633.photobucket.com/albums/uu52/C0nw0nk/Untitled-3.png

But as you can see from the picture it is running under the root user but still the same issue Sad

I hate how windows makes a mountin out of a molehill with the SYSTEM user.
Back to top
KenD



Joined: 30 Jul 2013
Posts: 7
Location: US, Gainesville, FL

PostPosted: Wed 23 Apr '14 2:46    Post subject: Reply with quote

You just need to run (as administrator) from a command prompt

sc config Apache2.4 depend= "LanmanWorkstation/Tcpip/Afd"

When you run "sc qc Apache2.4" again, the output should include

Code:
        DEPENDENCIES       : LanmanWorkstation
                           : Tcpip
                           : Afd


Apache should then wait on the network connections before starting.

Ken
Back to top


Reply to topic   Topic: Apache Network Hard Drive Mapping View previous topic :: View next topic
Post new topic   Forum Index -> Apache