准备工作

  1. 切换到管理员身份

    su -
  2. 安装编译扩展

    yum install -y gcc-c++
  3. 创建数据库目录、代码目录

    mkdir /mnt/data /mnt/www

安装Nginx 1.6.2

  1. 进入应用下载目录

    cd /usr/local/src
  2. 下载Nginx软件包及依赖包

    yum install -y openssl-devel pcre-devel zlib-devel
    wget http://nginx.org/download/nginx-1.6.2.tar.gz
  3. 添加用户及用户组

    useradd www
  4. 编译安装Nginx

    ./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --with-http_ssl_module --with-http_flv_module --user=www --group=www --with-http_gzip_static_module --with-http_stub_status_module --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/
    
    make -j5 install
  5. 创建启动脚本

    vi /etc/init.d/nginx

    #!/bin/sh
    #
    # nginx Startup script for nginx
    #
    # chkconfig: - 85 15
    # processname: nginx
    # config: /etc/nginx/nginx.conf
    # config: /etc/sysconfig/nginx
    # pidfile: /var/run/nginx.pid
    # description: nginx is an HTTP and reverse proxy server
    #
    ### BEGIN INIT INFO
    # Provides: nginx
    # Required-Start: $local_fs $remote_fs $network
    # Required-Stop: $local_fs $remote_fs $network
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: start and stop nginx
    ### END INIT INFO # Source function library.
    . /etc/rc.d/init.d/functions if [ -L $0 ]; then
    initscript=`/bin/readlink -f $0`
    else
    initscript=$0
    fi sysconfig=`/bin/basename $initscript` if [ -f /etc/sysconfig/$sysconfig ]; then
    . /etc/sysconfig/$sysconfig
    fi nginx=${NGINX-/usr/sbin/nginx}
    prog=`/bin/basename $nginx`
    conffile=${CONFFILE-/etc/nginx/nginx.conf}
    lockfile=${LOCKFILE-/var/lock/subsys/nginx}
    pidfile=${PIDFILE-/var/run/nginx.pid}
    SLEEPMSEC=${SLEEPMSEC-200000}
    UPGRADEWAITLOOPS=${UPGRADEWAITLOOPS-5}
    RETVAL=0 start() {
    echo -n $"Starting $prog: " daemon --pidfile=${pidfile} ${nginx} -c ${conffile}
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && touch ${lockfile}
    return $RETVAL
    } stop() {
    echo -n $"Stopping $prog: "
    killproc -p ${pidfile} ${prog}
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
    } reload() {
    echo -n $"Reloading $prog: "
    killproc -p ${pidfile} ${prog} -HUP
    RETVAL=$?
    echo
    } upgrade() {
    oldbinpidfile=${pidfile}.oldbin configtest -q || return
    echo -n $"Starting new master $prog: "
    killproc -p ${pidfile} ${prog} -USR2
    echo for i in `/usr/bin/seq $UPGRADEWAITLOOPS`; do
    /bin/usleep $SLEEPMSEC
    if [ -f ${oldbinpidfile} -a -f ${pidfile} ]; then
    echo -n $"Graceful shutdown of old $prog: "
    killproc -p ${oldbinpidfile} ${prog} -QUIT
    RETVAL=$?
    echo
    return
    fi
    done echo $"Upgrade failed!"
    RETVAL=1
    } configtest() {
    if [ "$#" -ne 0 ] ; then
    case "$1" in
    -q)
    FLAG=$1
    ;;
    *)
    ;;
    esac
    shift
    fi
    ${nginx} -t -c ${conffile} $FLAG
    RETVAL=$?
    return $RETVAL
    } rh_status() {
    status -p ${pidfile} ${nginx}
    } # See how we were called.
    case "$1" in
    start)
    rh_status >/dev/null 2>&1 && exit 0
    start
    ;;
    stop)
    stop
    ;;
    status)
    rh_status
    RETVAL=$?
    ;;
    restart)
    configtest -q || exit $RETVAL
    stop
    start
    ;;
    upgrade)
    rh_status >/dev/null 2>&1 || exit 0
    upgrade
    ;;
    condrestart|try-restart)
    if rh_status >/dev/null 2>&1; then
    stop
    start
    fi
    ;;
    force-reload|reload)
    reload
    ;;
    configtest)
    configtest
    ;;
    *)
    echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|upgrade|reload|status|help|configtest}"
    RETVAL=2
    esac exit $RETVAL

    chmod +x /etc/init.d/nginx

  6. 编辑配置

    vi /etc/nginx/nginx.conf
    • 修改访问用户

      # line:2
      user www;
    • 修改网站目录并开启PHP支持

      # line:43-46
      location / {
      root /mnt/www;
      index index.html index.htm index.php;
      }
      # line:65-71
      location ~ \.php$ {
      root html;
      fastcgi_pass 127.0.0.1:9000;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME /mnt/www$fastcgi_script_name;
      include fastcgi_params;
      }
  7. 启动Nginx

    service nginx start

