一. 安装所需的所有安装包

下载地址:http://yunpan.cn/cwgyc36ZW7rxq  访问密码刮刮乐 1b8f 

二.httpd源代码安装

1)下载之后依次安装:
apr-1.5.0.tar.bz2     
apr-util-1.5.2.tar.bz2  
httpd-2.4.10.tar.bz2
[[email protected] /]# tar -xf   apr-1.5.0.tar.bz2 
[[email protected] /]# tar -xf    apr-util-1.5.2.tar.bz2 
[[email protected] /]# tar -xf    httpd-2.4.10.tar.bz2 
[[email protected] apr-1.5.0]# ./configure   –prefix=/usr/local/apr && make && make  install 
[[email protected] apr-util-1.5.2]# ./configure   –prefix=/usr/local/apr-util  –with-apr=/usr/local/apr && make && make  install 
2)由于需要pcre ssl模块,所以在安装之前yum依次安装:
[[email protected] httpd-2.4.10]# yum install pcre-devel  openssl-devel 
[[email protected] httpd-2.4.10]# ./configure   –prefix=/usr/local/apache   –enable-so –enable-ssl –enable-cgi –enable-rewrite –with-zlib –with-pcre –with-apr=/usr/local/apr  –with-apr-util=/usr/local/apr-util/  –enable-modules=most –enable-mpms-shared=all –with-mom=event && make && make install 
3)创建用户和组:
[[email protected] /]#groupadd -r apache
[[email protected] /]#useradd -r -g apache apahce
4)在apache主配置文件最后添加以下内容:
PidFile "/var/run/httpd.pid"
5)添加/etc/rc.d/init.d/httpd文件并保存以下内容,然后赋予执行权限之后,即可启动apache.
[[email protected] httpd-2.4.10]# vim  /etc/rc.d/init.d/httpd
[[email protected] httpd-2.4.10]# chmod +x  /etc/rc.d/init.d/httpd 
[[email protected] httpd-2.4.10]# service httpd start

#!/bin/bash
#
# httpd        Startup script for the Apache HTTP Server
#
# chkconfig: – 85 15
# description: Apache is a World Wide Web server.  It is used to serve \
#        HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid

# Source function library.
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/httpd ]; then
        . /etc/sysconfig/httpd
fi

# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}

# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""

# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.

# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0

start() {
        echo -n $"Starting $prog: "
        LANG=$HTTPD_LANG daemon –pidfile=${pidfile} $httpd $OPTIONS
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch ${lockfile}
        return $RETVAL
}

stop() {
  echo -n $"Stopping $prog: "
  killproc -p ${pidfile} -d 10 $httpd
  RETVAL=$?
  echo
  [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
    echo -n $"Reloading $prog: "
    if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
        RETVAL=$?
        echo $"not reloading due to configuration syntax error"
        failure $"not reloading $httpd due to configuration syntax error"
    else
        killproc -p ${pidfile} $httpd -HUP
        RETVAL=$?
    fi
    echo
}

# See how we were called.
case "$1" in
  start)
  start
  ;;
  stop)
  stop
  ;;
  status)
        status -p ${pidfile} $httpd
  RETVAL=$?
  ;;
  restart)
  stop
  start
  ;;
  condrestart)
  if [ -f ${pidfile} ] ; then
    stop
    start
  fi
  ;;
  reload)
        reload
  ;;
  graceful|help|configtest|fullstatus)
  $apachectl [email protected]
  RETVAL=$?
  ;;
  *)
  echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
  exit 1
esac
exit $RETVAL


三.MariaDB统用二进制安装
1)下载并安装:
 mariadb-5.5.40-linux-x86_64.tar.gz
[[email protected] /]# tar xf  mariadb-5.5.40-linux-x86_64.tar.gz 
[[email protected] /]# mv  mariadb-5.5.40-linux-x86_64 /usr/local/mysql

2)新建mysql用户和组
[[email protected] /]# groupadd  -r -g 306 mysql
[[email protected] /]# useradd  -r -g 306 -u 306 mysql
3)把数据存放目录的数主数组改成mysql 
[[email protected] /]# mkdir /data
[[email protected] /]# chown  -R mysql.mysql /data/
[[email protected] mysql]# chown  -R root.mysql  * 在mysql的目录把属主改成root属组改成mysql
4)复制mysql生成一份mysql的配置文件
[[email protected] mysql]# mkdir /etc/mysql
[[email protected] support-files]# cp  my-large.cnf   /etc/mysql/my.cnf
5)初始化mysql数据库
[[email protected] mysql]# scripts/mysql_install_db   –datadir=/data  –user=mysql
6)修改主配置文件,添加以下参数
[[email protected] data]# vim /etc/mysql/my.cnf 
thread_cpncurrency=8 线程数 一般等于cpu的个数*2 (可使用lscpu命令查询cpu信息)
datadir=/data   数据库保存位置
innodb_file_per_table =on  对默认的数据引擎开启
7)启动mysql
[[email protected] mysql]cp support-files/mysql.server   /etc/rc.d/init.d/mysqld
[[email protected] mysql]chmod  +x /etc/rc.d/init.d/mysqld 
[[email protected] mysql]chkconfig  –add mysqld 
[[email protected] mysql]service mysqld start
[[email protected] mysql]# ss -tnl 查看3306开启即可!

四.源代码安装php
1)安装开发环境和依赖包 。
# yum -y groupinstall "Desktop Platform Development"
# yum -y install bzip2-devel libmcrypt-devel libxml2-devel
2)编译安装php
php-5.4.36.tar.bz2 
[[email protected] /]# tar xf php-5.4.36.tar.bz2 
[[email protected] /]# cd php-5.4.36
[[email protected] php-5.4.36]# ./configure   –prefix=/usr/local/php –with-mysql=/usr/local/mysql/  –with-openssl –with-mysqlli=/usr/local/mysql/bin/mysql_config   –enable-mbstring  –with-freetype-dir  –with-jpeg-dir  –with-png-dir –enable-zlib  –with-libxml-dir=/usr/   –enable-xml –enable-sockets  –with-apxs2=/usr/local/apache/bin/apxs   –with-bz2  –enable-maintainer-zts  && make &&make install 
3)为php提供配置文件
4)编辑apache的主配置文件,让apache支持php
[[email protected] php-5.4.36]# cp php.ini-production   /etc/php.ini
a:添加php支持类型
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source  .phps
b:在下面部分添加index.php 
    DirectoryIndex  index.php  index.html
c:在apache的网站根目录新建文件test.php并加入php的测试代码测试php环境
<?php
phpinfo();
?>
本地访问即可:http://172.16.249.221/test.php
五.源代码安装xcache
1)下载并安装:
xcache-3.2.0.tar.bz2
[[email protected] /]# tar xf xcache-3.2.0.tar.bz2 
[[email protected] /]# cd xcache-3.2.0
[[email protected] xcache-3.2.0]# /usr/local/php/bin/phpize  生成configure
[[email protected] xcache-3.2.0]# ./configure  –enable-xcache  –with-php-config=/usr/local/php/bin/php-config &&make && make install
安装完成会显示:
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20100525/
2)复制xcache的配置文件
[[email protected] xcache-3.2.0]# cp xcache.ini   /etc/php.d 
3)编辑xcache.ini文件,在[xcache-common]段添加xcache的路径为绝对路径
extension =/usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so
4)重启apache之后,在php的测试页面查看xcache插件

nali4

 

 

 

 

 

 

 

 

 

 

 

 

发表评论

后才能评论