Setting up PHP + MySQL + IIS in Windows

Source: Internet
Author: User
Tags mcrypt
Source: Saidi With the popularity and popularity of network marketing, especially the benefits and profits brought to enterprises through the network, more and more people are aware that in addition to the traditional sales and promotion modes, if the use of network resources to bring profits to enterprises has become an urgent problem for enterprises, many enterprises and individuals have now set up their own servers. The current server market is divided into several systems: the first is the Windows platform, the second is the Linux platform, and the remaining is mainly the BSD platform.


Part 1 Basic Environment Configuration



1. Brief Introduction



With the popularity and popularity of network marketing, especially the benefits and profits brought to enterprises through the network, more and more people are aware that in addition to the traditional sales and promotion modes, if network resources are used to bring profit to enterprises, it has become an urgent problem for enterprises. Therefore, many enterprises and individuals have set up their own servers. The current server market is divided into several systems: the first is the Windows platform, the second is the Linux platform, and the remaining is mainly the BSD platform. First, we will introduce the advantages and disadvantages of various platforms:



The Windows platform is easy to build and has high maintainability. after a short period of training, you can build various services you need. The disadvantage is that Windows has many security vulnerabilities. If you do not have any security-aware administrators to maintain the server, it will soon be compromised, and the stability of the server is not flattering.



The advantage of Linux and BSD is that the permissions are carefully divided and the server stability is well known. Therefore, many large enterprises prefer Linux and BSD platforms. However, the disadvantage is that the maintenance is difficult and not suitable for small and medium enterprises. It takes a lot of money and time to train an all-powerful Linux and BSD system administrator.



Ii. Build a Windows PHP + MySQL + IIS Security Platform



(1) install IIS



1. Install IIS



After installing the system, we may not install IIS by default, so we need to install IIS. First, place the system disk in the optical drive. Then, click "start"> "all ".Program"->" Management Tools "->" manage your servers ".



2. Add a role



In the "manage your servers" window, you can see three main functional modules: "add and delete roles", "Manage File Servers", and "add Shared Folders", as shown in 1, click Add and delete roles to configure and manage servers.











3. Configure the server role



In the displayed dialog box, click "Next". The Configuration Wizard starts to find some installed environments on your local machine, as shown in figure 2, you can configure the file server, Print Server, application server, mail server, Terminal Server, VPN Server, DHCP server, streaming media server, and WINS server, in short, Microsoft windows2003server is much better than windows2000server in terms of management, making the configuration easier. In Figure 2, you can see which servers have been configured.












4. Configure the Application Server



Here, we select the Application Server (IIS, Asp.net) and click the "Next" button. There are two options in the interface shown in 3. The first "frontpageserverextension" is generally unavailable, we recommend that you do not select it for security reasons. The second "enable Asp.net" is to enable Asp.net support. If your program is Asp.net, select "enable Asp.net ", click "Next" to install the SDK. The installation speed is very fast. After the installation is complete, we can run IIS. Click "start" menu> "All Programs"> "Management Tools ", an "IIS Server Manager" is added to the management tool, which indicates that the installation is successful. If this option is not available, repeat the preceding steps to continue or reinstall the tool.












(2) download and install the latest MySQL and PHP



1. Download MySQL



We will download the latest version 6.0.8 from www.mysql.org. For MySQL, [Click to download]



2. Download PHP



If PHP is not available locally, you can download it from PHP: [Click to download]



Why do we need to download the latest version? The hacker research of the latest version is relatively secure. The installation process is very simple. Simply follow the default installation instructions. Here, I will install php in the d: PHP Directory, and I will explain in detail how to configure MySQL later.



(3) Basic PHP preparation



1. Select to configure the php. ini file.



After the PHP installation is complete (in fact, the compressed package is decompressed, and there is also the kind of step-by-step installation of Microsoft MSI, which I have not tried), we first come to the PHP installation directory, here we can see two PHP. INI file, that is, PHP. ini-Dist and PHP. ini-recommended. We 'd better choose PHP. ini-recommended, because this file is an officially optimized PHP file. Change the name of this file to PhP. ini and copy it to the C: Windows directory.



2. Copy the libmysql. dll library file to the system.



Copy libmysql. DLL to the system directory to allow the PHP program to connect to the MySQL database. If MySQL is not used, you do not need to copy it. Here, copy the libmysql. dll file under the "D: PhP" directory to the "C: windowssystem32" directory.



3. Configure the php. ini file



Go to "C: Windows" and find the php. ini file. We need to edit several parameters so that PHP can find the required components such as MySQL library and GD library.



(1) modify the extension_dir parameter. 4. First, find extension_dir = ". /"change it to extension_dir =" D:/PHP/EXT ". You must change it to your own configuration environment. Otherwise, it will not succeed.












(2) load the required modules. Load the required modules according to the actual situation. In this configuration environment, we need to load the MySQL module, GD module, and mcrypt module. As shown in figure 5, it is the situation after our modification. We only need to remove the semicolon before "; Extension = php_openssl.dll. Of course, you need to remove the quotation marks for any modules.












Note:



(1) ". PHP can be connected to any database and can work seamlessly. For example, MySQL is the most typical database, followed by databases such as MSSQL and Oracle. if you do not select MySql for the operating environment, you must modify the corresponding module, for example, php_mssql.dll for MSSQL and php_oci8.dll for Oracle.



(2) The function of loading the GD module is to support graphics. You can understand the watermarking function of discuz.



