目录:

            |--->写在前面

            |--->编译安装apache

            |--->编译安装mysl

            |--->mysql5.6.24与老版本区别,安装mysql可能出现的问题及其解决方案

            |--->编译安装PHP

            |--->编译安装xcache

一.写在前面>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    1>.操作系统:redhat 6.4-x86_64  eth0接口地址192.168.1.11

        #setenforce 0

        #service iptables stop

    2>.yum安装    

        Development Tools

        zlib-devel.x86_64

        zlib.x86_64

        pcre-devel.x86_64

        openssl-devel.x86_64

        openssl.x86_64

    3>.以下资料都在云盘这里 http://yunpan.cn/cwcJxSDCQETev(提取码:61a7)


二.编译安装apache>>>>>>>>>>>>>>>>>>>>>>>>>

    源码包:

        httpd-2.4.12.tar.bz2

        apr-1.5.2.tar.bz2

        apr-util-1.5.4.tar.bz2  

        pcre-8.35.tar.gz

    1>.为支持2.4.12新特性,pcre包必须编译安装更新的版本。这里我们编译安装apr,apr-util,pcre

        #tar -xf apr-1.5.2.tar.bz2

        #cd apr-1.5.2

        #./configure --prefix=/usr/local/apr

        #make && make install


        #tar -xf apr-util-1.5.4.tar.bz2

        #cd apr-util-1.5.4

        #./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

        #make && make install


        #tar -xf pcre-8.35.tar.gz

        #cd pcre-8.35

        #./configure --prefix=/usr/local/pcre

        #make && make install

    2>.编译安装httpd-2.4.14

        #tar -xf httpd-2.4.12.tar.bz2 

        #cd httpd-2.4.12

        #./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-shared=most --with-mpm=event

        #make && make install

    3>.修改httpd的主配置文件,添加Pid文件的路径

        #vim /etc/httpd/httpd.conf

            PidFile  "/var/run/httpd.pid"

    4>.提供SysV服务脚本,并且提供权限,加入服务列表

        #vim /etc/rc.d/init.d/httpd

            (见云盘:httpd)

        #chmod +x /etc/rc.d/init.d/httpd

        #chkconfig --add httpd

        #chkconfig --level 2345 httpd on

    5>.添加帮助文档

        #vim /etc/man.config

            添加   MANPATH /usr/local/apache/man            

    6>.修改环境变量

        #vim /etc/profile.d/httpd.sh

            export PATH=$PATH:/usr/local/apache/bin

    7>.配置http虚拟主机

        #vim /etc/httpd/httpd.conf

            #DocumentRoot "/usr/local/apache/htdocs"(注释DocumentRoot行)

            Include /etc/httpd//extra/httpd-vhosts.conf (取消此行注释)

        #vim /etc/httpd//extra/httpd-vhosts.conf

            (见云盘 httpd-vhosts.conf)

        #vim /etc/hosts

            添加  192.168.1.11    www.a.org  

    8>.至此就可以启动服务测试了

        #service NetworkManager stop

        #service network start(要本地测试的话,NetworkManager必须关掉)

        #service httpd start

        #netstat -antple

三.编译安装mysql>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    1>.创建逻辑卷,独立分区/dev/mapper/mysqlvg-mysqllv 挂载在/mysqld上,专门为mysqld所用(you should better write mount info to /etc/fstab, or you might see "The server quit without updating PID file")

        创建逻辑卷详见:http://gumpping.blog.51cto.com/9811308/1619964

    2>.安装包准备

        mysql-5.6.24-linux-glibc2.5-x86_64.tar.gz

        libaio.x86_64

        libaio-devel.x86_64

    3>.安装5.6.24所依赖的包

        #yum install -y libaio.x86_64 libaio-devel.x86_64

    4>.创建系统用户:mysql,系统用户组:mysql,mysq家目录:/mysqld/data,将其属主属组改为mysql并且去掉该目录的读和执行权限
        #mkdir -pv /mysqld/data
        #groupadd -r mysql
        #useradd -g mysql -r -s /sbin/nologin -M -d /mysqld/data/ mysql
        #chown -R mysql.mysql /mysqld/data
        #chmod o-rx /mysqld/data
    5>.解压mysql包至/usr/lcal/
        #tar -xf mysql-5.6.24-linux-glibc2.5-x86_64.tar.gz -C /usr/local/

        #cd /usr/local/
        #ln -sv mysql-5.6.24-linux-glibc2.5-x86_64/ mysql
        #cd /usr/local/mysql/
        #chown -R mysql.mysql /usr/local/mysql/
    6>.安装mysql,用户为mysql,目录为/mysqld/data
        #scripts/mysql_install_db --user=mysql --datadir=/mysqld/data
        #chown -R root.mysql /usr/local/mysql/*
        #chown -R mysql ./data
        #bin/mysql_safe --user=mysql
    7>.修改配置文件,