安装MySQL 5.6.20

  1. 准备工作

    • 查找、删除系统中的MySQL

      rpm -qa | grep mysql
      # > mysql-libs-5.1.73-3.el6_5.x86_64
      rpm -e mysql-libs-5.1.73-3.el6_5.x86_64 --nodeps
    • 安装编译工具

      yum install -y cmake
    • 下载MySQL源码包

      wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.21.tar.gz
  2. 编译安装MySQL

    tar zxf mysql-5.6.21.tar.gz
    cd mysql-5.6.21 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mnt/data/mysql -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci make -j5 install
  3. 创建MySQL用户

    groupadd -g 27 -r mysql
    useradd -r -u 27 -g mysql -s /sbin/nologin -d /root -c "MySQL" mysql
  4. 修改目录权限

    chown -R mysql.mysql /usr/local/mysql
  5. 初始化安装数据库

    /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/mnt/data/mysql --user=mysql
  6. 查看MySQL启动顺序、放置MySQL配置文件

    mysql --verbose --help | grep -A 1 'Default options'
    mv /usr/local/mysql/my.cnf /etc
  7. 启动MySQL(报错注意关闭seLinux)

    ln -s /usr/local/mysql/bin/mysql /bin/mysql
    cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
    chkconfig --add mysql
    chkconfig mysql on
    service mysql start
  8. 修改密码

    • 推荐方式:

      /usr/local/mysql/bin/mysql_secure_installation
    • 备用方式:

      mysql -u root -ph8znVjtSES17d_pg
      
      SET PASSWORD=password('admin888');
      GRANT all privileges on *.* TO 'root'@'%' identified by 'admin888' WITH GRANT OPTION;
      FLUSH PRIVILEGES;
      \q
  9. 重新编译时,需要清除旧的对象文件和缓存信息。

    # make clean
    # rm -f CMakeCache.txt
    # rm -rf /etc/my.cnf

