search

 

一、部署LAMP环境,安装顺序

二、编译、安装php

三、安装xcache,为php(opcode)加速

四、其他

 

一、部署LAMP环境,安装顺序

 

编译安装部署LAMP环境,安装顺序

1、编译安装apache,http://64314491.blog.51cto.com/2784219/1652948

2、编译安装mysql,http://64314491.blog.51cto.com/2784219/1652999

3、编译安装php

 

二、编译、安装php

 

1、下载php并解压

[root@localhost downloads]# wget http://cn2.php.net/distributions/php-5.4.41.tar.bz2[root@localhost downloads]# tar xf php-5.4.41.tar.bz2

 

2、编译前准备工作

(1)、编译选项

./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml  --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt  --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2  --enable-maintainer-zts

 

(2)、直接编译,会有如下提醒,所以需提前准备

1、configure: error: xml2-config not found. Please check your libxml2 installation.2、configure: error: Please reinstall the BZip2 distribution3、configure: error: mcrypt.h not found. Please reinstall libmcrypt.4、configure: error: Cannot find MySQL header files under /usr/local/mysql.    #这个问题就需要先安装mysql后,再来编译php了,所以最好按照步骤apache-->mysql-->php

所以编译前需要安装依赖环境

1、# yum -y  install libxml2 libxml2-devel2、# yum -y  install bzip2-devel下载libmcrypt libmcrypt-devel,并安装# wget http://mirrors.sohu.com/fedora-epel/6Server/x86_64/libmcrypt-2.5.8-9.el6.x86_64.rpm# wget http://mirrors.sohu.com/fedora-epel/6Server/x86_64/libmcrypt-devel-2.5.8-9.el6.x86_64.rpm3、# rpm -ivh libmcrypt-2.5.8-9.el6.x86_64.rpm    # rpm -ivh libmcrypt-devel-2.5.8-9.el6.x86_64.rpm

 

3、编译、安装php

# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml  --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt  --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2  --enable-maintainer-zts# make && make install

注:--enable-maintainer-zts    编译模块worker、event时,需要使用该选项

 

4、编辑/etc/httpd/httpd.conf

(1)、在AddType application/x-gzip .gz .tgz后棉添加以下信息,使httpd识别php格式的页面

ADDType application/x-httpd-php .phpADDType application/x-httpd-php-source .phps

 

(2)、添加默认起始页文件名

DirectoryIndex index.php

<IfModule dir_module>    DirectoryIndex index.php index.html</IfModule>

完成配置后,重载配置

[root@localhost ~]# service httpd graceful

 

(3)、为php提供配置文件,在我们解压出的源码目录中,有两个配置文件样例

[root@localhost ~]# cd /root/downloads/php-5.4.41[root@localhost php-5.4.41]# ls |grep php.iniphp.ini-development    #适用于开发环境php.ini-production    #适用于生产环境

编译安装时,我们指定了php的配置文件目录/etc,这里我们把适用于生产环境的配置文件复制过去

[root@localhost php-5.4.41]# cp php.ini-production /etc/php.ini

 

(4)、测试

之前编译安装的apache,配置文件中,默认网站根目录是DocumentRoot "/usr/local/apache/htdocs"  
在该路径新建一个测试页面index.php,内容如下

<h1 id="host">host1</h1><?php        phpinfo();?>

在浏览器输入主机地址测试,出现下图所示,说明安装、配置成功

 

 

三、安装xcache,为php(opcode)加速

1、下载xcache

wget http://xcache.lighttpd.net/pub/Releases/3.1.2/xcache-3.1.2.tar.gz

 

2、为php添加xcache

[root@localhost downloads]# tar xf xcache-3.1.2.tar.gz [root@localhost downloads]# cd xcache-3.1.2[root@localhost xcache-3.1.2]# /usr/local/php/bin/phpizeConfiguring for:PHP Api Version:         20100412Zend Module Api No:      20100525Zend Extension Api No:   220100525

 

3、编译安装xcache

[root@localhost xcache-3.1.2]# ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config[root@localhost xcache-3.1.2]# make && make install

安装完成,提示模块安装的位置

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20100525/

 

4、将xcache配置文件复制到php配置文件目录

[root@localhost xcache-3.1.2]# mkdir /etc/php.d[root@localhost xcache-3.1.2]# cp xcache.ini /etc/php.d[root@localhost xcache-3.1.2]# vim /etc/php.d/xcache.ini[root@localhost xcache-3.1.2]# service httpd graceful    #重载配置

新建测试页面,在浏览器中访问测试页面,显示如下画面,说明模块正常加载

vim /usr/local/apache/htdocs/test.php编辑如下内容<?php        phpinfo();?>

 

    #配置文件已经载入

 

如果xcache没有正常工作,试试编辑xcache.ini,编辑extension = xcache.so,修改为全路径

extension = /usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so

 

 

四、其他

 

配置文件/etc/php.ini,/etc/php.d/目录下的*.ini

php.ini官方文档:

配置参数:http://www.php.net/manual/zh/ini.list.php  
核心配置参数详解:http://www.php.net/manual/zh/ini.core.php

Statement
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
Working with Flash Session Data in LaravelWorking with Flash Session Data in LaravelMar 12, 2025 pm 05:08 PM

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

Build a React App With a Laravel Back End: Part 2, ReactBuild a React App With a Laravel Back End: Part 2, ReactMar 04, 2025 am 09:33 AM

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Simplified HTTP Response Mocking in Laravel TestsSimplified HTTP Response Mocking in Laravel TestsMar 12, 2025 pm 05:09 PM

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

cURL in PHP: How to Use the PHP cURL Extension in REST APIscURL in PHP: How to Use the PHP cURL Extension in REST APIsMar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

12 Best PHP Chat Scripts on CodeCanyon12 Best PHP Chat Scripts on CodeCanyonMar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Notifications in LaravelNotifications in LaravelMar 04, 2025 am 09:22 AM

In this article, we're going to explore the notification system in the Laravel web framework. The notification system in Laravel allows you to send notifications to users over different channels. Today, we'll discuss how you can send notifications ov

Explain the concept of late static binding in PHP.Explain the concept of late static binding in PHP.Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

PHP Logging: Best Practices for PHP Log AnalysisPHP Logging: Best Practices for PHP Log AnalysisMar 10, 2025 pm 02:32 PM

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

See all articles

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version