(3) MySQL is a module that supports MySQL Database loading.



(4) The mcrypt module is required by phpMyAdmin. If you find it troublesome to manually manage MySQL and download software, you can download phpMyAdmin, a powerful MySQL management tool.



(4) Basic MySQL preparation



1. Install MySQL



(1) run the MySQL Installer



We use the latest version of 6.0.8. We will not be able to explain the basic installation location. Most people can do it independently, here we will focus on how to configure the MySQL server. Let's start from 6. Figure 6 shows the welcome page. If you have nothing to say, click Next.












(2) Select the installation type



As shown in figure 7, this is a key step. Let's select the installation type. "detailedconfiguration" is a manual and precise configuration. We can customize the server by ourselves, configure the server as needed. It is suitable for anyone who understands the basic principles of MySQL. The second is the standard configuration of "standardconfiguration". This option is used to complete installation using the default recommended options of MySQL. We chose "standardconfiguration" because we only need to use the standard MySQL function.












(3) configure an instance



As shown in figure 8, there are also two options in the instance Configuration Wizard, which makes it easier to understand "Install aswindowsservice". Selecting it is the system service installed into windows, to put it bluntly, it can be automatically started at startup. The second "includebindirectory inwindowspath”" command installs the BINLOG of mysqlinto the environment directory, so that any opened cmd.exe can execute MySQL programs. In this example, select MySql as the service name based on your interests.












(4) set the MySQL password



As shown in "Next" 9, here are some basic security settings, such as the root password. The principle here is to be as complex as possible, do not use the root user to install some PHP programs, such as discuz. Our principle is to create another dedicated low-privilege user. We will introduce it later. As shown in Figure 9, there is a place to pay attention to for the license. Do not select a place to draw a red line, here, "enablerootaccess fromremotemachines" means that the root user can connect remotely. If the password you set is simple and the remote access function is enabled, the system permissions are used by hackers. So pay attention to it.












(5) install MySQL



As shown in figure 10, we have started to install mysql. If all the options are checked, it indicates that MySQL is successfully installed, and some prompts will be given after the installation is successful. If the installation fails, please repeat the above steps to reinstall it!








 MySQL installation successfulNow, the basic configuration of MySQL is complete. At the above step, we have completed the basic preparations for IIS, PHP, and MySQL. Now we will start to use IIS to load PHP.





(5) Configure IIS to support PHP



1. Create a website



Because the website under Windows is configured, a new website needs to be created. Click Start> All Programs> Administrative Tools> Internet Information Service (IIS) manager. If everything works properly, the screen shown in Figure 11 is displayed.












Right-click a website, select "new" from the pop-up menu, as shown in figure 12, select a website from the sub-menu, and then the website creation Wizard will pop up, click "Next" to continue the configuration.












2. Set the website name



As shown in Figure 13, here we enter the name, which can be written as the name of your website, mainly used for identification and differentiation.












3. Set Host Header



As shown in figure 14, it is the host header of the website. In fact, this option can be used to configure virtual hosts, to put it bluntly, multiple websites are installed on one server. You can enter your own website. We will not enter the website here. The IP address of the website can be viewed here. We enter all unallocated IP addresses here, and all IP addresses on all NICs of the local machine can be accessed. The following is the WWW port. We will not modify the port 80 by default.












4. Set the Home Directory of the website



As shown in Figure 15, select the Home Directory of the website, corresponding to your own website directory. We can see that part of the draw line is to allow anonymous access, we must choose, if your website is based on Windows integrated authentication, you can choose not, most of the websites must choose.












5. Set website Access Permissions



After the preceding steps are selected, click "Next" to go to the website access permission settings page shown in 16. Note that you must select the first two items, that is, "Read missing and" run script ". Click "Next" to complete website configuration.












The preceding settings can be modified in the IIS manager after the new website wizard is set.



6. Configure IIS to support PHP



After configuring the website, we began to configure IIS support for PHP. We 'd better stop the website first.



(1) configure the test website



17. Right-click the newly created "test" website and select Properties. Click the "home directory" tab.












(2) Configure PHP Extension



Click the "configuration" button. In the "Application configuration" dialog box that appears, click the "add" button to add the php isapi support and select the executable file as "D: \ PHP \ php5isapi. DLL "(php5isapi under the PHP Directory. DLL), the extension is ". PHP "(here, pay attention to the. Above PHP .), "The restriction action is" get, post ", as shown in 18. Click" OK "to add and view". PHP "extension is loaded successfully. If yes, click OK to close the Configuration window and return to the main site Properties window.












(2) set the default document



19, and then click the "document" tab. In the "Default content Document", add the corresponding page name based on the home page name of the website program, which is usually "indexing index.php" and "default.php]. If there is a static state, you can include" indexing index.html ", after adding all of them to the list, click "OK" to close the site attribute Configuration window and return to the main interface of IIS manager.












(3) add PHP Extension



20. We chose to add PHP extensions. Note that the area marked in Figure 20 is configured with the extension status to allow. Otherwise, PHP is not supported.












(6) Test the PHP Environment



In this step, we have basically completed the website configuration. First, we started our test site, because we closed the configuration at the beginning. Go to our web directory and create a new index. php file. The content is. Then we open the site, as shown in Figure 21, indicating that we have successfully completed the configuration of IIS + MySQL + PHP.












Note:



You can use the phpinfo () function to display our configuration. You can use this function to display whether the configuration is correct or not. The installation has been completed here.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.