My OS: Windows 7 Home Premuim 64bit
Software Installed:
- NGINX 0.9.5 for Windows
- PHP: php-5.3.5-Win32-VC6-x86.zip
- MySQL: mysql-5.5.9-winx64.msi
NGINX Installation
- Download from http://nginx.org/en/download.html
- Unzip into C:\nginx
- Change the nginx.conf in C:\nginx\conf as per instructions athttp://blog.siteroller.net/set-up-nginx-mysql-and-php-wemp-on-windows
- See my nginx.conf file here.
Note that in this example, it is assumed that PHP is installed in C:\nginx\php (unzipped into this folder) and MySQl is installed in C:\Program Files\MySQL
PHP Installation
- After downloading the zip version of PHP (V6, threadsafe, zip), unzip into C:\nginx\php\
- Rename php.ini-production to php.ini
- Make changes to this file as given in at http://blog.siteroller.net/set-up-nginx-mysql-and-php-wemp-on-windows but do not expect the line numbers given to match exactly. Activate the extensions extension=php_mysql.dll and extension_dir = "ext"
MySQL Installation
- After downloading the latest VC6 version, run the installer and follow the directions provided at http://blogbuildingu.com/wordpress/install-wordpress-wemp
- Set the root password and note it somewhere. You will need it to manage the server.
- To manage the MySQL server, I would advice you use the mysql.exe console program in the bin directory of the MySQL installation folder. MySQL Administrator was a good GUI tool to administer MySQl but has been discontinued. MySQlL Workbench is a very messy tool that I guess you could figure out how to use if you have the time. I don’t. MySQL.exe is a command line tool. See tutorial at:http://dev.mysql.com/doc/refman/5.0/en/database-use.html In my case, I created a database called coursesb, created a table in this database and then used the LOAD INFILE command to load MS Excel data saved as a CSV file (comma delimited). Example:
LOAD DATA LOCAL INFILE "c:\nginx\courses-acmp.txt" INTO TABLE acmp FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' ;
Note the CSV file’s location is given as an absolute path.
My table creation was achieved with the following:
CREATE TABLE acmp (
sem VARCHAR(3) NOT NULL,
code VARCHAR(10) NOT NULL,
title VARCHAR(100) NOT NULL,
PRIMARY KEY (code)
);
Environmental Variables
Both the location of PHP and MySQL are added to the PATH variable. In my case the paths included are: C:\nginx\php;C:\Program Files\MySQL\MySQL Server 5.5\bin
Starting and Stopping NGINX, PHP and MySQL
In my installation, the following are used to start the servers. They are in C:\nginx where the “RunHiddenConsole.exe” is also located(download from: http://blogbuildingu.com/files/RunHiddenConsole.zip ). The VBS scripts prevent the console window from showing. RunHiddenConsole.exe is also supposed to do the same but doesn’t seem to work. The actual file to run is “start.vbs” You can create a shortcut on your desktop or START menu.
Table : start.bat
@ECHO OFF
ECHO Starting PHP FastCGI...
RunHiddenConsole.exe C:\nginx\php\php-cgi.exe -b 127.0.0.1:10000
ECHO Starting nginx...
c:\nginx\nginx.exe
ECHO Starting MySQL...
RunHiddenConsole.exe "C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld" --defaults-file="C:\Program Files\MySQL\MySQL Server 5.5\my.ini"
SLEEP 1
EXIT |
Table : start.vbs
Dim sh
Set sh = WScript.CreateObject("WScript.Shell")
sh.run "start.bat", 0
Set sh = Nothing |
Table : stop.bat
@ECHO OFF
nginx -s quit
net stop MySQL
taskkill /f /IM php-cgi.exe
EXIT |
Table : stop.vbs
Dim sh
Set sh = WScript.CreateObject("WScript.Shell")
sh.run "stop.bat", 0
Set sh = Nothing |
MySQL should already be running as a service that starts with Windows. The stop.bat scripts should stop MySQL server. Note that you should see php-cgi.exe in memory. NGINX used FastCGI implemented by php-cgi.exe
Test PHP
To test PHP, create the following PHP file and load it using the URL http://localhost/text.php
Test.php is shown below:
Table : test.php
<?php
phpinfo(); ?> |
Comments
Post a Comment