First, compile and install Apache
1. Install the build environment:
#yum-y groupinstall ' development tools '
#yum-y groupinstall ' Desktop Platform development '
#yum install wget gcc gcc-c++ make re2c curl curl-devel libxml2 libxml2-devel libjpeg libjpeg-devel libpng libpng-devel li Bmcrypt libmcrypt-devel zlib zlib-devel OpenSSL openssl-devel freetype freetype-devel gd gd-devel perl perl-devel ncurses Ncurses-devel Bison bison-devel libtool gettext gettext-devel cmake bzip2 bzip2-devel pcre pcre-devel (no Libmcrypt package in Yum Warehouse, It is necessary to re-install the libmcrypt below)
2. Compile and install Apr
#cd/USR/LOCAL/SRC
#tar-ZXVF apr-1.5.2.tar.gz
#cd apr-1.5.2
#./configure--PREFIX=/USR/LOCAL/APR
Make && make install
3. Compile and install Apr-util
#tar-ZXVF apr-util-1.5.4.tar.gz
#cd apr-util-1.5.4
#./configure--prefix=/usr/local/apr-util--WITH-APR=/USR/LOCAL/APR
#make && make Install
4. Compile and install httpd
#tar-ZXVF httpd-2.4.16.tar.gz
#cd httpd-2.4.16
#./configure--prefix=/usr/local/apache--enable-so--enable-ssl--enable-cgi--enable-rewrite--enable-zlib-- With-pcre--with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util--enable-modules=most--enable-mpms-shared =all--with-mpm=event--enable-deflate
#make && make Install
#cp/usr/local/apache/conf/httpd.conf/usr/local/apache/conf/httpd.conf.bak #备份配置文件
#vi/usr/local/apache/conf/httpd.conf #编辑配置文件
Found: #ServerName www.example.com:80
Modified to: ServerName 172.24.0.2:80
Found: DirectoryIndex index.html
Modified to: DirectoryIndex index.html index.php
Found: Options Indexes followsymlinks
Modified to: Options followsymlinks #不显示目录结构
Find AllowOverride None
Modified to: AllowOverride all #开启apache支持伪静态, modified in three places
LoadModule rewrite_module modules/mod_rewrite.so #取消前面的注释, open Apache support pseudo-static
Vi/etc/profile #添加apache服务系统环境变量
Add the following line at the end
Export path= $PATH:/usr/local/apache/bin
#chown daemon.daemon-r/usr/local/apache/htdocs #更改目录所有者
#chmod 700/usr/local/apache/htdocs-r #更改apache网站目录权限
Launch Apache
#/usr/local/apache/bin/apachectl-k start
Check whether to start
#ps-ef|grep httpd
#netstat-tplun|grep ": 80"
Second, compile and install MySQL
1. Compile and install CMake
#cd/USR/LOCAL/SRC
#tar-ZXVF cmake-3.2.1.tar.gz
#cd cmake-3.2.1
#./configure--prefix=/usr/local/cmake
#make && make Install
#vim ~/.bash_profile
Modify path= $PATH: $HOME/bin
paht= $PATH: $HOME/bin:/usr/local/cmake/bin
Save exit
#source ~/.bash_profile
2. Compile and install MySQL
#groupadd-R MySQL
#useradd-G mysql-r-s/sbin/nologin-m MySQL
#tar-ZXVF mysql-5.6.17.tar.gz
#cd mysql-5.6.17
#cmake. -dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/usr/local/mysql/data-dsysconfdir=/etc-dwith_innobase_ Storage_engine=1-dwith_archive_storage_engine=1-dwith_blackhole_storage_engine=1-dwith_federated_storage_ Engine=1-dwith_partition_storage_engine=1-dmysql_unix_addr=/tmp/mysqld.sock-denabled_local_infile=1-dextra_ Charsets=all-dmysql_user=mysql-ddefault_charset=utf8-ddefault_collation=utf8_general_ci
#gmake
#make Install
#cd/usr/local/mysql/support-files
#cp Mysql.server/etc/init.d/mysql
#cp my-default.conf/etc/my.cnf
#vim/etc/my.cnf
Basedir =/usr/local/mysql
DataDir =/usr/local/mysql/data
Port = 3306
Socket =/tmp/mysqld.sock
#chown-R MySQL. /usr/local/mysql/data
#cd/usr/local/mysql/scripts
#./mysql_install_db--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data--no-defaults--user=mysql
#service MySQL Start
#ps-ef | grep MySQL (see if there is a MySQL process)
#vim ~/.bash_profile
Append ":/usr/local/mysql/bin" after the path variable, and the result of the modification is as follows:
Path= $PATH: $HOME/bin:/usr/local/cmake/bin:/usr/local/mysql/bin (Note:/usr/local/cmake/bin directory for this experiment compiles the directory generated by the installation, If your cmake is installed via RPM or yum, there is no such path. Path= $PATH: $HOME/bin:/usr/local/mysql/bin)
#source ~/.bash_profile
You can also modify global variables
#vim/etc/profile
At the end of the add
Path= $PATH:/usr/local/mysql/bin:/usr/local/cmake/bin (Note:/usr/local/cmake/bin The directory generated for this experiment to compile the installation. )
#mysql
Mysql>\s
Third, compile and install PHP
1. Installing Libmcrypt
#cd/USR/LOCAL/SRC
#tar-ZXVF limcrypt-2.5.7.tar.gz
#cd libmcrypt-2.5.7
#./configure--prefix=/usr/local/libmcrypt
#make && make Install
2. Install PHP
#tar-JXVF php-5.6.7.tar.bz2
#cd php-5.6.7
#./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache/bin/apxs--with-config-file-path=/usr/local/ Php/etc--with-mysql=mysqlnd--with-mysqli=mysqlnd--with-pdo-mysql=mysqlnd--with-libxml-dir--WITH-GD-- With-jpeg-dir--with-png-dir--with-freetype-dir--with-iconv-dir--with-zlib-dir--with-bz2--with-openssl--with- mcrypt=/usr/local/libmcrypt/--enable-soap--enable-gd-native-ttf--enable-mbstring--enable-sockets--enable-exif- -disable-ipv6 (PHP 5.3 or above recommended to use the Mysqlnd driver, see: https://blog.linuxeye.com/395.html)
#make
#make Test
#make Install
#mkdir/usr/local/php/etc
#cp Php.ini-production/usr/local/php/etc/php.ini #复制php配置文件到安装目录
#rm-rf/etc/php.ini #删除系统自带的配置文件
#ln-S/usr/local/php/etc/php.ini/etc/php.ini #创建配置文件软链接
#vi/usr/local/php/etc/php.ini #编辑
Found in:; Open_basedir =
Modified to: Open_basedir =.:/ tmp/#防止php木马跨站, Important!!
Found: Disable_functions =
Modified to: Disable_functions = Passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini _alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server, Escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space, POSIX_CTERMID,POSIX_GET_LAST_ERROR,POSIX_GETCWD, Posix_getegid,posix_geteuid,posix_getgid, Posix_getgrgid,posix_ Getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, Posix_getppid,posix_getpwnam, Posix_getpwuid, Posix_getrlimit, Posix_getsid,posix_getuid,posix_isatty, Posix_kill,posix_mkfifo,posix_setegid, Posix_seteuid,posix_setgid, Posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname, Posix_uname
#列出PHP可以禁用的函数, if some programs need to use this function, you can delete, cancel disable.
Found:;d Ate.timezone =
Modified to: Date.timezone = PRC
Found: expose_php = On
Modified to: expose_php = OFF #禁止显示php版本的信息
Found: Display_errors = On
Modified to: display_errors = OFF #关闭错误提示
Configure Apache to support PHP
Vi/usr/local/apache/conf/httpd.conf #编辑apache配置文件
In the LoadModule php5_module modules/libphp5.so line, add the following,
AddType application/x-httpd-php. php
AddType Application/x-httpd-php-source. Phps (Note: PHP. PHP has a space before this point)
Service httpd Restart #重启apache
Service mysqld Restart #重启mysql
Test article
vim/usr/local/apache/htdocsvi/index.php #输入下面内容
<?php
Phpinfo ();
?>
: wq! #保存
In the client browser enter the server IP address, you can see the relevant configuration information!
Iv. Installing the XCache for PHP acceleration
#cd/USR/LOCAL/SRC
#tar ZXVF xcache-3.2.0.tar.gz
#/usr/local/php/bin/phpize
#./configure--enable-xcache--with-php-config=/usr/local/php/bin/php-config
#make && make Install
At the end of the installation, a line similar to the following appears:
Installing Shared extensions:/usr/local/php/lib/php/extensions/no-debug-zts-20131226/xcache.so
Edit PHP.ini, integrate PHP and XCache
The sample configuration provided by XCache is first imported into the php.ini
# MKDIR/ETC/PHP.D
# CP XCACHE.INI/ETC/PHP.D (Note: Xcache.ini file is in the XCache source directory. )
Next edit/etc/php.d/xcache.ini, locate the line that begins with extension, and modify it to the following line
Extension =/usr/local/php/lib/php/extensions/no-debug-zts-20131226/xcache.so (Note: If the php.ini file has more than one zend_ Extension the command line, make sure that this new row is ranked first. )
At this point, the entire installation process is over, the following is a brief introduction to the use of pressure test tool AB.
Ab Use method
Test Apache server performance with the AB command:
-C Concurrency: The number of requests initiated at once, the default is 1;
-I: Use the head method when testing, the default is get;
-K: Enable HTTP long connection request mode;
-N Requests: The number of impersonation requests initiated, the default is 1, the number of requests is greater than or equal to the number of concurrent connections;
-Q: Silent mode, when the number of requests is greater than 150 does not output the percentage of request completion;
Output Result:
Time taken for tests: the duration from the first request connection to the end of the response message that received the last request;
Complete requests: number of successful requests;
Simple test:
Ab-c 100-n http://localhost/index.php
This approach allows you to make a simple assessment of the performance of your Web server.
This article is from the "Lot" blog, please be sure to keep this source http://6294180.blog.51cto.com/6284180/1685154
Pro-Test CentOS 6.6 x86_64 under source installation lamp platform (APACHE 2.4.16+mysql 5.6.17+php 5.6.7)