Preface: the APR (Apache portable run-time Libraries,apache Portable runtime) is designed to provide an underlying support interface library that can be used across multiple operating system platforms, as its name would be, primarily for upper-level applications.
PHP accelerator XCache: Special PHP-based extension mechanisms such as opcode cache extensions can also cache opcode in PHP's shared memory, allowing the same piece of code to skip the compilation phase to improve performance when it is repeatedly executed. These accelerators do not really increase the speed of the opcode, but only after analyzing the opcode and rearranging them to achieve the purpose of fast execution.
Note: The version supported by Php-xcache
Preparatory work
software version: All packages are placed in:/app/directory
Apr-1.6.2.tar.gz
Apr-util-1.6.0.tar.gz
httpd-2.4.27.tar.bz2
Note: The version of httpd on CENTOS6 is version 2.2, and the APR to use the 2.4 version must be above the apr-1.4 version
Php-5.6.31.tar.xz
xcache-3.2.0.tar.bz2
Mariadb-5.5.57-linux-x86_64.tar.gz
Wordpress-4.8.1-zh_cn.tar.gz
First, compile httpd-2.4
1. Install the compiled environment
cd/app/
Yum Groupinstall "Development tools" # Development Kit Group
Yum Install openssl-devel pcre-devel expat-devel # at compile time, depending on or specify the relevant features of the package, it is best to install first, free of the compile half of the time when prompted to install.
2. Unzip the installation package
TAR-XVF apr-1.6.2.tar.gz
TAR-XVF apr-util-1.6.0.tar.gz
TAR-XVF httpd-2.4.27.tar.bz2
3. Copied to the httpd-2.4.27/srclib/directory, put together to compile, or can be compiled separately, this httpd-2.4.27/srclib/must be placed in this directory.
Cp-r apr-1.6.2 HTTPD-2.4.27/SRCLIB/APR
Cp-r apr-util-1.6.0 Httpd-2.4.27/srclib/apr-util
4. Compiling
CD httpd-2.4.27/
./configure--prefix=/app/httpd24--enable-so--enable-ssl--enable-rewrite--with-zlib--with-pcre-- WITH-INCLUDED-APR--enable-modules=most--enable-mpms-shared=all--with-mpm=prefork
5. Installation
Make && make install
6. Environment variables
VIM/ETC/PROFILE.D/LAMP.SH # Create a separate file here that's easier to manage.
path=/app/httpd24/bin/: $PATH
. /ETC/PROFILE.D/LAMP.SH # Effective
7. Service Scripts
CP/ETC/INIT.D/HTTPD/ETC/INIT.D/HTTPD24 # Here are the Yum-installed scripts, or other installed scripts, to edit and modify them.
VIM/ETC/INIT.D/HTTPD24 # Below is the place to modify, other places do not need to modify
Apachectl=/app/httpd24/bin/apachectl
HTTPD=${HTTPD-/APP/HTTPD24/BIN/HTTPD}
Prog=httpd
Pidfile=${pidfile-/app/httpd24/logs/httpd.pid}
LOCKFILE=${LOCKFILE-/VAR/LOCK/SUBSYS/HTTPD24}
Once the edits are complete, add the service to the boot entry
Chkconfig--add httpd24
Chkconfig--list httpd24
Service HTTPD24 Start
Two, binary installation mariadb
1. Unzip the installation package
cd/app/
TAR-XVF mariadb-5.5.57-linux-x86_64.tar.gz-c/usr/local/
cd/usr/local/
MV mariadb-5.5.57-linux-x86_64 MySQL # Here you have to use MySQL as the directory name, at the time of pre-compilation has already pointed to the word good, or do a soft link can also: ln-s mariadb-5.5.57-linux-x86_64/ Mysql
2. Create a user
Useradd-r-m-d/app/mysqldb-s/sbin/nologin MySQL # system users do not automatically create home directories so use-M
3. Build the Database
Cd/usr/local/mysql
scripts/mysql_install_db--datadir=/app/mysqldb--user=mysql # Specify the location and user of the database separately
4. Create a database configuration file
Mkdir/etc/mysql
CP SUPPORT-FILES/MY-LARGE.CNF/ETC/MYSQL/MY.CNF # MY-LARGE.CNF This is the system comes with the template
Vim/etc/mysql/my.cnf
[Mysqld]
DataDir =/app/mysqldb # database Location
5. Create a service script
CP/USR/LOCAL/MYSQL/SUPPORT-FILES/MYSQL.SERVER/ETC/INIT.D/MYSQLD # Mysql.server put it in the system startup directory and rename it.
Chkconfig--add mysqld
6. Add a log file
Touch/var/log/mysqld.log
Chown Mysql/var/log/mysqld.log
Service mysqld Start
Check whether the service is started, view port information: Ss-ntl 3306 ports Open
7. Add Environment variables
vim/etc/profile.d/lamp.sh
path=/app/httpd24/bin/:/usr/local/mysql/bin/: $PATH
. /etc/profile.d/lamp.sh
8. Initialization of the database password environment
Mysql_secure_installation # scripts, changing the root password, whether the test database is enabled, whether remote connection is turned on, etc.
9. Add WordPress users and related databases
Mysql-uroot-pcentos # The root password is specified in the initial
Create Datebase wpdb;
Grant all on wpdb.* to [e-mail protected] ' 192.168.25.% ' identified by ' CentOS ';
Third, the source code compiled PHP
1. Unzip and compile
cd/app/
TAR-XVF PHP-5.6.31.TAR.XZ
Yum Install libxml2-devel bzip2-devel libmcrypt-devel # at compile time, rely on or specify the relevant characteristics of the package, Libmcrypt-devel this package is on the Epel source, first configure the Epel source.
CD php-5.6.31
./configure--prefix=/app/php--with-mysql=/usr/local/mysql--with-openssl--with-mysqli=/usr/local/mysql/bin/mysql_config--enable-mbstring--with-png-dir--with-jpeg-dir--with-freetype-dir--with-zlib--with-libxml-dir=/usr--enable-xml--enable-sockets--with-apxs2=/app/httpd24/bin/apxs--with-mcrypt--with-config-file-path=/etc--WITH-CONFIG-FILE-SCAN-DIR=/ETC/PHP.D--with-bz2
2. Installation
Make && make install
3. Add Environment variables
vim/etc/profile.d/lamp.sh
path=/app/php/bin:/app/httpd24/bin/:/usr/local/mysql/bin/: $PATH
. /etc/profile.d/lamp.sh
4. Add a configuration file
Cp/app/php-5.6.31/php.ini-production/etc/php.ini # template files generated after compilation and installation completed
5. Add config file to httpd, support PHP
Vim/etc/httpd24/httpd.conf
# Add two lines to the tail of the file
AddType application/x-httpd-php. php
AddType Application/x-httpd-php-source. Phps
# Modify the line below
<ifmodule dir_module>
DirectoryIndex index.php index.html # Add PHP's main page
</IfModule>
Last Restart Service
Service HTTPD24 Restart
Iv. connection to the test database
vim/app/httpd24/htdocs/index.php
<?php
$mysqli =new mysqli ("localhost", "root", "CentOS");
if (Mysqli_connect_errno ()) {
echo "Connection database failed!";
$mysqli =null;
Exit
}
echo "Connect database successfully!";
$mysqli->close ();
?>
Finally open from the Web page, enter the IP address of the HTTPD server, will be prompted whether successful.
Five, configure WordPress
1. Unpacking the Package
cd/app/
TAR-XVF wordpress-4.8.1-zh_cn.tar.gz-c/app/httpd24/htdocs
Cd/app/httpd24/htdocs
MV WordPress Blog
2. Add a profile and edit the configuration file
cd/app/httpd24/htdocs/blog/
CP wp-config-sample.php wp-config.php # The module configuration file that comes with the installation package must be changed to this name
Vim wp-config.php
Define (' db_name ', ' wpdb ');
/** MySQL Database user name */
Define (' Db_user ', ' wpuser ');
/** MySQL Database password */
Define (' Db_password ', ' CentOS ');
/** MySQL Host */
Define (' db_host ', ' localhost ');
Vi. compiling XCache for PHP acceleration
1. Unpacking the Package
cd/app/
TAR-XVF xcache-3.2.0.tar.bz2
CD xcache-3.2.0
2. Compiling, installing
The extracted directory does not configure this script at the moment, so build this script file yourself
Phpize # System does not have phpize this tool, in the previously compiled good PHP/app/php/bin/this directory, some PHP version does not support this tool.
./configure--enable-xcache--with-php-config=/app/php/bin/php-config
Make && make install
3. Add a profile and edit it
mkdir/etc/php.d/
CP xcache.ini/etc/php.d/
Vim/etc/php.d/xcache.ini
Extension =/app/php/lib/php/extensions/no-debug-non-zts-20131226/xcache.so
Note: The module file generated by this compilation is not stored in the default directory by default, and you want to specify where it is stored
Service httpd24 Restart # restart HTTPDE Services
Seven, testing
Address of the 1.HTTP://HTTPD server/blog/
2. Stress test ab-c 100-n http://httpd server address/blog/
login will appear on the main page registration information
CentOS6 build and install lamp based on source code to realize WordPress function and XCache function