
Hello!
For a long time I was going to write an article on Habr, and finally I was going to.
')
I'll tell you about one assembly, greatly facilitating the life of the webmaster under Windows.
The story is as follows - during the next “dances with a tambourine” to raise the web environment under win at the customer, I realized that all this magic got me.
Tired of searching and calling elementals of level 50 in order to find a mod_wsgi module for Python and Apache compiled under win, initializing Postge SQL data, this is because Apache does not start because Skype is already hanging on port 80 ...
I wanted something simple, flexible and most importantly portable.
Those. the hunt was set up once, then came, copied to another place, launched - and the whole environment with ready data and settings rose.
Why win, when there is a long time the same Ubunt? Because we often went with our software to customers, and after viewing the demo they said, “can I leave to play?”, Well, 90% of computers had windows.
Having looked at what is on this field, and seeing only limited solutions, I sat down to write myself. How about "Do you want to do well - do it yourself."
The idea was simple - to make the web developer’s portable environment “with checkers and ladies of not heavy behavior,” moreover, so that it could be delivered, and then removed without leaving garbage,
cheating the system or anything else from this opera.
This is how the assembly of the “
Windows Web Survival Kit ” or
WWSK - portable “Apache + Node + PHP + Python + MySQL + PgSQL + Utilities” was born.
How is portability (portability) of the assembly made?
I “untied” the programs from the physical paths that are called “head on”, but everything is very simple and clear.
The folder with the name “www” was made the assembly's root folder (that is, our whole environment lives inside it), but you can put it anywhere.
For each configuration, in those places where an indication of the full path is required, the path is indicated as "? / Www / path-where-need-relative-folder-www".
When copying to a certain path, after copying, a special file is launched, which roughly says the following: it takes all our “initial” configurations, replaces “? /” With the current path to the “www” folder and lays out the corrected configs in the right places, then launches and registers the service.
What is inside the base assembly?
Apache - registers the “ApacheSA” service at the start.
MySQL - registers the MySQLSA service at startup.
PgSQL - registers the PgSQLSA service at startup.
PHP 5, connected as fast-cgi.
Python 3 (or 2), connected as mod-wsgi
When stopping any component, services also stop and unregister.
What windows versions does it work on?
Windows XP (32/64), Windows 7 (32/64) works exactly.
In theory, it should work on Windows 8, but it was not possible to check, unfortunately.
Assembly structure
At the root are the following folders:
- Apache - Apache Web Server Files
- MySQL - MySQL files
- NodeJS - NodeJS files
- PgSQL - Postgre SQL Files
- PHP files PHP
- Python - Python files
- sys - files necessary for the operation of the assembly
- tmp - folder for temporary files (sessions in PHP, uploaded files, etc.)
- Tools - folder with tools
- webroot - root folder for sites
And files:
- _runner ___. cmd - the main assembly menu file (restarting Apache, reconfiguration, logs, etc. - everything is here)
- _setconf __. cmd - build reconfiguration file (can be called from the runner, or it can be launched separately)
- _showlogs_.cmd - file for working with Apache logs - cleaning, viewing (can also be launched from runner or manually)
- clean.cmd - assembly cleanup file (for example, for transfer to a USB flash drive - deletes temporary files, logs, etc.
- phpinfo.cmd - file for generating information on PHP and opening it in the browser for learning
- readme.txt - build description file
- upgradeSites.txt - file with links to update assembly components
Sys folder
Inside there are subfolders
apacheData, mysqlData, pgsqlData, phpData, pythonData which store the configuration templates for all these services.
These are the same configuration templates that, when the assembly is tied to a new folder, will be copied to the right places with the modified path inside.
In addition, database managers are also stored there (
mysqlData / manager and
pgsqlData / manager ).
Managers are not included in the assembly - everyone can use what they are used to.
I use EMS MySQL and the PgSQL manager - I liked them most of all for functionality and convenience.
The most important condition is that the file being launched by the manager in these folders should be
labeled as
manager.exe .
In the root of the
sys folder there is also a file for working with the assembly from the command line
services.cmdFor example, you can restart Apache like this:
services.cmd RestartApache .
Hardly it will be necessary in life - everything can be done from the menu, but if someone wants to fasten something of their own - there is a possibility.
Tmp folder
The temporary directory of the entire assembly.
In all configurations where you need to specify a temporary directory, it is indicated here.
Inside it you can delete everything except the
sessions directory in which PHP sessions live.
Tools folder
Folder with various tools.
The subfolders of
Apache, MySQL, NodeJS, PgSQL, PHP, Python contain various docks and tricks for these services, plus some service files that allow you to do any additional functionality.
For example, in the case of a database, there are batch files for importing and exporting dumps for a database, initializing databases, etc.
In addition, I have a GIT (folder with the same name), YUI minimizer (Minimizer folder), Image Optimizers (IMGoptimize folder), cURL, Inkscape, etc. in this folder.
If you have any tools that you constantly use - they can be placed here.
Webroot folder
In this folder live folders with sites, the paths to which are registered in the configuration of Apache or NodeJS.
The only special subfolder here is the
Python subfolder where the host handler for mod_wsgi for Python lives, it is also registered in the Apache config and you can always replace it with whatever you want.
Build update
With the update, everything is simple - download the necessary component from the site and unzip it into the necessary folder with the replacement of files.
However, of course, there are several nuances:
- 32 bit build - files need to be downloaded appropriate (although you can make the whole 64 bit one - just not to mix)
- PHP should be downloaded as thread safe
- when updating Python , you need to download the appropriate version of mod_wsgi , put it in sys \ pythonData and register it in the Apache config.
Some components are provided by the manufacturers as an msi package, it can be unpacked in win using the
msiexec / a “msi package” name TARGETDIR = "% CD% \ tmp" / qb - it will create a tmp folder in the directory next to the package and unpack its contents, and only then it can be copied to the desired folder (do not forget to delete in the tmp folder a copy of the package file that the careful MSI installer puts there)
Assembly features
- Username and password for all root databases
- Build the whole 32-bit
- timezone is GMT + 6
- Python is available in two versions: 2.x and 3.x
- Components of the assembly are hung on 127.0.0.1 and the desired port, and, accordingly, will be available from there.
- 127.0.0.1 points to webroot /
- 127.0.0.2 points to webroot / site1
- 127.0.0.3 points to webroot / site2
- 127.0.0.5 via mod_wsgi on webroot / Python
- In the Apache config, there are two labels of the form # CL #, immediately after them there are DocumentRoot and RewriteEngine On - they are needed to find and change these parameters from the runner
Getting started with the build
The first thing to do is to go into the configuration templates (see the information about the sys folder) and tweak them "for yourself." Specify the necessary folders with sites inside webroot, find out what version of Python is needed, etc.
During the operation of copying an assembly to somewhere, or during reconfiguration, it is necessary that
all components of the assembly be stopped — that is, Apache, MySQL and PgSQL, etc. should be stopped.
This can be done from the runner by selecting
Stop All there.Then run the
runner and select
Set configuration there or immediately run
setconf and select
Reset to defaults and set the current path as the main path - after that the assembly will be reconfigured to work in this folder.
The main thing to remember is that after this operation all current configs that were replaced with the template! And if you changed something in them, but did not change it in the templates, these changes will be lost.
After reconfiguration, start the services you need from the runner and that's it — you can work. For example, log in to the browser at 127.0.0.1 and (if this setting has not changed in the configuration) the site from the root of webroot should open.
If you run the build for the first time - do not forget to initialize the MySQL / PgSQL database and create at least one database.
Problems
- Skype and some other programs like to sit on localhost on the ports used in the build services (80, 3306, 5432) - naturally, attempts to start these services will lead to a crash.
- In the firewall and anti-viruses, the appropriate permissions must be given for the localhost and services running on it.
Some questions and answers to them
- Why not on PowerShell?
In those days, when I started writing ps, I was still in the project. And if you write on something, then on the shell of your system. - Why so old school cmd? Why not write a beautiful GUI?
An interesting question of course. But everything is trivial enough - on cmd, so that you can easily change something - including adding or removing menu items, etc. This is the easiest time-consuming path, and I needed to quickly implement a convenient portable and easily configurable functionality. Yes, and to make a cool interface that comes 1-2 times at the very beginning seems to me impractical. But! Since all the commands of this interface are available from services.cmd (and besides, they are very simple in functionality), then if you want a GUI pin, you can wash it yourself with geisha and passion fruit juice without any problems (plus from me and others using this thing , get a bunch of thanks) - What does the build configuration menu look like?
- Where to get?
Download the build from here protocoder.ru/site/articles/WWSK/wwsk.zip (163 Mb)
Here in general, that's all.
I tried to make the simplest solution possible and describe it as simply as possible.
Hopefully, the elementals will sleep well now, and the web developer will finally do what he must with - development.
I think that the main advantage of this assembly is the absence of everything superfluous - only the most necessary - everything else is freely configured “dear to yourself”, for something is something, and then cmd / bat is not difficult to work with Windows.
All your necessary tools can always be hidden in the Tools daddy and work with them in the menu, if required.
But to decide how it happened to you in fact - any questions, bug reports and suggestions are welcome - I will be very happy for them.
I hope you enjoy working with this thing, and someone's time and nerves saved is the best reward for me.
PS Thank you very much UFO and all good people - now I am also in this wonderful community!