Home Backend Development PHP Tutorial 搭建PHP(LAMP),安装zend优化解析速度,并在其平台上搭建phpmyadmin管理系统,以页面方式管理mysql

搭建PHP(LAMP),安装zend优化解析速度,并在其平台上搭建phpmyadmin管理系统,以页面方式管理mysql

Jun 20, 2016 pm 12:45 PM

具体操作:

1. 准备工作

为了避免发生程序冲突等现象,建议先将rpm方式安装的php及相关依赖包(如果有的话)卸载。

2. 安装扩展工具库

在实际企业应用中,一部分基于PHP开发的Web应用系统需要额外的扩展工具,如数据加密工具libmcrypt、mhash、mcrypt等(可以从站点sf.net下载)。安装php软件包之前,应先安装好这些扩展工具程序。

1) 安装libmcrypt

2) 安装mhash

3) 安装mcrypt:

3. 编译安装PHP

1) 解包

2) 配置

? --prefix:指定将PHP程序安装到哪个目录。

? --with-mcrypt加载数据加密等扩展工具支持。

? --with-apxs2设置“Apache HTTP Server”提供的apxs模块支持程序的文件设置。

? --with-mysql设置MySQL数据库服务程序的安装位置。

? --with-config-file-path设置PHP的配置文件php.ini将要存放的位置。

? --enable-mbstring启用多字节字符串功能,以便支持中文等代码。

如果配置出现错误,可能是缺少一个网页格式xml,安装即可,然后重新再配置一次。如图所示:

3) 编译及安装

n 设置LAMP组件环境

1. php.ini配置调整

安装好php软件包以后,服务器并不会自动创建php.ini配置文件,但在源码目录下提供了两份样例配置文件,分别对应于开发环境、生产环境。

选择其中一个样例文件,并复制到PHP的配置文件目录(应确保与configure步骤中指定的路径一致),并改名为php.ini。在php.ini配置文件中,以分号开头的内容表示注释信息。

通过修改php.ini文件中的配置内容,可以控制PHP网页的执行特性。如是否允许用户上传文件、设置上传文件的大小限制、设置默认使用的字符集、加载额外的扩展模块等。如果没有特别要求,可以直接沿用默认配置,不做任何修改。

为了进一步提高PHP程序的执行效率,优化页面加载速度,可以为PHP添加Zend公司开发的ZendGuardLoader优化模块。若需要加密PHP代码以限制未经授权的分支,还可以购买该公司的ZendGuard软件。

首先将下载的ZendGuardLoader包释放,并将其中php-5.3.x目录下的模块文件复制到PHP程序的模块文件夹。

然后修改php.ini配置文件,添加加载及启用ZendGuardLoader.so模块的配置语句。

2. httpd.conf配置调整

要让httpd服务器支持PHP页面解析功能,需通过LoadModule配置项加载PHP程序的模块文件,并通过AddType配置项添加对“.php”类型网页文件的支持。除此以外,还应修改DirectoryIndex配置行,添加“index.php”项,以识别常见的PHP首页文件。

在上述配置内容中,LoadModule行应该会在安装php的过程中自动添加,其中的“php5_module”表示模块名称;“module/libphp5.so”是模块文件位置。而AddType行需要手动添加,DirectoryIndex行在原有基础上对其进行修改即可。

n 测试LAMP协同工作

1. 测试PHP网页能否正确显示

编写一个“.php” 格式的测试网页文件,使用PHP内建的“phpinfo()”函数显示服务器的PHP环境信息,PHP代码应包括在“”标记之间。将测试文件放置到网站根目录下。

然后通过浏览器访问,如图所示,若能看到PHP程序的版本号、配置命令、运行变量等相关信息,表示此Web服务器已经能正常显示PHP网页。若还能看到Zend引擎相关信息,则表示ZendGuardLoader模块也已启用成功。

2. 测试PHP网页能否访问MySQL数据库

再编写一个测试网页文件,添加简单的数据库操作命令,用于验证与MySQL服务器的连接、查询等操作。其中,“mysql_connect()”函数用于连接MySQL数据库,需要指定目标主机地址,以及授权访问的用户名、密码。

然后通过浏览器访问测试网页,若能看到成功连接的提示信息,如图所示,则表示能够通过PHP网页访问MySQL数据库。当使用了错误的用户名、密码,或者因mysqld未运行而导致连接失败时,执行时将会报错。

n 部署phpMyAdmin系统

phpMyAdmin是一个使用php语言编写,用来管理MySQL数据库的Web应用系统。通过该套件提供的网页界面,即便是对SQL语句不太熟悉的人,也能够非常容易的对MySQL数据库进行管理和维护。

1. 解包并复制到网站目录

对于大部分PHP应用系统来说,只需要解包后复制到网站目录下即可完成部署,之后再根据需要调整配置,或者访问安装页面以完成进一步的安装。

2. 建立配置文件config.inc.php

将phpMyAdmin套件复制到网站目录以后,还需要创建配置文件方可正常使用。默认提供的样例配置文件为config.sample.inc,需要参照该文件内容建立config.inc.php配置文件。查找并修改配置文件中的“blowfish_secret”行,并设置一个短语密钥(此密钥用于网页cookie认证,不需要用户记忆)。

3. 访问phpMyAdmin的Web管理界面

在浏览器中访问http://192.168.10.10/phpMyAdmin/,如果能够看到phpMyAdmin系统的登录界面,如图所示,则表示部署成功。使用MySQL数据库的用户(不能是密码为空的用户)登录后,即可在授权范围内对数据库进行管理。

phpMyAdmin系统默认使用cookie认证方式,在首次访问时页面下方可能会提示“必须启用Cookies才能登录”,要求客户机的浏览器启用cookies机制。实际上大多数浏览器默认都是支持cookies的,因此按F5键刷新页面后该提示信息即会消失。

4. 使用phpMyAdmin系统

需要使用phpMyAdmin系统时,应先通过MySQL服务器中授权的数据库用户(如root)进行登录,认证成功后可以看到管理界面,如图所示。通过phpMyAdmin套件,用户可以在授权的范围内执行各种数据库管理操作,使界面更加直观、友好、大大降低了远程维护MySQL数据库服务器的难度。

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

How does session hijacking work and how can you mitigate it in PHP? How does session hijacking work and how can you mitigate it in PHP? Apr 06, 2025 am 12:02 AM

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to debug CLI mode in PHPStorm? How to debug CLI mode in PHPStorm? Apr 01, 2025 pm 02:57 PM

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

How to send a POST request containing JSON data using PHP's cURL library? How to send a POST request containing JSON data using PHP's cURL library? Apr 01, 2025 pm 03:12 PM

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

See all articles