- Log into your Windows Server. Once you have logged in, click on "Start" > "Run" and type MMC and then press ok / enter.
- The Windows MMC (Microsoft Management Console) will appear. In the Console click "File" > "Add/Remove Snap-in".
- You will now need to browse for "IP Security Policy Management" and highlight it. Once it is highlighted, click "Add" that is located in the middle pane.
- You will need to select the computer or domain you want to add the snap-in for. Choose "Local Computer" and click "Finish".
- Now click "OK".
- You will be back at the console but you will now have "IP Security Policies on Local Computer" listed. Right click on "IP Security Policies on Local Computer" and then select "Create IP Security Policy".
-
You will now be at the IP Security Policy Wizard screen. Click Next to continue.8.You will now need to name your policy. For this article we are blocking an IP address, so call it "Block IP Address ", give it a description and then click "Next"9. You will be prompted to "Activate the default response rule", however this only applies to previous versions of Windows such as Windows Vista and Windows 2003. Leave this unchecked and click "Next
10. You policy is now created. Click "Finish" to proceed.
11. You will now be at the properties screen for your new policy. Click "Add" to continue.
12. You will now be at the "Welcome to the Create IP Security Rule Wizard". Click "Next".
13.You will now see the "Tunnel Endpoint" screen. Select "This rule does not specify a tunnel and click "Next".
14. For your network type, select "All Network Connections and click "Next".
15. You will now be at the "IP Filter List". Here you can specify the ruleset for your policy. You're your rule a name and click "Add" to setup a custom rule.
16. You will now be able the IP Filter Description and Mirrored Property Screen. Leave the "Mirrored" option checked and click "Next".
17. Now you will be able to select the source address for your rule. Since we want to block an IP Address, we need to select "A specific IP Address or Subnet".
18. Once you select this rule, you will now be able to specify the IP or Range. Fill in the IP or Range and click "Next".
19. Now we will need to select the "Destination Address". Change this to "My Address" and click "Next".
21. Now you can specify the port that you want to block the IP or IP's from accessing. This is very useful if you want to block HTTP or MSSQL, etc. For this example we will select HTTP so we will need to choose port 80. So leave the from port to "Any Port" and the to port at "To this Port" and fill the box with 80. Now click "Next".
22.You will have now completed your rule. Click on "Finish" to close the wizard.
23.Now you will need to enable the rule. To do this, make sure it is selected at the "IP Filter List". Then click "Next".
25. You will need to name the Action. For this article we will call is Block IP. Then Click "Next"26. Now you will need to select the action behavior. You will have 3 chooses; Permit, Block or Negotiate Security. Choose "Block" and click "Next" and then at the next screen click "Finish".
27.Make sure the IP Action is also selected and then click "Next"
28.You will now be at the Policy Properties again. Make sure the new rule is selected and click "Apply" and then "OK".
29. Finally you will be back at the console screen. Right click on the new policy and click "Assign". This will activate the rule.
You have successfully created an IPsec policy and activated it.
How to Block an IP Address using IPSec on 2003
This article will walk you through how to block an individual IP address from accessing your server, using an IPSec Security Policy.
For various reasons, you may find yourself wanting to block a specific IP address from accessing your server.
Simply following these instructions showing how to create an IPSec Security Policy specifying to block access to a specific IP address.
1. Click on the Start Menu and Click on Run.
2. Type "secpol.msc" and Click OK.
3. When the Local Security Settings console opens, Click on "IP Security Policies on Local Computer".
4.Right Click in the Right Window Pane and Click "Create IP Security Policy".
5.Click Next when the Wizard opens.
6. Here you can name your new IPSec Security Policy. In this example, we named it "Blocked IPs". When you are ready, Click Next.
7. Uncheck the box for “Activate the default Response Rule” and then click Next Button..
8. On the Next screen remove the check for Edit Properties and Click Finish.9.Once you click on the Finish Button you will see the screen below along with your rule being added to the list. Now we will create an IP filter list to block IPs.10.Double click on the rule you have just create to open the properties window:11. Since we have chosen to uncheck “Activate the default Response Rule” in Step 7 the Dynamic rule in not applied. Click on Add button to open Security Rule Wizard and Click again on Add button to open IP Filter List Wizard.12. You will have a screen some what in Figure 12. Put in the name of your list and Click on the Add button.13. This will open another window for you to add IP and ports in the IP Filter list. In the Description box just put in the IP address that you want to block and make sure that you keep the check on the box for “Mirrored. Match packets with the exact appropriate source and destination addresses” and click on the Next button.14. Select My IP address in the Sources Address from the drop down list.
15. You have many more options to select from the list for both in Sources and Destination Address. You will need some advanced knowledge to work with those option. We will select My IP address for now and click on Next button.16. In the IP Traffic Destination, select “A specific IP Address” and enter the IP address that you want to block on your machine. Here you can also select a sub net from the drop down and block the entire subnet. Once you finish entering an IP/Subnet, click on Next button.17.Here in IP Protocol Type you can define the protocol that you want to block, it can be any one from the list for example TCP, UDP, ICMP etc. We will select ANY which mean all connect from a specific IP address. If you select a protocol from the list andclick Next it will ask you to enter the port address that you want to block, example 80 (See Figure 17.2). But since we want to block all ports we will select Any and click Next (Figure 17.1) and then Finish.18. After you click on Finish button you will see that the rule has been added in the IP filter list. If you want to add more IP and subnets then click on the Add button to add another rule or block 2nd IP. Once you finish with it you will have rules as in Figure 18.2.19. Once your IP Filter List is complete click on the OK button to get back Security Rule Wizard. Select the IP filter list which you have created by clicking on the radio button and click Next.
20. In the Next screen of Security Rule Wizard you will not see any Filter Action as Block as by default it is not created. We will create a Filter action to block connect by click on Add button.21.In the Name type “Block” and any discryption you like and click on Next.22. In Filter Action General options select Block and click Next.23.And then on Finish to get back to Security Rule Wizard.24. This will add the Filter option as Block in the list, just click on radio button to select it and click Next.25. Click Finish to complete the security Rule Wizard.26. You will see the rule added in the list, you can add more rule with the same steps. Now just click OK to finish with the rules.27.Now since we have already created the rules to block desired IP address just right click on the IP Security Policy and select Assign to apply the rule on the server.There are allot many option to secure your entire server with IP security policy. You can create more rules to block every one on RDP port TCP 3389 and allow only select IPs. IP Security is IP and port based application and not Services based and you can create the rule as per your need.
A blog for Server Administrators. Find free technical support on a variety of issues faced with the hosting servers and plenty of how-to's on new technology. It contains answers to all the day to day issues faced on servers.
Wednesday, 12 September 2012
Set up an IP Security Policy Rule for Windows 2008 and 2003
Tuesday, 11 September 2012
Install PHPMyAdmin on IIS7 and Server 2008
After installing our copy of MySQL on IIS7 and Server 2008,
you might be wondering what to do next. Well if you don’t feel like
learning the command line sequences for MySQL you might be interested in
using a web based GUI based tool which will make managing the databases
a lot easier.
This tool is called PHPMyAdmin and can be found at www.phpmyadmin.net.
What will you be able to do with PHPMyAdmin in the database? Here is a list of some of the features:
Note: PHPMyAdmin requires both PHP and MySql to be installed on the server.
The current version as I write this article is 2.11.9, so I am going to go ahead and download that to get started. Which version you use will depend on your environment; I am going to use the english.zip for this demo. Let’s get started!
1. Extract the files from the archive to a site that is available on the web server (remember the application is web based).
For this demo I am going to use C:\inetpub\wwwroot\phpmyadmin
2. Now start IIS Manager and expand the default website; right click on phpmyadmin and left click on Convert to Application.
3. You can leave the default settings in place for the Add Application window and click OK.
4. Create a folder to save your PHP sessions; for our example I am going to use C:\temp\phpsessions and give full rights to the following users:
IUSR
IIS_IUSRS
Network Service
5. Now go into your php directory and find php.ini — we have to make a few changes:
Find session.save_path and set it to the same as you used in step 4 which in our case is C:\temp\phpsessions and save the file.
6. Please note that this application requires the following extensions for PHP:
MySQL
GD
MBSTRING
If you do not have these on your server already, please install them. If you are using my article to install PHP then in step 6 just add the above extensions to your installation, or if you already installed it rerun the installer msi file and modify your installation to include these extensions.
To check if they are installed do a search for extension=php_mysql in the php.ini and you should see it uncommented.
Do the same for the other extensions:
extension=php_gd2.dll
extension=php_mbstring.dll
7. Go into IIS Manager, go to the default site (that is if you have been following my demo, if you have been modifying your site location or path then use that) and click on Default Document.
8. In the right pane click Add…
9. In the dialog box type index.php and click Ok.
10. Go to the directory that you unzipped PHPMyAdmin to and look for a file named config.sample.inc.php and open it in Wordpad. (You can use notepad but it tends to jumble everything up)
11. Now find the line $cfg[‘blowfish_secret’] = ‘’; you have to fill in this line with anything that you want but it needs to be a value.
Only up to 46 characters and it can be alphanumeric. In this case I am going to use trainsignal1111TST
12. Go down to you see the section User for advanced features and uncomment (Remove the // from the front of the line) the two lines under that and change the pmapass to a different password, for this demo I am going to use trainsignal.
13. next, go down to the next section Advanced phpMyadmin features and uncomment all the lines under it (remove the // from the front of the line).
14. Now save this file as config.inc.php
15. Point your browser to http://localhost/phpmyadmin/ (if you have been following this example; if you have used a different site/directory then point to that) and you should see a login page.
Type in the userid and password for your local MySql server, then click Go.
16. Now you are in and able to manage your MySql instance!
As a quick test let’s create a database by scrolling to the Database link and clicking on it
17. Type in the name of your new database, for this example I am going to use Trainsignaltraining and then click Create.
18. You will now see a page that confirms that database Trainsignaltraining has been created.
That’s all there is to it, now you can quickly and easily manage you MySql databases on IIS7 through PHPMyAdmin.
This tool is called PHPMyAdmin and can be found at www.phpmyadmin.net.
What will you be able to do with PHPMyAdmin in the database? Here is a list of some of the features:
- browse and drop databases, tables, views, fields and indexes
- create, copy, drop, rename and alter databases, tables, fields and indexes
- maintenance server, databases and tables, with proposals on server configuration
- execute, edit and bookmark any SQL-statement, even batch-queries
- load text files into tables
- administer multiple servers
- create and read dumps of tables
- search globally in a database or a subset of it
Note: PHPMyAdmin requires both PHP and MySql to be installed on the server.
Download and Install PHPMyAdmin
Ok so now that we know why we should install it, let’s get to the actual installation part. But before we begin, let’s go download the software at: www.phpmyadmin.net/home_page/downloads.php.The current version as I write this article is 2.11.9, so I am going to go ahead and download that to get started. Which version you use will depend on your environment; I am going to use the english.zip for this demo. Let’s get started!
1. Extract the files from the archive to a site that is available on the web server (remember the application is web based).
For this demo I am going to use C:\inetpub\wwwroot\phpmyadmin
2. Now start IIS Manager and expand the default website; right click on phpmyadmin and left click on Convert to Application.
3. You can leave the default settings in place for the Add Application window and click OK.
4. Create a folder to save your PHP sessions; for our example I am going to use C:\temp\phpsessions and give full rights to the following users:
IUSR
IIS_IUSRS
Network Service
5. Now go into your php directory and find php.ini — we have to make a few changes:
Find session.save_path and set it to the same as you used in step 4 which in our case is C:\temp\phpsessions and save the file.
6. Please note that this application requires the following extensions for PHP:
MySQL
GD
MBSTRING
If you do not have these on your server already, please install them. If you are using my article to install PHP then in step 6 just add the above extensions to your installation, or if you already installed it rerun the installer msi file and modify your installation to include these extensions.
To check if they are installed do a search for extension=php_mysql in the php.ini and you should see it uncommented.
Do the same for the other extensions:
extension=php_gd2.dll
extension=php_mbstring.dll
7. Go into IIS Manager, go to the default site (that is if you have been following my demo, if you have been modifying your site location or path then use that) and click on Default Document.
8. In the right pane click Add…
9. In the dialog box type index.php and click Ok.
10. Go to the directory that you unzipped PHPMyAdmin to and look for a file named config.sample.inc.php and open it in Wordpad. (You can use notepad but it tends to jumble everything up)
11. Now find the line $cfg[‘blowfish_secret’] = ‘’; you have to fill in this line with anything that you want but it needs to be a value.
Only up to 46 characters and it can be alphanumeric. In this case I am going to use trainsignal1111TST
12. Go down to you see the section User for advanced features and uncomment (Remove the // from the front of the line) the two lines under that and change the pmapass to a different password, for this demo I am going to use trainsignal.
13. next, go down to the next section Advanced phpMyadmin features and uncomment all the lines under it (remove the // from the front of the line).
14. Now save this file as config.inc.php
15. Point your browser to http://localhost/phpmyadmin/ (if you have been following this example; if you have used a different site/directory then point to that) and you should see a login page.
Type in the userid and password for your local MySql server, then click Go.
16. Now you are in and able to manage your MySql instance!
As a quick test let’s create a database by scrolling to the Database link and clicking on it
17. Type in the name of your new database, for this example I am going to use Trainsignaltraining and then click Create.
18. You will now see a page that confirms that database Trainsignaltraining has been created.
That’s all there is to it, now you can quickly and easily manage you MySql databases on IIS7 through PHPMyAdmin.
Monday, 10 September 2012
Install MySQL on a Windows Server
The following article explains how to install MySQL on a Windows
Server. The process involves downloading the latest version of MySQL
directly to your Windows server and then installing the software. MySQL
is a free product. Once installed, you may begin creating and using
MySQL databases on your server.
6.Accept the License Agreement and click Next.
7.Select Typical Installation and click Next.
8.Click Install. The installation will take a few moments.
9.Click Next until you reach the Wizard Completed screen.
10.Check Configure the MySQL Server now and click Finish.
11.Click Next to begin the MySQL Server Instance Configuration Wizard.
12. Select Detailed Configuration and click Next.
13.Select Multifunctional Database and click Next.
14.For InnoDB Tablespace Settings, leave the default settings and click Next.
15.Select Online Transaction Processing (OLTP) and click Next.
16.Check Enable TCP/IP Networking, leave the default Port Number and click Next.
17. Select Standard Character Set and click Next.
18.Check Install as Windows Service, uncheck Include BIN directory in Windows PATH and click Next.
19.Enter a password for your root user, uncheck Create an Anonymous Account and click Next.
20.Click Execute to complete the installation.
As mentioned earlier, I will assume that you have already set up PHP.
To install MySQL, please follow these steps:
- Log into your server through Terminal Services or Remote Desktop Connection.
- Open a Web browser and load http://dev.mysql.com/downloads/
- Download Windows (x86) ZIP/Setup.exe (there's no need to sign up. It is a free download).
- Unzip the file you downloaded above and run Setup.exe.
6.Accept the License Agreement and click Next.
7.Select Typical Installation and click Next.
8.Click Install. The installation will take a few moments.
9.Click Next until you reach the Wizard Completed screen.
10.Check Configure the MySQL Server now and click Finish.
11.Click Next to begin the MySQL Server Instance Configuration Wizard.
12. Select Detailed Configuration and click Next.
13.Select Multifunctional Database and click Next.
14.For InnoDB Tablespace Settings, leave the default settings and click Next.
15.Select Online Transaction Processing (OLTP) and click Next.
16.Check Enable TCP/IP Networking, leave the default Port Number and click Next.
17. Select Standard Character Set and click Next.
18.Check Install as Windows Service, uncheck Include BIN directory in Windows PATH and click Next.
19.Enter a password for your root user, uncheck Create an Anonymous Account and click Next.
20.Click Execute to complete the installation.
Modifying Your PHP Configuration to Allow Your PHP Scripts to Use MySQL
Now that you have a MySQL server running on your machine, you will probably want to set up PHP so that your scripts can access databases on the server.As mentioned earlier, I will assume that you have already set up PHP.
-
Open up your
php.inifile in Notepad. If you have followed the steps in my guide, you should already be familiar with how to do this. The file itself can be found inc:\php\php.ini(unless you have installed it elsewhere).
-
Look for the following line.
extension_dir = "./"Modify it so that it now looks like this:
extension_dir = "c:\php\ext"If you used my guide to set up PHP before, "c:\php\ext" is where the extensions were installed. Those who installed PHP in a different folder should of course put the correct path in theextension_dirsetting.
-
Now search for the following line:
;extension=php_mysql.dll(Be careful. It's surrounded by a number of lines that look very similar. Be sure you get the line that has "php_mysql.dll" and not "php_msql.dll", "php_mssql.dll" or "php_mysqli.dll".)
Remove the initial semi-colon (";") so that the line now looks like this:
extension=php_mysql.dll(A semi-colon indicates the start of a comment, which is ignored by the PHP interpreter. Removing it makes the line a configuration setting.)
-
Save the file and close Notepad.
-
Now start up Windows Explorer. That is, click the Start menu, followed
by "Computer". A window should open. Look for "System properties"
somewhere
near the top of the window. Click it. Then click "Advanced system
settings" in the left column. The Vista User Account Control
should appear. Click "Continue".
In the "System Properties" dialog box that appears, click the "Environment Variables" button. In the list box under "System variables", look for the line that has "Path" in the first column. Click it to select it. Click the "Edit" button.
A dialog box entitled "Edit System Variable" appears. Click somewhere in the "Variable value" line and use your arrow key to move to the end of the line (or just use the "End" key on your keyboard). Append the following:
;c:\php(Note: the above starts with a semi-colon and is followed by the directory/folder where you installed PHP.)
This adds "c:\php" to the "PATH" environment variable, which is basically a list of directories that Windows searches for when it needs to look for a program or components of a program. You need to do this because PHP needs it to load a file calledlibmysql.dll, located in that directory. For some reason, it doesn't seem to be able to do it if "c:\php" is not in the PATH (even though it's the same directory as the PHP program itself).
Once you have done this, restart your computer.
-
After you reboot your computer, a simple PHP script like the following
should be run to make sure that the PHP is able to load the
MySQL libraries (DLLs).
<?php phpinfo(); ?>Save the script as "test.php" in your "htdocs" directory and invoke it from your browser with "http://localhost/test.php". You should now be able to see a new section called "mysql" in the report. This means that PHP was successful in loading its MySQL-related libraries (the extension and libmysql.dll libraries).
Wednesday, 8 August 2012
Install and Configure PHP
Introduction
The fastest and easiest way to install PHP on Internet Information Services (IIS) is by using the Microsoft® Web Platform Installer (Web PI). Web PI completely automates setting up IIS, FastCGI, and the latest version of PHP from the php.net Web site. With Web PI, you can navigate to the “Web Platform” tab and select “PHP” under “Framework and Runtimes” customize link. Alternately, use the instructions that follow as guidance for installing PHP with Windows® Installer or using a compressed (Zip) file installation.
There are two builds for each PHP version: one is thread-safe, and one is not (referred to as the non-thread-safe [NTS] version). The thread-safe version is designed for environments where the Web server core can keep the PHP engine in memory, running multiple treads of execution for different Web requests simultaneously. The architecture of IIS and the FastCGI extension provide an isolation model that keeps requests separate, removing the need for a thread-safe version. The NTS version does not have any of the code that allows PHP to manage multiple threads. As a result, there is a performance improvement on IIS when using the NTS version when compared to the tread-safe version because the NTS version avoids unnecessary thread-safety checks (FastCGI ensures a single-threaded execution environment).
Install PHP
There are two main ways to install PHP on a Windows®-based computer: download the Windows Installer or use the Windows Zip file from the PHP Web site. Either method will get PHP working, but both have some extra steps that are needed to make PHP work well.
Windows Installer The Windows Installer version can get a complete PHP environment up and running, but the installation of extensions can be confusing. By default, no extensions are installed, and this can adversely affect the usefulness of the PHP installation. Alternately, all of the extensions can be installed; this results in an unstable system because some of the extensions can conflict with others. It is generally easier to use the Zip file installation.
Zip File Installation
The Zip file installation installs many of the extensions that are available for the Windows Installer version; however, none of the extensions are enabled until their entries in the Php.ini file are set up.
The Zip file installation installs many of the extensions that are available for the Windows Installer version; however, none of the extensions are enabled until their entries in the Php.ini file are set up.
1. Download the latest non-thread-safe Zip file package with binaries of PHP. Under Windows Binaries, click on the most current PHP non-thread-safe Zip package to download the PHP files.
2. Unpack the files to a directory of your choice (for example, C:\PHP) on your IIS server.
3. Rename the Php.ini-recommended to php.ini.
4. Open the Php.ini file in a text editor, then uncomment and modify settings as follows:
a. Set fastcgi.impersonate = 1.
FastCGI under IIS supports the ability to impersonate security tokens of the calling client. This allows IIS to define the security context that the request runs under.
FastCGI under IIS supports the ability to impersonate security tokens of the calling client. This allows IIS to define the security context that the request runs under.
b. Set cgi.fix_pathinfo=0
The cgi.fix_pathinfo provides PATH_INFO/PATH_TRANSLATED support for Common Gateway Interface (CGI). Setting this to 1 will cause PHP CGI to fix its paths to conform to the specification.
The cgi.fix_pathinfo provides PATH_INFO/PATH_TRANSLATED support for Common Gateway Interface (CGI). Setting this to 1 will cause PHP CGI to fix its paths to conform to the specification.
c. Set cgi.force_redirect = 0.
d. Set open_basedir to point to a folder or network path where the content of the Web site(s) is located.
e. Set extension_dir to point to a location where PHP extensions reside. For PHP 5.2.X, this is typically extension_dir = "./ext" .
f. Set error_log=”C:php_errors.log”
This can help with troubleshooting.
This can help with troubleshooting.
g. Enable the required PHP extension by un-commenting corresponding lines.
5. Click on Start, Settings, Control Panel, and then double-click on the System icon (using the class view).
6. Click on the Advanced system settings link in the left column.
7. From the System Properties window, click on the Advanced tab, and then click on the Environment Variables button at the bottom.
8. Select the Path variable from the System Variables section, and then click on Edit. Add: c:\php to your system path.
Figure 2: Edit System Variable
9. Click OK until you have exited the System Properties window.
10. Start IIS Manager by clicking on Start, Programs, Administrative Tools, and then Internet Information Services (IIS) Manager.
11. From the IIS Manager, click on the hostname of your server in the Connections panel on the left.
12. Double-click on the Handler Mappings icon.
Figure 3: Internet Information Services (IIS) Manager
13. From the Handler Mappings Actions panel, click on Add Module Mapping.
Figure 4: Handler Mappings
14. Type the following information into the appropriate text boxes, and then click OK.
- Request path: *.php
- Module: FastCGImodule
- Executable: C:\php\php-cgi.exe
- Name: FastCGI
Figure 5: Add Script Map
15. Click OK, and then click Yes.
16. In the left panel, click on your server’s hostname, and then double-click on the Default Document icon.
17. From the Actions panel on the right, click Add.
18. Enter index.php as the new default document name, and then click OK.
19. Enter default.php as the new default document name, and then click OK.
20. In the left panel, click on your server’s hostname.
21. In the Actions panel on the right, click Restart.
22. Create a new text document, and save it as c:\inetpub\wwwroot\phpinfo.php with the following content:
<?php phpinfo(); ?>
23. You should now see the PHP information page at http://localhost/phpinfo.php.
Extensions
It is important to determine which extensions are needed by the applications that will be running and then to limit the installed extensions to only those. For a typical open-source application installation, for example, the following extensions are installed:
- Database Extensions—Most open-source applications that use MySQL for a database engine use either the php_mysql or the php_mysqli extensions. For new development work, either of these extensions work well, or consider using the PDO versions of the MySQL driver (PDO is a PHP extension providing a data-access abstraction layer that can be used with a variety of databases); this extra layer of abstraction provides a richer set of object database functionality and controls. If Microsoft® SQL Server® (or an express version, such as Microsoft® SQL Server® 2008 Express or Microsoft® SQL Server®2005 Express Edition) is the database engine, use the php_mssql extension for open-source applications. For new development work, use the PDO version of the SQL driver.
- Image Handling Extensions—Many of the open-source applications that enable work with images make use of the GD2 extension – php_gd2, which has a number of good basic image manipulation application programming interfaces (APIs). Some applications use the ImageMagick application and libraries. There is also a php_exif library for working with the extended information that modern digital cameras store within the images.
- Internationalization and Localization Extensions—The two most commonly used extensions for i18n and l10n are php_mbstring (Multi-Byte String) and php_gettext (Native Language Support). Many of the open-source applications use one or both of these.
- Web Services Extensions—Choose the Web services extensions based on the services desired. For PHP, the SOAP extension is widely used. The XML-RPC extension is often used in conjunction with SOAP and other services.
PHP.INI File Settings
The Php.ini file provides PHP with configuration and environmental information. Below are a number of settings for the Php.ini file that help PHP work better with Windows.
Required Settings:
- extension_dir = <PATH TO EXTENSIONS>The extension_dir needs to point to the directory where the PHP extensions are stored. The path can be fully qualified (for example, C:\PHP\ext) or relative (for example, .\ext). Extensions that are specified lower in the Php.ini file need to be located in the extension_dir. If the extensions specified are not in the extension_dir, then PHP will give a warning message at the start of script execution, and the application may show errors because of the missing functionality.
- extension = xxxxxx.dllFor each extension enabled, a corresponding extension= directive that tells PHP which extensions in the extension_dir to load at startup time is necessary.
- log_errors=OnPHP errors can also go through the PHP error logging facility. This can be used to send errors to a file or to a service (for example, syslog) and works with the error_log directive described below. When running under IIS, log_errors must be enabled with a valid error_log. Otherwise, FastCGI considers any startup messages (which may be benign) as an error condition, which generates an HTTP 500 return error code to the browser.
- error_log=<path_to_error_log_file” The error_log needs to specify the fully qualified, or relative, path to the file where the PHP error log is stored. This file needs to be writable for the IIS service. The most common places for this file are in various temporary directories (for example, C:\inetpub\temp\php-errors.log). That puts the log in a place that IIS can use, and also keeps the log close to where PHP applications are running.
- cgi.force_redirect = 0This directive is required for running under IIS. It is a directory security facility required by many other Web servers; however, enabling it under IIS will cause the PHP engine to fail on Windows.
- cgi.fix_pathinfo = 1This lets PHP access real path info following the CGI specification. The IIS FastCGI implementation needs this extension set.
- fastcgi.impersonate = 1FastCGI under IIS supports the ability to impersonate security tokens of the calling client. This allows IIS to define the security context that the request runs under.
- fastcgi.logging = 0FastCGI logging should be disabled on IIS. If it is left enabled, then any messages of any class are treated by FastCGI as error conditions, which will cause IIS to generate an HTTP 500 exception.
Optional Settings:
- max_execution_time=##This directive sets the maximum amount of time that can be taken executing any given script. The default is 30 seconds. Some applications need more time to process batch operations (for example, Gallery2 loading multiple images from a remote location). However, setting the execution time higher than 300 seconds is not advised because there are often other parts of the connection that cannot support such a long execution time.
- memory_limit=###M The amount of memory available for the PHP process (in MB). The default is 128 MB, which is appropriate for most PHP applications.
- display_errors=Off This directive determines whether to include any error messages in the stream that it returns to the Web server. If turned on, PHP will send the classes of errors that are defined with the error_reporting directive back to IIS as part of the error stream. Many of the open-source applications bypass error reporting by executing commands prefaced with @. This allows the applications to control error handling.
- Mail functionsPHP is configured by default to send outbound mail through an SMTP server located on the same system as the Web server. Note that most Windows installations usually have the Web and mail servers on separate systems.
Enable PHP Session State
1. In Windows® Explorer, create the session subdirectory in the PHP installation directory.
2. Right-click the session directory, and select Properties.
3. In the Security tab, click Edit.
4. Click Add, and enter IIS_IUSRS for Enter the object names to select.
5. Click OK.
6. Select the Modify permission check box, and click OK.
7. Click OK in the Session Properties window.
8. Open php.ini in the PHP installation directory, and set the session.save_path setting to the session subdirectory:
session.save_path = "C:\php\session"
9. Save and close the file.
10. Click Start, and then select Command Prompt.
11. Type runas /user:administrator cmd.exe to enable elevated permissions.
12. Type iisreset at the command prompt, and then press the ENTER key.
Figure 8: IISRESET command
Note that PHP uses file-based session state by default. You can modify a number of additional session settings, including whether cookie or URL sessions should be used, and whether sessions are created on the first request or need to be explicitly created.
13. Test the session state by using Windows Explorer, navigate to C:\inetpub\wwwroot.
14. Create a folder and rename it phpapp.
15. Create session.php in the phpapp directory.
16. Paste the following into it:
<?phpsession_start();
$counter = isset($_SESSION['counter']) ? $_SESSION['counter'] : 0;
$counter++;
print "You have visited this page $counter times during this session";
$_SESSION['counter'] = $counter;
?>
17. Save and close the file.
18. Start Internet Explorer, and navigate to http://localhost/session.php.
Figure 9: Using session state
19. Observe that the counter is 1.
20. Request http://localhost/session.php again, or press F5
Figure 10: Using session state
21. Observe that the counter is 2.
Subscribe to:
Posts (Atom)


























































































