Skip to main content

Installing NGINX with PHP and MySQL


My OS: Windows 7 Home Premuim 64bit

Software Installed:

  1. NGINX 0.9.5 for Windows
  2. PHP: php-5.3.5-Win32-VC6-x86.zip
  3. MySQL: mysql-5.5.9-winx64.msi
NGINX Installation
  1. Unzip into C:\nginx
  2. Change the nginx.conf in C:\nginx\conf as per instructions athttp://blog.siteroller.net/set-up-nginx-mysql-and-php-wemp-on-windows
  3. 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
  1. After downloading the zip version of PHP (V6, threadsafe, zip), unzip into C:\nginx\php\
  2. Rename php.ini-production to php.ini
  3. 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

  1. After downloading the latest VC6 version, run the installer and follow the directions provided at http://blogbuildingu.com/wordpress/install-wordpress-wemp
  2. Set the root password and note it somewhere. You will need it to manage the server.
  3. 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();
?>

Output of test.php:

Comments

Popular posts from this blog

How to Install RIOT Plugin for GIMP

How to Install RIOT Plugin for GIMP:: Since this article was first written a stand-alone version of RIOT has been made available Download the plugin from  http://luci.criosweb.ro/riot/download/Select the download link titled "RIOT as plug-in for other applications"   Launch the Riot-plugin.exe file by double clicking.The installer installs all the files including Riot.exe, Riot.dll, and FreeImage.dll in the location where you installed GIMP  If GIMP is open, close it and re-launch it.To optimise an image, open it then save with menu File-&gt;Save for web with RIOT  You can set the target file size by selecting "Compress to size" button  on bottom right corner of optimised image pane and providing the size in kilobytes. Alternatively you can use a slider provided to allow you to change the quality while showing you a preview of the resulting image.


Enjoy.

How to Stream Live With Your Smartphone

Using Larix Broadcaster , you can stream live video and audio from a smartphone running Android, IOS or Windows. The steps are:
Download and install Larix from the link above.Configure LarixTest with the streaming server provided by whomever is hosting your live streamWhen requested, start sending your stream.
Before giving details explanations of how to configure Larix, its important to note one of two things about the stream:
Many people may be watching worldwide and its important to test and then, during the live stream, ensure only acceptable video and audio are sent to the server. The Larix website illustrates the connection between your phone, server and the viewer devices. Clear video requires planning your shot - from which direction? is the lighting good? will bright lights interfere? Is there traffic noise or other interference.Maintain your smartphone in  landscape orientationIf more than one person are to stream to the same server, be on standby and start your stream promptly…

How to Install Packet Tracer 6.0.1 for Linux

This article is intended to help me remember the installation process for Cisco Packet Tracer 6 details of which seems to be hard to come by on the web.

1. Log in in to your Cisco Netspace account. Yes, you need to be logged in.
2. The "Download PT 6.0.1" link on is on the NetSpace home page.
3. Click this "Cisco Packet Tracer" link shown below the folder icon as shown in the figure below:

4. Select Cisco Packet Tracer 6.0.1
5. Select download location.
6. After completion of download, use your file manager to open that folder and rename the file to something such as "CPT6". It is a shell script so no file extension is required.
7. Change the file permissions to executable using command: sudo chmod 777 CPT6from a terminal window opened in the download directory. This assumes your downloaded file is renamed CPT6
8. Launch the file with command: ./CPT6 from the terminal window. You will get the message:

Self extracting archive...

Welcome to Packet Tracer 6.0…