官网部署手册

官网部署手册

1.  前期准备

1.1安装centos6.8系统,并配置ip,能够上外网。

备注:此步骤省略

2.  安装相关软件服务

2.1lnmp环境准备

yum –y install gcc gcc-c++ autoconf automake bison flex make libtool zlib-devel zip unzip openssl-devel php pcre pcre-devel telnet curl-devel ntp wget perl-Test-Harness mysql mysql-server epel-release gettext php-devel php-fpm php-cli php-pdo php-mbstring php-gd php-tidy php-xml php-xmlrpc php-mcrypt php-mysql

2.2修改配置/etc/php-fpm.d/www.conf文件

pm.start_servers = 5

pm.min_spare_servers = 5

pm.max_spare_servers = 100

pm.max_children = 100

user = www

group = www

2.3配置php-fpm服务开机自启动

chkconfig  php-fpm  on

service  php-fpm  start

useradd -c "tengine daemon account" -r www

ulimit -SHn 65535

2.4编译安装jemalloc-4.4.0和tengine-2.2.0

wget https://github.com/jemalloc/jemalloc/releases/download/4.4.0/jemalloc-4.4.0.tar.bz2

tar xjvf jemalloc-4.4.0.tar.bz2

cd jemalloc-4.4.0/

./configure --prefix=/usr/local/jemalloc

make -j8 && make install

echo /usr/local/jemalloc/lib >> /etc/ld.so.conf

ldconfig

wget http://tengine.taobao.org/download/tengine-2.2.0.tar.gz

tar zxvf tengine-2.2.0.tar.gz

cd tengine-2.2.0

./configure --user=www --group=www --with-http_ssl_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-mail --with-mail_ssl_module --with-jemalloc --with-jemalloc=/root/jemalloc-4.4.0

./configure --user=www --group=www --with-http_ssl_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-mail --with-mail_ssl_module

  nginx path prefix: "/usr/local/nginx"

  nginx binary file: "/usr/local/nginx/sbin/nginx"

  nginx configuration prefix: "/usr/local/nginx/conf"

  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"

  nginx pid file: "/usr/local/nginx/logs/nginx.pid"

  nginx error log file: "/usr/local/nginx/logs/error.log"

  nginx http access log file: "/usr/local/nginx/logs/access.log"

  nginx http client request body temporary files: "client_body_temp"

  nginx dso module path: "/usr/local/nginx/modules/"

  nginx http proxy temporary files: "proxy_temp"

  nginx http fastcgi temporary files: "fastcgi_temp"

  nginx http uwsgi temporary files: "uwsgi_temp"

  nginx http scgi temporary files: "scgi_temp"

make

make install

2.5配置nginx启动脚本

vi /etc/rc.d/init.d/nginx

#开始

#!/bin/sh

#

# nginx - this script starts and stops the nginx daemon

#

# chkconfig:   - 85 15

# description:  Nginx is an HTTP(S) server, HTTP(S) reverse \

#               proxy and IMAP/POP3 proxy server

# processname: nginx

# config:      /usr/local/nginx/conf/nginx.conf

# pidfile:     /usr/local/nginx/logs/nginx.pid

 

# Source function library.

. /etc/rc.d/init.d/functions

 

# Source networking configuration.

. /etc/sysconfig/network

 

# Check that networking is up.

[ "$NETWORKING" = "no" ] && exit 0

 

nginx="/usr/local/nginx/sbin/nginx"

prog=$(basename $nginx)

 

NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"

 

lockfile=/var/lock/subsys/nginx

 

start() {

    [ -x $nginx ] || exit 5

    [ -f $NGINX_CONF_FILE ] || exit 6

    echo -n $"Starting $prog: "

    daemon $nginx -c $NGINX_CONF_FILE

    retval=$?

    echo

    [ $retval -eq 0 ] && touch $lockfile

    return $retval

}

 

stop() {

    echo -n $"Stopping $prog: "

    killproc $prog -QUIT

    retval=$?

    echo

    [ $retval -eq 0 ] && rm -f $lockfile

    return $retval

}

 

restart() {

    configtest || return $?

    stop

    start

}

 

reload() {

    configtest || return $?

    echo -n $"Reloading $prog: "

    killproc $nginx -HUP

    RETVAL=$?

    echo

}

 

force_reload() {

    restart

}

 

configtest() {

  $nginx -t -c $NGINX_CONF_FILE

}

 

rh_status() {

    status $prog

}

 

rh_status_q() {

    rh_status >/dev/null 2>&1

}

 

case "$1" in

    start)

        rh_status_q && exit 0

        $1

        ;;

    stop)

        rh_status_q || exit 0

        $1

        ;;

    restart|configtest)

        $1

        ;;

    reload)

        rh_status_q || exit 7

        $1

        ;;

    force-reload)

        force_reload

        ;;

    status)

        rh_status

        ;;

    condrestart|try-restart)

        rh_status_q || exit 0

            ;;

    *)

        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"

        exit 2

esac

        #结束

 

赋予脚本可执行权限:

chmod 755 nginx

配置nginx自启动,并启动它。

chkconfig  nginx  on

service nginx start

修改配置文件

vi /usr/local/nginx/conf/nginx.conf

location ~ \.php$ {

            root           html;

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

            fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html$fastcgi_script_name;

            include        fastcgi_params;

        }

2.6mysql设置开机自启动,并导入官网数据库语句。

chkconfig mysqld on

service mysqld start

/usr/bin/mysqladmin -u root password 'new-password'

###注意修改”new-password”为合适的密码

mysql -uroot -p

Enter password:

mysql>grant all privileges on *.*  to  ‘root’@’%’ identified by ‘new-password’ with grant option; 

mysql>grant all privileges on *.* to ‘root’@’localhost’ identified by ‘new-password’ with grant option;

mysql>flush privileges;

mysql> CREATE DATABASE sheying DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

mysql> USE sheying;

mysql> source /root/web6.cn.sql  ###此处注意语句的路径

mysql> quit

3.  官网程序配置修改

3.1将官网程序解压至/usr/local/nginx/html目录下并授予相关权限

chown -R www:www /usr/local/nginx/html/

3.2配置数据库相关信息

vi /usr/local/nginx/html/Application/Conf/config.php  

//配置数据库

                //线上数据库

        'DB_TYPE'               =>      'mysql',// 数据库类型

        'DB_HOST'               =>      'localhost',// 数据库服务器地址

        'DB_NAME'               =>      'sheying',// 数据库名称

        'DB_USER'               =>      'root',// 数据库用户名

        'DB_PWD'                =>      'new-password',// 数据库密码

        'DB_PREFIX'             =>      'pre_',// 数据表前缀

        'DB_CHARSET'    =>      'utf8',// 网站编码

        'DB_PORT'               =>      '3306',// 数据库端口

posted @ 2017-02-04 09:11  FlyBack  阅读(858)  评论(0编辑  收藏  举报