可简单计算内存的值:『key_buffer_size+(sort_buffer+read_buffer)*max_connections』大约为256+(2+2)*150=856M.
        #cp support-files/my-default.cnf /etc/my.cnf

        #. !$        
        #vim /etc/my.cnf  (见云盘my.cnf)
            [client]
            port=3306
            socket=/tmp/mysql.sock
            max_allowed_packet=8M


            [mysqld]
            basedir = /usr/local/mysql
            datadir = /mysqld/data
            socket = /tmp/mysql.sock
            port = 3306           
            key_buffer_size=256M
            sort_buffer_size=2M
            read_buffer_size=2M
            max_connections=150
            max_allowed_packet=8M
            thread_concurrency = 2(这里的数值暂时取CPU个数的2倍【cat /proc/cpuinfo可查看】)

            [mysqldump]
            quick
            [mysqld_safe]
            log-error=/var/log/mysqld.log
            pid_file=/var/run/mysqld/mysqld.pid
    8>.提供mysqld的sysv服务脚本
        #cp support-files/mysql.server /etc/init.d/mysqld
        #chkconfig --add mysqld
        #chkconfig --list mysqld

    9>.添加帮助文档可用man,输出mysql的头文件至系统头文件路径,为系统提供mysql的库文件,重载系统库,修改环境变量
        #vim /etc/man.conf
            添加  MANPATH /usr/local/mysql/man
        #ln -sv /usr/local/mysql/include /usr/include/mysql
        #echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
        #ldconfig
        #vim /etc/profile.d/mysql.sh
            export PATH=$PATH:/usr/local/mysql/bin

    10>.启动服务测试,并且为mysql设置密码

         #service mysql start

        #mysql_secure_installation

        #hwclock -s

四.mysql版本区别,安装mysql可能出现的问题及其解决方案>>>>>>>>>>>>>>>>>>

    1>.mysql-5.6.8发行版前后的比较区别主要为:
        The my-default.cnf template replaces the older sample option files formerly supplied with MySQL distributions (my-small.cnf, my-medium.cnf, my-large.cnf, and my-huge.cnf). As of MySQL 5.6.8, these older files are no longer distributed.

        大概说my-default.cnf这个模板替换了旧发行版MYSQL所提供的 (my-small.cnf, my-medium.cnf, my-large.cnf, and my-huge.cnf)。从5.6.8版本之后,这些文件不再发行。

        详见:http://dev.mysql.com/doc/refman/5.6/en/server-default-configuration-file.html

    2>.mysql-5.6的/etc/my.cnf的基础配置

        详见:http://dev.mysql.com/doc/refman/5.6/en/option-files.html
    3>.可能出现问题以及解决方案
        --->error1:Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)
            >solution:#vim /etc/my.cnf

                    basedir=/usr/local/mysql

        --->error2:Starting MySQL...The server quit without updating PID file (/usr/local/mysql/xxxxxx.pid)
            >solution1:编辑/etc/my.cnf如步骤七
            >solution2:kill -9 mysql*

五.编译安装PHP>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    什么是php,php技术简介(个人感觉非常有用,见云盘:php.summary)

    1>.准备源码和依赖包

        php-5.6.8.tar.bz2

        libmcrypt-2.5.7-1.2.el6.rf.x86_64.rpm
        libmcrypt-devel-2.5.7-1.2.el6.rf.x86_64.rpm
        mhash-0.9.9-1.el6.rf.x86_64.rpm
        mhash-devel-0.9.9-1.el6.rf.x86_64.rpm

        bzip2.x86_64

        bzip2-devel.x86_64

        libxml2-devel.x86_64

        安装依赖源

        #rpm -ivh *.rpm

        #yum install bzip2.x86_64 libxml2-devel.x86_64

    2>.编译安装PHP

        #tar -xf php-5.6.8.tar.bz2

        #cd php-5.6.8

        #./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-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts

        #make

        #make test

        #make install

    3>.为php提供配置文件

        #cp php.ini-production /etc/php.ini

    4>.在httpd中设置与php连接的配置

        #vim /etc/httpd/httpd.conf

            <IfModule dir_module>(此模块中添加index.php)

                DirectoryIndex index.php index.html

            </IfModule>

            <FilesMatch \.php$>(告知 Apache 将特定的扩展名解析成 PHP)
                SetHandler application/x-httpd-php
            </FilesMatch>
            <FilesMatch "\.phps$">(将 .phps 文件由 PHP 源码过滤器处理,使得其在显示时可以高亮源码)
                SetHandler application/x-httpd-php-source
            </FilesMatch>

            <IfModule mime_module>(此模块为旧版本PHP配置模块,个人不建议使用:它不能排除”a.php.*“语言格式,推荐上面两个模块写法)

                AddType application/x-httpd-php .php

                AddType application/x-httpd-php-source .phps

            </IfModule>

        详见:http://php.net/manual/zh/install.unix.apache2.php

    5>.重启httpd服务,测试

        编辑/usr/local/apache/docs/www.a.org/index.php添加<?php phpinfo(); ?>测试结果中有php相关信息

六.编译安装xcache>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>返回目录

    1>.源码包

        xcache-3.0.1.tar.gz

    2>.编译安装

        # tar xf xcache-3.0.1.tar.gz
        # cd xcache-3.0.1
        # /usr/local/php/bin/phpize
        # ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config
        # make && make install

        出现Xcache的安装目录     /usr/local/php/lib/php/extensions/no-debug-zts-20131226/

    3>.将xcache提供的样例配置导入php.ini

        #mkdir /etc/php.d

        #cp xcache.ini /etc/php.d

    4>.测试

        编辑/usr/local/apache/docs/www.a.org/index.php添加<?php phpinfo(); ?>测试结果中有Xcache信息

    5>.特别说明:

        对与xcache3.x,/etc/php.d/xcache.ini不用添加zend_extension 选项,直接使用默认即可,否则Xcache不能启动,(亲测)。



定有不足,差错恳请致邮:KaiXuanyin@live.com