First, the deployment lamp environment, installation sequence
Second, compile, install PHP
Third, install XCache, for php (opcode) acceleration
Iv. Other
First, the deployment lamp environment, installation sequence
Compiling and installing the lamp environment, installation sequence
1. Compile and install apache,http://64314491.blog.51cto.com/2784219/1652948
2. Compile and install mysql,http://64314491.blog.51cto.com/2784219/1652999
3. Compile and install PHP
Second, compile, install PHP
1. Download PHP and Unzip
[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, pre-compilation preparation work
(1), compile options
./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), direct compilation, there will be the following reminders, so you need to prepare in advance
1, configure:error:xml2-config not found. Please check your libxml2 installation.2, configure:error:Please Reinstall the BZIP2 Distribution3, configure:error:mcry Pt.h not found. Please reinstall Libmcrypt.4, configure:error:Cannot find MySQL header files Under/usr/local/mysql. #这个问题就需要先安装mysql后, compile PHP again, so it's best to follow the steps apache-->mysql-->php
So you need to install a dependent environment before compiling
1, # yum-y install libxml2 libxml2-devel2, # yum-y install bzip2-devel download Libmcrypt libmcrypt-devel, and install # 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. Compiling and installing 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
Note: You need to use this option when compiling the module worker, event--enable-maintainer-zts
4. Edit/etc/httpd/httpd.conf
(1), AddType application/x-gzip. GZ tgz Post-cotton Add the following information to enable HTTPD to identify pages in PHP format
AddType application/x-httpd-php. Phpaddtype application/x-httpd-php-source. Phps
(2), add default start Page file name
DirectoryIndex index.php
DirectoryIndex index.php index.html
After the configuration is complete, the overloaded configuration
[root@localhost ~]# Service httpd Graceful
(3), to provide a configuration file for PHP, in our extracted source directory, there are two sample configuration files
[root@localhost ~]# cd/root/downloads/php-5.4.41[root@localhost php-5.4.41]# ls |grep php.iniphp.ini-development #适用于开发环境php. Ini-production #适用于生产环境
When compiling the installation, we specified the configuration file directory for PHP/etc, where we copied the configuration file for the production environment.
[Root@localhost php-5.4.41]# CP Php.ini-production/etc/php.ini
(4), test
Before compiling the installation of Apache, the configuration file, the default Web site root directory is DocumentRoot "/usr/local/apache/htdocs"
Create a new test page on the path index.php, as follows
Host1
Enter the host address test in the browser, as shown in the instructions for installation, configuration success
Third, install XCache, for php (opcode) acceleration
1. Download XCache
wget http://xcache.lighttpd.net/pub/Releases/3.1.2/xcache-3.1.2.tar.gz
2. Add XCache for PHP
[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. Compile and install 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
Installation complete, prompt for module installation location
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20100525/
4. Copy the XCache configuration file to the PHP configuration file directory
[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 #重载配置
New test page, access the test page in the browser, display the following screen, indicating that the module load normally
vim/usr/local/apache/htdocs/test.php Edit the following content
#配置文件已经载入
If XCache is not working properly, try editing xcache.ini, edit extension = xcache.so, modify to full path
Extension =/usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so
Iv. Other
Configuration file/etc/php.ini,/etc/php.d/Directory *.ini
PHP.ini Official documents:
Configuration parameters: http://www.php.net/manual/zh/ini.list.php
Core configuration parameters in detail: http://www.php.net/manual/zh/ini.core.php