Zend Framework framework programming (2): software installation and environment Configuration

Source: Internet
Author: User
Tags zend framework
1. Windows server2003
After windows server2003 is installed, it is best to install all the system patches through Windows Update, including its latest SP patch package. Although this does not have a fatal impact on learning, however, we recommend that you do this. Because IIS is not installed in Windows 2003 by default, you must add and delete IIS after installation. Program To install the iis6.0 component.
Note that you must also enable the "enable parent path" option of "main directory"-"configuration"-"option" of iis6.0. Set "all unknown ISAPI extensions" in "Web service extensions" to "allow"-because our test environment will allow PHP and IIS to be integrated as "ISAPI. The "include files on the server" service extension does not seem to affect script commands such as PHP require.
Note that due to our ZF learning and Code Debugging is mainly performed in the Apache environment. Therefore, the above IIS configuration has little to do with our ZF learning, but when we use it as additional knowledge, these configurations are required only when ZF is demonstrated in IIS.

2. Install MySQL for Windows
The database is installed on the same machine as Windows2003. Mysql-5.0.41-win32is A setup.exe file. Double-click it to make some choices, and then press "Next" to complete the installation. Finally, enter the configuration process immediately. For our learning, how to configure MySQL has little impact. We recommend that you select the "MyISAM" format for the database. Remember the user root password.
Before configuring nysql, you must disable the firewall and anti-virus software on the server, such as 360 security guard. Otherwise, database creation may fail. If you have any questions, uninstall MySQL and try again.

3. Apache for Windows
I chose the Apache for Windows version of The apache_2.2.8-win32-x86-openssl-0.9.8g.msi. Installation path: C:/program files/Apache Software Foundation/apache2.2.

3.1 because the IIS service itself occupies port 80, I chose Apache to use port 8080. In this way, a machine can run two types of web services for our testing. In a real production environment, Apache is enabled on port 80 by disabling or not installing IIS. To modify the Apache port, open the C:/program files/Apache Software Foundation/apache2.2/CONF/httpd. conf file in the text editor 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 the file is modified, you must restart the apache service to make the configuration take effect. Pay special attention to this. (If anyone wants to restart the machine, the apache service will reinitialize it again-but I believe PHP programmers are not so stupid)

3.2 modify the default homepage file of a website
Add index. php to the directoryindex of the following httpd. conf code. Separate multiple homepage files with commas:
<Ifmodule dir_module>
Directoryindex index.html, index. php
</Ifmodule>

3.3 The apache2.2 folder contains many folders, including two important folders:
Conf contains the configuration file httpd. conf;
Htdocs is the default place for storing webpage files. The default folder for storing webpage files can be modified using the DocumentRoot Statement of httpd. conf, but the default one is used in our test.

3.4 Apache Virtual Host Configuration
To test a large number of applications, we need to create virtual hosts so that applications can run separately on independent websites.
Remove the default website, that is, add a comment symbol before the following configuration statement # (you can also delete this statement ):
# DocumentRoot "C:/program files/Apache Software Foundation/apache2.2/htdocs"
Then, enter the following statement in the statement:
Namevirtualhost*: 8080
<Virtualhost *: 8080>
Serveradmin webmaster@mydomain.com
DocumentRoot "C:/program files/Apache Software Foundation/apache2.2/htdocs"
Servername localhost
Errorlog "log/localhost-error.log"
Customlog "logs/localhost-access.log" common
</Virtualhost>
You can access the local website with http: // localhost: 8080/on the server. For example, if the content of an index. php file is as follows, the basic configuration information of the server can be displayed:
<? PHP
Phpinfo ();
?>
Configure the VM (by domain name phpchina1.com ):
<Virtualhost *: 8080>
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
</Virtualhost>
Save and restart the service. Add a statement to the hosts file on a machine or server on the LAN.
<Server IP> phpchina1.com
You can access the website in the form of http://phpchina1.com: 8080.
Note:
PHP documents cannot be accessed until Apache and PHP are correctly integrated.
You cannot perform ZF tests before configuring ZF correctly. In fact, there are several important configuration steps before running the ZF code.

4. install and configure php
we chose PHP 5.2.5. To php-5.2.5-win32.zip file, unzip to the following folder:
C:/usr/local/php-5.2.5.for_Apache2.2/php-5.2.5.bin
your path can be different from here, I set up such a deep path because many PHP versions are installed on my machine.
Configuration required by PHP:
PHP configuration is completed by editing PHP. ini. For the first time, we copied PHP under
C:/usr/local/php-5.2.5.for_Apache2.2/php-5.2.5.bin
. ini-recommended file to generate a PHP. INI file, then specify the extension_dir path:
extension_dir = "C:/usr/local/php-5.2.5.for_Apache2.2/php-5.2.5.bin/EXT"
and open the comment for the following statement, to enable ZF to support MySQL Databases:
extension = php_pdo.dll open PDO
extension = php_pdo_mysql.dll open pdo_mysql
to support more extensions of PHP, you can remove their annotations, for example, to support graphics, you can enable
extension = php_gd2.dll
. By the way, to ensure security, register _ Globals = off, which is disabled by default. The PHP extension we developed can also be copied to the ext folder and called in the form of extension = myphp_ext.dll.

5. Zend framework:
Obtain the zendframework-1.5.1.zip package, extract the content of the library folder, and copy the library folder to the following folder:
C:/program files/Apache Software Foundation/apache2.2/htdocs
The final folder path format is:
C:/program files/Apache Software Foundation/apache2.2/htdocs/library/Zend /*.*

6. Integration of PHP with Apache and MySQL
Add the following statement to the end of the HTTP. conf file:
# Integration with MySQL
LoadFile "C:/usr/local/php-5.2.5.for_Apache2.2/php-5.2.5.bin/libmysql. dll"
# Integrate PhP5
Loadmodule php5_module "C:/usr/local/php-5.2.5.for_Apache2.2/php-5.2.5.bin/php5apache2_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:/usr/local/php-5.2.5.for_Apache2.2/php-5.2.5.bin"
If it is PhP6, it is like:
Loadmodule php6_module "...... /Php6apache2_2.dll"
Note that the above loadmodule statement must load the DLL file corresponding to the current PHP and Apache versions. Configuration error cannot work.
Note: after saving the HTTP. conf file, you must restart the apache service to make the configuration take effect.

So far, we should be able to run common non-Zend framework PHP code on our virtual host. Unfortunately, we still cannot start our Zend framework journey. Due to the special design of ZF, we also need to make some additional configuration for Apache. This is also the reason why I do not recommend running ZF applications on IIS, because Apache can run ZF applications after several settings, and IIS can only use third-party software. Furthermore, in everyone's mind, IIS and PHP and ZF are not golden partners. In the programmer's mind, technology must also be right.

We can see the first ZF example at the end of the next part.

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.