54432 发表于 2014-6-27 16:42:43

apache/mysql/php编译安装及支持xcache和fastcgi方式运行

一、编译安装apache
    1、安装环境:yum install gcc gcc-c++ openssl-devel libtool -y
    2、安装apr、apr-util及pcre
      tar jxf apr-1.5.1.tar.bz2
      cd apr-1.5.1
      ./configure --prefix=/usr/local/apr
      make && make install
   
      tar jxf apr-util-1.5.3.tar.bz2
      cd apr-util-1.5.3
      ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

      tar jxf pcre-0.8.33.tar.bz2
      cd pcre-0.8.33
      ./configure --prefix=/usr/local/pcre
    3、解压编译安装httpd
      tar jxf httpd-2.4.9.tar.bz2
      cd httpd-2.4.9
      ./configure --prefix=/usr/local/apache \
      --enable-so \
      --enable-rewrite \
      --enable-ssl \
      --enable-mpms-shared=all \
      --sysconfdir=/etc/httpd \
      --enable-proxy \
      --enable-cgi \
      --enable-cgid \
      --enable-zlib \
      --with-apr=/usr/local/apr \
      --with-apr-util=/usr/local/apr-util \
      --with-pcre=/usr/local/pcre
      make && make install
      编译完成之后测试启动apache/usr/local/apache/bin/apachectl start
      检查httpd是否启动netstat -tnpl |grep httpd
    注:如httpd进程未启动,则检查/usr/local/apache/logs/error_log
AH01177: Failed to lookup provider 'shm' for 'slotmem': is mod_slotmem_shm loaded??
[:emerg] AH00020: Configuration Failed, exiting
      可以看出是proxy_balancer这个模块的问题,编辑配置文件注释proxy_balancer.so这个模块,重新启动

      添加apache到系统变量 echo 'export PATH=$PATH:/usr/local/apache/bin' >>/etc/profile.d/httpd.sh

配置虚拟主机:

配置中心主机注释中心主机并开启虚拟主机
注释:DocumentRoot "/usr/local/apache/htdocs"
开启:Include /etc/httpd/extra/httpd-vhosts.conf
配置虚拟主机:vim /etc/httpd/extra/httpd-vhosts.conf
<virtualhost *:80>
    servername www.example.com
    documentroot "/www/example.com"
    errorlog "/var/log/httpd/error_log"
    customlog "/var/log/httpd/access_log" combined
    <directory "/www/example.com">
    options none
    allowoverride none
    require all granted
    </directory>
#限制目录访问功能:
#    <directory "/www/example.com">
#    options none
#    allowoverride authconfig
#    authtype basic
#    authname "example.com"
#    authuserfile "/etc/httpd/.htpassword"
#    require vaild-user   
</virtualhost>
启用apache的ssl功能:
    启用LoadModule ssl_so
    启用Include /etc/httpd/extra/httpd-ssl.conf      
二、源码安装mysql
    groupadd -r -g 306 mysql
    useradd -r -g mysql -s /sbin/nolog mysql
    tar zxf mysql-5.6.19-linux-glibc2.5.x86_64.tar.gz -C /usr/local
    cd /usr/local
    ln -s mysql-5.6.19-linux-glibc2.5.x86_64 mysql
    cd mysql
    chown -R mysql.mysql .
    mkdir /mydata
    chown -R mysql.mysql /mydata
    ./usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/mydata
    vim my.cnf
      
      user=mysql
      socket=/tmp/mysql.sock
      datedir=/mydata
      
      socket=/tmp/mysql.sock
      
    cp support-files/mysql.server /etc/init.d/mysqld
    chkconfig --add mysqld
    chkconfig mysqld on
    echo 'export PATH=$PATH:/usr/local/mysql/bin'>>/etc/profile.d/mysqld.sh
    chown -R root .
    echo '/usr/local/mysql/lib'>>/etc/ld.so.conf.d/mysqld.conf
    ldconfig
    ldconfig -v |grep mysql
      service mysqld start————>mysql客户端连接查看


三、编译安装PHP
    tar jxf php-5.5.13.tar.bz2
    cd php-5.5.13
    ./configure --prefix=/usr/local/php \
    --with-apxs2=/usr/local/apache/bin/apxs \
    --with-mysql=/usr/local/mysql \
    --enable-fpm \
    --with-config-file-path=/etc/php \
    --sysconfdir=/etc/php \
    --with-config-file-scan-dir=/etc/php/php.d \
    --with-zlib \
    --with-bz2 \
    --enable-mbstring \
    --with-mysqli=/usr/local/mysql/bin/mysql_config \
    --enable-zip \
    --with-jpeg-dir \
    --with-png-dir \
    --with-openssl
    make && make install

    为php提供配置文件: cp php.ini-production /etc/php/php.ini

    输出php脚本到系统环境变量:

      echo 'export PATH=$PATH:/usr/local/php/bin'>>/etc/profile.d/php.sh

    编辑httpd配置文件加载php模块

    LoadModule php5_module    modules/libphp5.so

    DirectoryIndexindex.php index.html

    AddType application/x-httpd-php .php

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

    重启httpd 新建index.php页面,测试访问

    建立mysql_connect()函数测试php与mysql连接

      <?php

      $conn=mysql_connect('localhost','root','');

      if ($conn)

            echo "scuess...";

      else

            echo "failure..."

      ?>

    安装xcache:
      tar zxf xcache-3.1.0.tar.gz
      cd xcache-3.1.0
      yum install autoconf -y

      /usr/local/php/bin/phpize
      ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config
      make && make install
      cp xcache.ini /etc/php/php.d
      修改vim /etc/php/php.d/xcache.ini 指定正确的PHP扩展路径即编译xcache时make install最后输出的路径
      重启httpd 使用phpinfo查看xcache是否加载成功    
                           


页: [1]
查看完整版本: apache/mysql/php编译安装及支持xcache和fastcgi方式运行