Home > php教程 > PHP开发 > Entering Zend Framework Programming 2 (Software Installation and Environment Configuration)

Entering Zend Framework Programming 2 (Software Installation and Environment Configuration)

黄舟
Release: 2016-12-17 10:21:07
Original
1077 people have browsed it

Software installation and environment configuration

1. After Windows Server2003
Windows Server2003 is installed, it is best to go online and install all system patches through Windows Update, including its latest SP patch package. Although this may not have a fatal impact on learning, But it is still recommended. Since Windows 2003 does not install IIS by default, you must install the IIS6.0 component through "Add and Remove Programs" after the installation is complete.
Note that you must also turn on the "Enable Parent Path" of "Home Directory" - "Configuration" - "Options" of IIS6.0. Also set "All unknown ISAPI extensions" in "Web Service Extensions" to "Allow" - because our test environment will allow PHP to integrate with IIS in "ISAPI mode". The "include file on the server side" service extension does not seem to affect PHP's require and other script commands.
Note again that since our ZF learning and code debugging are mainly carried out in the Apache environment, the above IIS configuration has little to do with our ZF learning. It is only used when we need to demonstrate ZF under IIS as additional knowledge. These configurations are required.

2. Installation of MySQL for Windows
Select the database and install it on the same machine as Windows 2003. mysql-5.0.41-win32 is a Setup.exe file. Double-click it, make some selections along the way, and then click "Next" to complete the installation. Finally, choose to enter the configuration process immediately. For our study, how mySQL is configured has little impact. It is recommended that the database be selected in "myISAM" format. Pay attention to remember the password of user root.
Note that before configuring nySQL, be sure to turn off the firewall and some anti-virus software on the server, such as 360 Security Guard, otherwise it may cause the database creation to fail. If there is a problem, you can uninstall mySQL and try again.

3, Apache for Windows
I choose the Apache for Windows version of apache_2.2.8-win32-x86-openssl-0.9.8g.msi. The installation path is: C:PRogram FilesApache Software FoundationApache2.2.

3.1 Since the IIS service itself occupies port 80, I choose Apache to use port 8080. In this way, one machine can run two kinds of Web services, which is convenient for our testing. In a real production environment, IIS is disabled or not installed and Apache is allowed to serve under port 80. The method to modify the Apache port is to use a text editor to open the C:Program FilesApache Software FoundationApache2.2confhttpd.conf file and change Listen 80 to Listen 8080.
Note that httpd.conf is the configuration file of Apache and will be modified frequently in the future. After modifying this file, you must restart the Apache service for the configuration to take effect. This must be paid special attention to. (If you are willing, you can restart the machine, and the Apache service will also be re-initialized - but I believe PHP programmers are not so stupid)

3.2 Modify the default homepage file of the website
Add index after DirectoryIndex in the code below in httpd.conf. php, multiple homepage files are separated by commas:


DirectoryIndex index.html, index.php

3.3 There are many folders under the Apache2.2 folder, including 2 important folders:
Conf contains With the configuration file httpd.conf;
Htdocs is the default place to store web page files. The default folder for storing web page files can be modified through the DocumentRoot statement of httpd.conf, but our test uses the default one.

3.4 Apache virtual host configuration
In order to test numerous applications, we need to establish a virtual host so that the applications can run in independent websites.
Block the default website, that is, add a comment symbol # before the following configuration statement (you can also delete the statement):
#DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
Then in this Type the following sentences under the statement: namevirtualhost *: 8080


Serveradmin webmaster@mydomain.com

documentroot "C: Program Filesapache Software Foundache2.2htdocs" MSservername LocalHost

errorLog "LOGS/LOCALHOST-ERROR.LOG ”

CustomLog “logs/localhost-access.log” common

Copy the code to access the local website at http://localhost:8080/ on this server. For example, the content of an index.php file is as follows, You can display the basic configuration information of the server:

phpinfo();
?>
Configure the virtual host (distinguished by the domain name phpchina1.com):

ServerAdmin any@any.com

DocumentRoot “C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/phpchina1.com”

ServerName phpchina1.com

ErrorLog “logs/phpchina1.com-error.log”

CustomLog “logs/phpchina1.com-access.log” common

Copy the code and save it, then restart the service. On a machine on the LAN or on the server, add a statement in the hosts file

phpchina1.com
You can use http://phpchina1.com:8080/*.* to access the website.
But note:
Until Apache and PHP are properly integrated, PHP documents cannot be accessed.
Before further configuring ZF correctly, ZF testing cannot be done. In fact, there are several important configuration steps that need to be done before running ZF code.

4. PHP installation and configuration
We choose PHP 5.2.5 version. After getting the php-5.2.5-Win32.zip file, unzip it to the following folder:
C:usrlocalphp-5.2.5.for_Apache2.2php-5.2.5.bin
Your path can be different from here, I The reason for establishing such a deep path is that there are many PHP versions installed on my machine, so it is organized in this way.
Configuration required for PHP:
PHP configuration is completed by editing php.ini. For the first time, we copy the php.ini-recommended file under
C:usrlocalphp-5.2.5.for_Apache2.2php-5.2.5.bin
to generate a php.ini file, and then specify the extension_dir path:
extension_dir = “C :usrlocalphp-5.2.5.for_Apache2.2php-5.2.5.binext”
Open the comments of the following statements to allow ZF to support mySQL database:
extension=php_pdo.dll to open pdo
extension=php_pdo_mysql.dll to open pdo_mysql
In order for PHP to support more extensions, you can remove their comments. For example, to support graphics functions, you can open
extension=php_gd2.dll
By the way, please note that for security reasons, register_globals = Off, which is already closed by default. The PHP extension we developed ourselves can also be copied to the ext folder and called in the form extension=myphp_ext.dll.

5, Zend Framework:
Get the ZendFramework-1.5.1.zip compressed package, unzip and take out the contents of the library folder, and copy the library folder to the following folder:
C:Program FilesApache Software FoundationApache2.2htdocs
The final folder path is in the form:
C:Program FilesApache Software FoundationApache2.2htdocslibraryZend*.*

6, Integration of PHP with Apache and mySQL
Add the statement at the end of the http.conf file: #Integrate mySQL

LoadFile “C: usrlocalphp-5.2.5.for_Apache2.2php-5.2.5.binlibmysql.dll”

#Integrate PHP5

LoadModule php5_module “C:usrlocalphp-5.2.5.for_Apache2.2php-5.2.5.binphp5apache2_2.dll”

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

#(Specify the location of the php.ini file)

PHPIniDir “C:usrlocalphp-5.2.5.for_Apache2. 2php-5.2.5.bin”
If the copy code is PHP6, it will be in the form:
LoadModule php6_module “…php6apache2_2.dll”
Note that the above load module statement LoadModule must load the dll file corresponding to the current PHP and Apache versions. If configured incorrectly, it will not work.
Note again: After saving the http.conf file, you must restart the Apache service for the configuration to take effect.

At this point, we should be able to run ordinary non-Zend Framework PHP code on our virtual host. Unfortunately, we still can't start our Zend Framework journey. Because of ZF's special design, we also need to do some additional configuration on Apache. This is why I did not recommend running ZF applications on IIS earlier, because Apache can run ZF applications after a few settings, while IIS requires third-party software. Furthermore, in everyone's mind, IIS, PHP, and ZF are not golden partners. In the minds of programmers, the technologies must be matched.

It is expected that we will not really see the first example of ZF until the end of the next part.

The above is the introduction to Zend Framework Programming 2 (software installation and environment configuration). For more related articles, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template