65yth 发表于 2014-5-21 08:44:01

Lamp源码安装及缓存


    首先安装环境
    Development tools
    Server Platform Development
    # yum --disablerepo=\* --enablerepo=c6-media groupinstall " Server Platform Development" "Development tools"
    1、安装MySQL
    从官网下载mysql绿色软件包www.mysql.com
    mysql-5.6.15-linux-glibc2.5-x86_64.tar.gz可以下载更新版本
    拆包
    # tar -zxvf mysql-5.6.15-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
    创建链接
    # ln -s mysql-5.6.15-linux-glibc2.5-x86_64/mysql
    创建用户以及组
    # groupadd -r mysql
    # useradd -r -g mysql mysql
    # chown -R mysql:mysql .
    # ./scripts/mysql_install_db --user=mysql
    # chown -R root .
    #chown-Rmysqldata
    # cp my.cnf/etc/【生成mysql server配置文件】
    # cp mysql.server/etc/init.d/mysqld【产生mysql server 控制文件】
    添加所有用户可执行权限
    # chmod a+x /etc/init.d/mysqld
    将mysql添加到启动项
    # chkconfig --add mysqld
    设置开机启动
    # chkconfig mysqld on

    3.改变 PATH变量
    vim /etc/profile
    PATH=$PATH:/usr/local/mysql/bin

    .   /etc/profile
    4.mysql库文件的输出
   echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf
    ldconfig
    5.手册
    echo "MANPATH /usr/local/mysql/man" >>/etc/man.conf

    2、安装httpd
    从网上下载源码包httpd-2.4.9.tar.bz2

    安装apr和apr-util
    # tar -zxvf apr-1.4.6.tar.gz -C /usr/local/src
    #./configure --prefix=/usr/local/apr
    # tar -zxvf apr-util-1.5.1.tar.gz -C /usr/local/src
    # cd ../apr-util-1.5.1/
    [root@localhostapr-util-1.5.1]#./configure--prefix=/usr/local/apr-utils--with-apr=/usr/local/apr/bin/apr-1-config

    改变PATH变量
    # vim /etc/profile
    添加一句
    PATH=$PATH:/usr/local/mysql/bin
    . /etc/profile
    mysql库的输出
    # vim /etc/ld.so.conf.d/mysql.conf
    添加一句/usr/local/mysql/lib
    然后刷缓存
    # ldconfig

    修改手册
    # vim /etc/man.config
   

    # tar -jxvf httpd-2.4.9.tar.bz2 -C /usr/local/src
    #./configure\
    --prefix=/usr/local/apache\
    --sysconfdir=/etc/httpd \
    --enable-so \
    --enable-ssl\
    --enable-rewrite\
    --with-apr=/usr/local/apr/bin/apr-1-config \
    --with-apr-util=/usr/local/apr-utils/bin/apu-1-config \
    --with-pcre\
    --with-z\
    --enable-mpms-shared=all \

    执行make和make install
    改变PATH
    # vim /etc/profile

   
    再执行一遍
    # . /etc/profile
   (查看下面的附件下载)
    修改man手册
    # echo "MANPATH /ust/local/apache/man" >>/etc/man.config
    写开机控制脚本,并设置开机启动
    # vim /etc/init.d/httpd

    # chkconfig --add httpd
    # chkconfig httpd on
    可以正常启动
   



    3、PHP安装
    从网上下载源码包 www.php.net

    先安装libxml2-devel
    # yum --disablerepo=\* --enablerepo=c6-media install libxml2-devel
    然后解压
    # tar -jxvf php-5.5.8.tar.bz2 -C /usr/local
    执行configure    ./configure\    --prefix=/usr/local/php \    --with-config-file-path=/etc/php\    --with-config-file-scan-dir=/etc/php5.d\    --with-apxs2=/usr/local/apache/bin/apxs\    --with-mysql=/usr/local/mysql \    --with-mysqli=/usr/local/mysql/bin/mysql_config \    --enable-mbstring=all
    然后make&&make install
    # make && make install

    在etc下创建php和php5.d
    # mkdir -pv php php5.d

    在httpd.conf 加入一句
    AddType application/x-httpd-php .php
    把php.ini拷到指定目录
    # cp php.ini-development /etc/php/php.ini

    测试
    在/var/www/html/下创建一个测试页index.php,如果可以调用MySQL则显示ok
    # cd /var/www/html/
    # vim index.php
   
    Apache已经可以调用MySQL

   
    修改index.php,看Apache是否可以调用php
    # vim index.php
   
    出现这个界面说明可以调用
   

    我们的安装已经完成。

    下面添加xcache缓存
    在没有添加xcache加速器时使用ab测试一下
    # ab -n 10000 -c 900 http://192.168.10.100/phpmyadmin
   


    解压xcache
    # tar -zxvf xcache-3.1.0.tar.gz -C /usr/local/src/
    产生config
    # /usr/local/php/bin/phpize
    [root@localhostxcache-3.1.0]#/configure--enable-xcache--with-php-config=/usr/local/php/bin/php-config
    # make && make install

    # cp xcache.ini /etc/php5.d/

    编辑xcache.ini,修改第四行路径
   

    重启下httpd再测试一下
    # service httpd restart
    # ab -n 10000 -c 900 http://192.168.10.100/phpmyadmin
   
    明显比不适用xcache快很多

    下面做xcache的web管理页面
    # cp -r htdocs/ /usr/local/apache/htdocs/xcache
    添加账户密码
    先产生md5加密的密码,拷贝进去
    # echo -n "123" |md5sum
    202cb962ac59075b964b07152d234b70-
    # vim /etc/php5.d/xcache.ini
   
    重启下httpd
    # service httpd restart
    已经可以web界面管理了
   

    当然也可以使用opcache
    编辑php.ini只需将0该为1 即可
    # vim /etc/php/php.ini
    ;opcache.enable=1
金山快盘附件:开机脚本.txt(0.85KB)


页: [1]
查看完整版本: Lamp源码安装及缓存