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 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 CPT6 from 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... We...

How to Install Visual Basic 2017 Offline

This page offers a way to avoid the long and error-prone online installation of Visual Studio which is a massive package. Our interest is limited to Visual Basic and ASP.Net. One can, later, add other tools such as C# and C++. In this page, "VS" refers to Visual Studio. Installing Visual Basic 2017 Offline is not a simple process because Visual Basic 2017 is a part of Visual Studio 2017 that comes as one huge package (up to 35GB) in three versions: Community Edition (Free) Professional Edition (intended for a few people) Enterprise (intended for larger software teams)  Visual Studio by default uses a web-based install process that starts by downloading one of three the bootstrapper package from the VS download page . When you run the bootstraper, it will initiate download of the Visual Studio components that may be up to 35GB in size and takes a very long time to complete. The purpose of this page is to explain how to avoid the headache of this long and tedious ...

Android Applications with Intellij IDEA - 1

This article applies to Android applications in Windows using IntelliJ IDEA development tools. Windows 7 was used in this example but the explanation will work for other recent versions of Windows. It is quite a task learning how to use mobile application development tools. This page describes how to digitally sign your .apk file which is the  Android application package file. In short, your Android program file. Once you have created an APK file to launch it, simply copy to your device and use the Android file manager to install it. The picture below shows the digital signature keystore file, the unsigned APK file and the signed APK file. The procedure of signing the APK file is quite straighforward but first you must ensure your Java JDK is properly installed and that the Java tools are accessible on your commandline (Windows command console - what used to be called the DOS window). Most important is that your PATH environmental variable (In Windows 7 find thi...