安装PHP 5.6.4

  1. 安装编译使用的扩展

    yum install -y gcc gcc-c++
  2. 安装依赖库

    1. 安装libmcrypt

      下载页面:http://sourceforge.net/projects/mcrypt/files/Libmcrypt/

      cd /usr/local/src
      tar zxf /usr/local/src/libmcrypt-2.5.8.tar.gz
      cd /usr/local/src/libmcrypt-2.5.8/
      ./configure; make -j5 install
    2. 安装mhash

      下载页面:http://sourceforge.net/projects/mhash/files/mhash/

      cd /usr/loacl/src
      tar zxvf /usr/local/src/mhash-0.9.9.9.tar.gz
      cd /usr/local/src/mhash-0.9.9.9/
      ./configure; make -j5 install
    3. 配置运行库

      vi /etc/ld.so.conf
      
      line:2 加入
      /usr/local/lib ldconfig

      如果报错执行:export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

    4. 安装mcrypt

      下载页面:http://sourceforge.net/projects/mcrypt/files/MCrypt/

      tar zxf /usr/local/src/mcrypt-2.6.8.tar.gz
      cd /usr/local/src/mcrypt-2.6.8
      ./configure; make -j5 install
  3. 安装PHP扩展

    yum install -y libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel gd gd-devel glib2 glib2-devel ncurses ncurses-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel libcurl libcurl-devel
  4. 安装PHP

    1. 下载并解压

      下载页面:http://cn2.php.net/downloads.php

      tar jxf /usr/local/src/php-5.6.4.tar.bz2
      cd /usr/local/src/php-5.6.4
    2. 编译

      ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql --with-mysqli --with-pdo-mysql --with-curl --with-mcrypt --with-mhash --with-gd --with-openssl --with-xmlrpc --with-zlib --with-libxml-dir --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --enable-inline-optimization --enable-bcmath --enable-mbstring --enable-mbregex --enable-sockets --enable-zip --enable-debug --enable-maintainer-zts --enable-sysvsem --enable-shmop --enable-xml --enable-sysvsem --enable-sysvshm --enable-gd-native-ttf --enable-pcntl --enable-soap --enable-opcache --disable-rpath
    3. 安装,注意&&

      make -j5 && make install
  5. 移动配置文件

    cp /usr/local/src/php-5.6.4/php.ini-production /usr/local/php/etc/php.ini
    cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
  6. 添加php-fpm到service

    1. 开启php-fpm.pid

      vi /usr/local/php/etc/php-fpm.conf
      
      line:25 开启pid,改为
      pid = /var/run/php-fpm.pid
    2. 新建服务脚本

      vi /etc/init.d/php-fpm
      ----------------------- #!/bin/bash
      #
      # Startup script for the PHP-FPM server.
      #
      # chkconfig: 345 85 15
      # description: PHP is an HTML-embedded scripting language
      # processname: php-fpm
      # config: /usr/local/php/etc/php.ini # Source function library.
      . /etc/rc.d/init.d/functions PHP_PATH=/usr/local/php
      DESC="php-fpm daemon"
      NAME=php-fpm
      # php-fpm路径
      DAEMON=$PHP_PATH/sbin/$NAME
      # 配置文件路径
      CONFIGFILE=$PHP_PATH/etc/php-fpm.conf
      # PID文件路径(在php-fpm.conf设置)
      PIDFILE=/var/run/$NAME.pid
      SCRIPTNAME=/etc/init.d/$NAME # Gracefully exit if the package has been removed.
      test -x $DAEMON || exit 0 rh_start() {
      $DAEMON -y $CONFIGFILE || echo -n " already running"
      } rh_stop() {
      kill -QUIT `cat $PIDFILE` || echo -n " not running"
      } rh_reload() {
      kill -USR2 `cat $PIDFILE` || echo -n " can't reload"
      } case "$1" in
      start)
      echo -n "Starting $DESC: $NAME"
      rh_start
      echo "."
      ;;
      stop)
      echo -n "Stopping $DESC: $NAME"
      rh_stop
      echo "."
      ;;
      reload)
      echo -n "Reloading $DESC configuration..."
      rh_reload
      echo "reloaded."
      ;;
      restart)
      echo -n "Restarting $DESC: $NAME"
      rh_stop
      sleep 1
      rh_start
      echo "."
      ;;
      *)
      echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
      exit 3
      ;;
      esac
      exit 0
  7. 添加执行权限

    chmod +x /etc/init.d/php-fpm
  8. 启动php-fmp

    service php-fpm start

添加自启动

chkconfig --add php-fpm
chkconfig php-fpm on
chkconfig nginx on
chkconfig mysql on

