Felayman ----- PHP environment setup

Source: Internet
Author: User
Tags php development environment
PHP is a server-side embedded scripting language. it is a server-side, cross-platform, object-oriented, and HTML embedded scripting language. This chapter will introduce you to PHP development environment setup and common configuration problems and solutions. Through this chapter, you can learn the following content. Change

PHP is a server-side embedded scripting language. it is a server-side, cross-platform, object-oriented, and HTML embedded scripting language. This chapter will introduce you to PHP development environment setup and common configuration problems and solutions. Through this chapter, you can learn the following content.

Change verification code

: Windows -- AppserV integrated installation package to build a PHP environment

: Linux -- XAMPP integrated installation package to build a PHP environment

: Key configuration information of the PHP development environment

: Solve common PHP configuration problems

1.1 PHP environment construction 1.1.1 AppServ-Windows PHP integrated installation package

AppServ packages Apache, PHP, MySQL, phpMyAdmin, and other server software and tools after installation and configuration. Developers can quickly build a PHP development environment by downloading the software on the website and installing it. It is very suitable for beginners.

Note: When using AppServ to build a PHP development environment, make sure that Apache, PHP, and MySQL are not installed in the system. Otherwise, uninstall the software and then apply the AppServ.

The following describes how to build a PHP development environment using the AppServ integrated installation package:

(1)double-click the appserv-win32-2.5.10.exe file to open the AppServ startup page shown in 1.1.


(2) click the Next button in. 1 to open the AppServ installation protocol page shown in 1.2.

(3) click the I Agree button in. 2 to open the page shown in 1.3. Set the installation path of AppServ (the default installation path is E: \ AppServ). after AppServ is installed, Apache, MySQL, and PHP are stored in subdirectories.


(4) click the Next button in. 3 to open the page shown in 1.4. Select the programs and components to install (all are selected by default ).



Note: in step 4, if the MySQL Database has been installed on the local machine, you can still use the existing MySQL Database on the local machine without selecting the MySQL Database option.

(5) click the Next button in. 4 to open the page shown in 1.5. Enter the computer name, add the email address, and set the Apache port number. the default value is port 80.


Tip: Setting the port number of the Apache server is directly related to whether the Apache server can be started normally. If Port 80 in the local machine is occupied by IIS or thunder, you need to modify the Apache port number or the IIS or Thunder port number to complete the configuration of the Apache server. If a port conflict occurs, the installation will fail and the Apache service cannot be started.

(6) click the Next button in. 5 to open the page shown in 1.6. Set the logon password and character set for the root user of the MySQL database.

Tips: MySQL database character set settings, you can choose UTF-8, GBK or GB2312. Here, the character set is set to UTF-8 Unicode, indicating that the character set of the MySQL database will be UTF8 encoded.


Note: the password of the root user of the MySQL database set in. 6 must be kept in mind because the program must use this password when connecting to the database.

To change the password of the database. If you forget to set the password during installation, the most effective solution is to reinstall AppServ.

(7) click the Install button in. 6 to start installation, as shown in Figure 1.7.


(8) after the installation is complete, you can start Apache and MySQL services in the AppServ related operation list in the Start menu, as shown in figure 1.8.


1.2 Key configuration information of the PHP development environment

The preceding section describes the configuration of the PHP development environment. in addition to the installation steps, the configuration of PHP and server is also very important. The following describes the configuration of PHP and Apache servers.

1.2.1 basic configuration of Apache server

