Posts Tagged ‘windows’

2 Comments Installing And Running Fabric On Windows - 12/17/09

I recently had to setup Fabric (http://docs.fabfile.org/0.9.0/) for doing deployment from my Windows machine at home.
Setting it up under Linux is very very easy but for some reasons there are a number of
issues you have to overcome when installing on Windows. I followed this page to start:

http://docs.fabfile.org/0.9.0/installation.html

First up a standard Python install (I used 2.6.2) and setup tools 0.6c11:

http://pypi.python.org/pypi/setuptools

and create a simple fabric script (fabfile.py)

 Python |  copy |? 
from fabric.api import local, env, put
env.hosts = ["elephant@babar.net:40"]
env.show = ['debug']
def deploy():
	print "Deploying...";
	put("fabtest.txt", "/tmp/fabtest.txt");
	print "All Done...";

From there:

 Bash |  copy |? 
easy_install fabric

will result in:

 PowerShell |  copy |? 
...
Installed f:\python26\lib\site-packages\fabric-0.9.0-py2.6.egg
Processing dependencies for fabric
Searching for pycrypto>=1.9
Reading http://pypi.python.org/simple/pycrypto/
Reading http://pycrypto.sourceforge.net
Reading http://www.amk.ca/python/code/crypto
Best match: pycrypto 2.0.1
Downloading http://www.amk.ca/files/python/crypto/pycrypto-2.0.1.tar.gz
Processing pycrypto-2.0.1.tar.gz
Running pycrypto-2.0.1\setup.py -q bdist_egg --dist-dir f:\docume~1\admini~1\loc
als~1\temp\easy_install-clrpu1\pycrypto-2.0.1\egg-dist-tmp-1wszmf
error: Setup script exited with error: Unable to find vcvarsall.bat

You can solve this in a number of ways, the easiest of which is to install the binary for pycrypto manually from here:

http://www.voidspace.org.uk/downloads/pycrypto-2.0.1.win32-py2.6.exe

Next, try running fabric using: fab -f fabfile.py deploy. This results in:

 PowerShell |  copy |? 
Traceback (most recent call last):
  File "F:\Python26\Scripts\fab-script.py", line 8, in <module>
    load_entry_point('fabric==0.9.0', 'console_scripts', 'fab')()
  File "f:\python26\lib\site-packages\setuptools-0.6c9-py2.6.egg\pkg_resources.p
y", line 277, in load_entry_point
  File "f:\python26\lib\site-packages\setuptools-0.6c9-py2.6.egg\pkg_resources.p
y", line 2180, in load_entry_point
  File "f:\python26\lib\site-packages\setuptools-0.6c9-py2.6.egg\pkg_resources.p
y", line 1913, in load
  File "build\bdist.win32\egg\fabric\main.py", line 17, in <module>
  File "build\bdist.win32\egg\fabric\api.py", line 9, in <module>
  File "build\bdist.win32\egg\fabric\context_managers.py", line 12, in <module>
  File "build\bdist.win32\egg\fabric\state.py", line 125, in <module>
  File "build\bdist.win32\egg\fabric\state.py", line 74, in _get_system_username
 
ImportError: No module named win32api

Install the pywin32 extensions from here:

http://sourceforge.net/projects/pywin32/files/

and finally run fabric again (fab -f fabfile.py deploy), the script should run fine this time…

 PowerShell |  copy |? 
All Done...
Done.
Disconnecting from babar.net:40... done.

Comment PHP, Apache, Windows (Grrr) - 10/12/08

Posted under Design and Architecture by admin on Thursday 17 July 2008 at 2:22 pm

Ok just a few quick notes on stupid Apache, PHP and stupid Windows I wanted to share with people. If you ever have to setup Apache and PHP on Windows there are a few caveats you need to be aware of, especially if you require VirtualHost support for multiple domains. The reason I chose to do this is because I host websites at home on a Centos installation but have an archaic Medi@ TV server by Packard Bell that serves media files via a Powerline network. This means I have to boot into Windows to use it, I haven’t tried sorting this out via Wine yet but I don’t fancy my chances of getting it working. Whilst I’m at it, don’t buy one of these Medi@ TV boxes if you have a 64 bit processor, it just won’t work, plain and simple, I’ve got it running on an old AMD Duron proc. I found a need little driver called Ext2 IFS which allows you to map your Linux EXT2 partitions from Windows. Since I host both O/S’s on the same box this was a requirement. It’s straightforward and works out of the box, this means I could have the same DocumentRoot in the same place in Linux and Windows and be able to write to the DocumentRoot from either O/S. Grade. Apache frustrates me under Windows, the install is straightforward, the setup of the Windows service is pretty straightforward but the error reporting is just plain old stupid.

Service install is achieved via:

 PowerShell |  copy |? 
apache -k install

Service uninstall is achieved via:

 PowerShell |  copy |? 
apache -k uninstall

If you ever have problems with old stray Apache services (or indeed any services under Windows) then you might need to hack your registry and delete a few keys specifically from:

 PowerShell |  copy |? 
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services.

Anyways, that was the first issue. Secondly is the setup of php which should be pretty straightforward. In fact, in hindsight make sure you use the Windows installer rather than the zip file and configuration by hand. It adds the following to httpd.conf:

 PowerShell |  copy |? 
PHPIniDir "D:\\php\\" LoadModule php5_module “D:\\php\\php5apache2_2.dll”

However, make sure that you add the relevant entry to DirectoryIndex:

 PowerShell |  copy |? 
DirectoryIndex index.php index.html

to serve php files. Also:

 PowerShell |  copy |? 
AddType application/x-httpd-php .php .html
AddType application/x-httpd-php .php

to handle the php file type, alternatively modify mime.types under conf and add:

 PowerShell |  copy |? 
application/x-httpd-php php application/x-httpd-php-source phps

You might need to modify php.ini to point to your Apache installation and also to point to your DocRoot:

 PowerShell |  copy |? 
doc_root = "r:\www\html" extension_dir =”D:\php\ext”

And you might need to tweak:

 PowerShell |  copy |? 
upload_max_filesize = 2M

if you’re uploading files from forms. PHP all done. Finally back to Apache to sort out my VirtualHosts for my multiple domain names. First configuration of a name based virtual host and default host:

 PowerShell |  copy |? 
NameVirtualHost *:80
DocumentRoot “R:\\www\\html”

and my set of virtual hosts setup per domain:

 PowerShell |  copy |? 
<VirtualHost _default_:80>
DocumentRoot "d:\\workspace\sanctuary7website"
</VirtualHost>

Note that DocumentRoot has to have the \ escaped \\ under Windows. Doh. All done, up and running.

|