CentOS6.6x86_64 部署 Nginx1.62+MySQL5.6.20+PHP5.6.4的更多相关文章

  1. CentOS6.9部署Redis3.2.9+FastDFS_4.06+Nginx1.5.0

    CentOS6.9部署Redis3.2.9+FastDFS_4.06+Nginx1.5.0 原文链接:https://www.toutiao.com/i6481931577499582990/ 一.上 ...

  2. centos6.8 Mysql-5.7.20 升级 mysql-8.0.14-1

    Mysql-5.7.20 升级 mysql-8.0.14-1   操作前建议先查阅以下网页初步了解Mysql版本升级信息  https://blog.csdn.net/u012946310/artic ...

  3. centos6.8 Mysql5.6.22 升级 mysql-5.7.20

    一.检查系统环境 二.备份数据库 mysqldump –all-databases > allbackupfile.sql (建议:有条件的话可使用图形化界面备份,操作灵活) 三.下载安装文件 ...

  4. CentOS 6.2编译安装Nginx1.2.0+MySQL5.5.25+PHP5.3.13

    CentOS 6.2编译安装Nginx1.2.0+MySQL5.5.25+PHP5.3.132013-10-24 15:31:12标签:服务器 防火墙 file 配置文件 written 一.配置好I ...

  5. Centos6.6部署Redis集群

    Centos6.6部署Redis集群 1环境准备 1环境安装redis 1安装ruby 2配置redis主从环境 3部署redis sentinel服务器 5集群使用 13当前集群环境说明 13测试功 ...

  6. MySQL5.7.20报错Access denied for user 'root'@'localhost' (using password: NO)

    在centos6.8上源码安装了MySQL5.7.20,进入mysql的时候报错如下: 解决办法如下: 在mysql的配置文件内加入: vim  /etc/my.cnf skip-grant-tabl ...

  7. CentOS 7.x编译安装Nginx1.10.3+MySQL5.7.16+PHP5.2 5.3 5.4 5.5 5.6 7.0 7.1多版本全能环境

    准备篇 一.防火墙配置 CentOS 7.x默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewalld.se ...

  8. [svc]centos6上部署openvpn+gg二步认证

    最近又发现个新的vpn: wireguard 为了满足员工在家办公的需求.需要 openvpn+gg方案 在centos6上部署openvpn 参考 1.安装前准备 wget -O /etc/yum. ...

  9. CentOS7.2编译配置LNMP环境(MySQL5.7.20,PHP7.0.24)

    一,     查看系统版本及内核版本 二,     编译安装nginx 1,          新建nginx用户 useradd -s /sbin/nologin -M nginx 2,       ...

随机推荐

  1. 解决JsonFormat日期少一天问题

    使用Jackson的@JsonFormat注解时出现少一天 比如数据库存的日期是2015-01-05,转成json则变成了2015-01-04 解决办法: @JsonFormat(pattern=&q ...

  2. C#关于窗体的keysdown事件,无法获取到焦点

    当窗体中包含button之类的控件时,按下方向键时它们会自动获取焦点,导致窗体keysdown事件无法执行.解决方法很简单.将按钮之类控件放到panel容器中控件就无法获取焦点了.这时焦点会在整个窗体 ...

  3. 解决Ext.TextField的AllowBlank不能过滤空格代码

    Ext过滤空格 重写了组件... Ext.apply(Ext.form.TextField.prototype, { validator : function(text) { if (this.all ...

  4. Android 判断wifi和4G网络是否开启

    public boolean isWifiAvailable() { ConnectivityManager connectivityManager = (ConnectivityManager) g ...

  5. macbookpro2011 光驱坏了如何安装windows7

    由于光驱坏了试了网络上的很多方法,2011年款是无法识别到光驱的,即使做了USB的windows驱动盘也无济于事,结果去了电脑城,一位技术员最终用一个U盘装着windowsPE,从PE中安装windo ...

  6. 【HDOJ】2266 How Many Equations Can You Find

    简单DFS. #include <cstdio> #include <cstring> #define MAXN 15 char str[MAXN]; __int64 x; i ...

  7. C++ Primer 随笔 Chapter 9 顺序容器

     参考:http://www.cnblogs.com/kurtwang/archive/2010/08/19/1802912.html 1..顺序容器:vector(快速随机访问):list(快速插入 ...

  8. -_-#【jQuery插件】Colorpicker 颜色选择器

    Spectrum - The No Hassle jQuery Colorpicker (jQuery 插件) Color Picker jQuery plugins (jQuery 插件) colo ...

  9. Linux企业级开发技术(3)——epoll企业级开发之epoll模型

    EPOLL事件有两种模型: Edge Triggered (ET)  边缘触发 只有数据到来,才触发,不管缓存区中是否还有数据. Level Triggered (LT)  水平触发 只要有数据都会触 ...

  10. bzoj 1602 [Usaco2008 Oct]牧场行走(LCA模板)

    1602: [Usaco2008 Oct]牧场行走 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 379  Solved: 216[Submit][Sta ...