The configuration file of the Apache server is located in the/usr/local/apache/conf/directory in the Linux operating system ("/etc/httpd/conf" in the Windows operating system, basically, the following three configuration files are used to configure the behavior of the Apache server.

T access. conf: used to configure server access permissions and control access restrictions for different users and computers.

T httpd. conf: used to set the basic environment for server startup.

T srm. conf: mainly used for setting file resources.

Tip: http. conf is the configuration file of the Apache server. Common configurations include: the port number of the Apache server, the access path of the server, and pseudo-static settings.

ServerName localhost: 80

DocumentRoot "/xampp/htdocs"

LoadModule rewrite_module modules/mod_rewrite.so

1.2.2 basic configuration of the PHP. ini file

The php. ini file is the configuration file automatically read by PHP at startup. Php. ini is an ASCLL text file. it consists of multiple parts, each of which includes relevant parameters. The name of each part is placed in square brackets at the beginning, followed by the name-to-number, each name Exclusive line. The PHP code in the rule is very sensitive to parameter names and cannot contain spaces. However, a parameter can be a number, string, or Boolean logical number. The semicolon is located at the beginning of each row and serves as the specified tag. This makes it easy to choose to use or not use these features of PHP, instead of deleting the row. If you annotate a feature (that is, add a semicolon), this row will not be compiled and executed. After modifying the php. ini file, you must restart the Apache server to make the new settings take effect.

Tip: php. ini is the configuration file of PHP. it is used to load various function libraries, set the error level, and set the server time. In Linux, php. ini is stored in/opt/lampp/etc/php. in the ini folder, and in the Windwos operating system, php. ini is stored in a windows file on the system disk. The basic configuration of the php. ini file is shown in Table 1.1.

Table 1.1 basic configuration of the php. ini file

Parameters

Description

Default value

Error_reporting

Sets the error handling level. Recommended value: E_ALL &~ E_NOTICE &~ E_STRICT: displays all error messages except the reminder and encoding standard warning.

E_ALL &~ E_NOTICE &~ E_STRICT

Register_globals

This variable can usually be set to Off to provide more security measures for script attacks through forms.

Register_globals = On

Include_path

Set the PHP search path. this parameter can receive directories of the series. When PHP encounters a file prompt with no path, it will automatically detect these directories. Note that when some options allow multiple values, the system list separator should be used, use the semicolon ";" in Windows and the colon ":" In Linux

; UNIX: "/path1:/path2"

; Include_path = ".:/php/shortdes"

; Windows: "\ path1; \ path2"

; Include_path = ".; c: \ php \ shortdes"

Extension_dir

Specifies the Directory of the PHP dynamic connection Extension Library

Under the "\ ext" directory

Extension

Specify the dynamic connection extension library loaded when PHP starts. For more information about common PHP extension libraries, see Table 1.2.

Common PHP extension libraries are commented out after the initial installation and configuration, which must be manually changed

File_uploads

Set whether to allow file upload over HTTP

File_uploads = On

Upload_tmp_dir

Sets the temporary directory when files are uploaded over HTTP. if it is null, the temporary directory of the system is used.

Upload_tmp_dir = null

Upload_max_filesize

Set the size of the file to be uploaded, such as "50 m". The unit is required.

Upload_max_filesize = 2 M

Post_max_size

Control the maximum capacity that PHP can receive in a form submission using the POST method. To upload a larger file, the value must be greater than the value of upload_max_filesize.

For example, if upload_max_filesize = 10 M, the value of upload_max_filesize must be greater than 10 M.

Post_max_size = 8 M

Max_input_time

The time for receiving data through POST, GET, and PUT is limited in seconds.

Max_input_time = 60

Table 1.2 common PHP extension libraries and descriptions

Expansion Library

Description

Php_ftp.dll

Supports FTP function libraries to implement standard Transfer Protocol (FTP) between the client and the server)

Php_gd2.dll

Supports image processing libraries and multiple image formats such as .gif?.jpg=.png.

Php_imap.dll

Supports the imap email processing function library

Php_mssql.dll

Support for MsSQL databases

Php_msql.dll

Support for mSQL databases

Php_MySQL.dll

Support for MySQL databases

Php_oracle.dll

Support for Oracle databases

Php_cmd.dll

Support PDF file processing function library

Php_sockets.dll

Support for Sockets processing function libraries

Php_zlib.dll

Supports zlib file compression function library

Php_pdo.dll

Support PDO database abstraction layer

Php_pdo_mysql.dll

Support for MySQL databases

Php_pdo_mssql.dll

Support for ms SQL Server databases

Php_pdo_oci8.dll

Support for Oracle databases

Php_pdo_odbc.dll

Support for ODBC databases

Php_pdo_pgsql.dll

Support for PostgreSQL databases

1.3 solve common PHP configuration problems

Program running errors are the biggest headache for many programmers. The following describes common PHP configuration problems. Through this section, you can identify which errors are caused by improper configuration of the PHP environment, so as to avoid unnecessary waste of time resources and efficiently complete Web application development.

1.3.1 resolve Apache server port conflict

The default port number of IIS is 80, which is the same as the default port number of Apache server. Because the same port number is used, a conflict occurs when the webpage is running.

If IIS is installed on your machine, you need to modify the default port of IIS. Otherwise, the Apache server will not work properly. Modify the default listening port 80 of IIS. you can set it in the IIS Manager or stop IIS services.

You can also change the default port number when installing the Apache server, so that the two servers share a port number and conflict occurs.

Tip: If you set Apache port to 82 when setting up a PHP environment, you should enter http: // 127.0.0.1: 82/or http: // localhost: 82 /.

1.3.2 set the current time of the PHP System

Because php 5.0 overwrites the date () function, the current date and time function is eight hours less than the system time. In PHP, the standard Greenwich Mean Time (zero time zone) is set by default. to obtain the current local time, you must change the time zone settings in PHP. The method is as follows:

In php. in the INI file, find "; date." under [date. timezone = "option, change this item to" date. timezone = Asia/Hong_Kong ", and then restart the Apache server.

After the settings are complete, the current time of the output system will not experience time difference.

1.3.3 added the PHP Extension Module

The added PHP extension module is also called dynamic extension. it is used to dynamically load a module. it contains a command: extension.

In a Windows operating system, the method for loading a module is as follows. Open the php. ini file, locate the following location, and remove the; tension = php_java.dll; save and restart the Apache server to load the extension module.

; Tension = php_java.dll

In Linux, the method for loading a module is as follows.

Extension = php_java.so

It should be noted that loading only this line of code does not necessarily enable the relevant extension package, and sometimes it is necessary to ensure that the relevant software is installed in the operating system. For example, to enable java support, you must install JDK.


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.