Home > Uncategorized > Nginx + PHP-FPM + MySQL under CYGWIN

Nginx + PHP-FPM + MySQL under CYGWIN

An adaption from How to install Nginx, PHP, PHP-FPM and MySQL under Windows with Cygwin by Michel Nadeau.

I really prefer my linux server over this, but I have siblings that use windows instead of linux.

Like every other tutorial, we set up our grand environment. Things needed go as follows:

Note: As of 7/27/2010, the latest version of Cygwin is 1.7.5 and MySQL is 1.5.49. Libevent is 1.4.10 stable and is not packaged in cygwin anymore and I don’t know why.

Those are about the only things you will need to download for this gig.

1 – Installing CYGWIN

Run Setup.exe(Cygwin’s setup file). First thing it shows you is a choice to do 3 of the following:

– Install from Internet
– Download Without Installing
– Install from Local Directory

First option is to download, save, and install directly.
Second option is to download and save only.
Third option is to install what you have downloaded and saved.

We will go with the first option and to install it directly. Do note that you have a choice to compile your own MySQL libraries or download/install precompiled libraries from cygwinports.

For those who want to download precompiled MySQL libraries there is a chance you will have to run the setup twice.

Well to continue, keep clicking next until you reached Choose a Download Site. For those who wish to use precomiled libraries, grab a mirror from here and paste it into the little text box next to User URL and click ADD. Select your new url and click next.

Extra packages to select on top of default packages:

– Admin\cygrunsrv
– Devel\autoconf
– Devel\automake
– Devel\bison
– Devel\flex
– Devel\gcc
– Devel\libiconv (Useless since PHP can not seem to find the location of libiconv)
– Devel\libjpeg-devel
– Devel\libmcrypt
– Devel\libncurses-devel
– Devel\libncursesw-devel
– Devel\libpng12-devel
– Devel\libtool
– Devel\libxml2
– Devel\libxml2-devel
– Devel\make
– Devel\openssl-devel
– Devel\patchutils
– Devel\zlib-devel
– Editors\vim
– Libs\crypt
– Libs\gd
– Libs\jpeg
– Libs\libbz2-devel
– Libs\libbz2_1
– Libs\libcurl3
– Libs\libgd-devel
– Libs\libgd2
– Net\curl
– Net\libcurl-devel
– Net\libcurl4

These are what some of the basics I had for cygwin. For those choosing the precompiled libraries of MySQL, at the top in the box type mysql and select the development package for libmysqld-devel, libmysqlclient-devel, and libmysqlclient16. The precompiled version is 5.1.47.

After that, let it download and install. Alright, you finished setting up your compiling environment.

libevent

This is a required library for PHP.
Either copy the tar file into your Cygwin Home directory or extract it to your cygwin home directory.
People who extracted it already goto step 2. Those who copied the tar file, start with step 1.
C:\cygwin\Home\Username\ << Cygwin Home Directory – where Username is the username you use to login to windows.

1. If you copied the tar file, run the following command:

tar -zxvf libevent-X.Y.Z-stable.tar.gz

2. then change into libevent's folder and configure/compile it

cd libevent-X.Y.Z
./configure
make && make install
cd ~

That's it for libevent

MySQL Client Libraries
This is only for those who did not download the precompiled libraries.

Copy the tar file into cygwin’s home directory. Untar it.

tar -zxvf mysql-5.1.49.tar.gz

Change into it’s directory.

cd mysql-5.1.49

Run the configure command and make it!

./configure –without-server –with-readline
make && make install
cd ~

That’s it for mysql. If you’re wondering why I add the –with-readline syntax, I believe this is telling mysql to use it’s bundled readline instead of the global readline. Not sure though.

nginx

copy the tar file into cygwin’s home directory, untar, configure, and make.

tar -zxvf nginx-0.7.67.tar.gz
cd nginx-0.7.67
./configure –with-http_ssl_module –without-mail_pop3_module –without-mail_imap_module –without-mail_smtp_module
make && make install

That’s it for nginx.

PHP

The most painful compilation ever, or most stressful one to get it to compile under cygwin.

Grab PHP 5.3.3 source file, preferably the gz version and place it into cygwin’s home directory.
Change directory in Cygwin’s Bash shell to the home directory and unpack it:

cd ~
tar -zxvf php-5.3.3.tar.gz

Go into php’s directory.

cd php-5.3.3

Now, run the following commands.

PHP_AUTOCONF=autoconf-2.13 ./builconf –force
./configure –with-config-file-path=/usr/local/lib/php \
–enable-fpm \
–with-mcrypt \
–with-zlib \
–without-iconv \
–enable-mbstring \
–disable-pdo \
–with-curl \
–with-bz2 \
–with-mysql=/usr/local/include/mysql \
–with-mysqli=shared,mysqlnd \
–with-mhash \
–enable-bcmath \
–enable-calendar \
–enable-soap \
–enable-sockets \
–with-gd \
–with-jpeg-dir \
–with-png-dir \
–with-openssl \
–without-sqlite
make && make install

Hopefully, you didn’t get any errors. In this setup of php, we took out iconv. I took it out because in my setup, PHP wasn’t able to find iconv’s directory even when I added it to iconv. If you do need iconv, you can try –with-iconv=/usr/include but I wasn’t able to get it to work with mines.

Now you can test it and see how it runs. Have fun. Oh yeah almost forgot, you can use the win32 binary installation of MySQL. Just remember to point all your web configuration to 127.0.0.1 instead of localhost when connecting to MySQL inside PHP files. Feel free to ask any questions you have, and know that I’ll try to help to the best of my knowledge.

Categories: Uncategorized
  1. March 7, 2011 at 10:42 pm

    Thanks for the article, I’m just trying to make it work with high performance..

  1. No trackbacks yet.

Leave a comment