首页 > CentOS > 阿里云CentOS6 安装wordpress博客(Tengine-2.0.3+MySQL5.1.73+PHP5.3.3)
2014
07-29

阿里云CentOS6 安装wordpress博客(Tengine-2.0.3+MySQL5.1.73+PHP5.3.3)

1、安装jemalloc-3.6.0

因为在tengine 中使用的内存库是jemalloc 所以要安装这个库 官方网址 http://www.canonware.com/
[root@iZ2832ssdf5Z tmp]# wget http://www.canonware.com/download/jemalloc/jemalloc-3.6.0.tar.bz2
[root@iZ2832ssdf5Z tmp]# tar xf jemalloc-3.6.0.tar.bz2
[root@iZ2832ssdf5Z tmp]# cd jemalloc-3.6.0
[root@iZ2832ssdf5Z jemalloc-3.6.0]# ./configure
[root@iZ2832ssdf5Z jemalloc-3.6.0]# make && make install
[root@iZ2832ssdf5Z jemalloc-3.6.0]# echo ‘/usr/local/lib’ > /etc/ld.so.conf.d/local.conf
加载配置文件
[root@iZ2832ssdf5Z jemalloc-3.6.0]# ldconfig
查看是否加载成功
[root@iZ2832ssdf5Z jemalloc-3.6.0]# lsof -n | grep jemalloc
bash 23705 root cwd DIR 202,1 4096 406790 /tmp/jemalloc-3.6.0
lsof 28155 root cwd DIR 202,1 4096 406790 /tmp/jemalloc-3.6.0
grep 28156 root cwd DIR 202,1 4096 406790 /tmp/jemalloc-3.6.0
lsof 28157 root cwd DIR 202,1 4096 406790 /tmp/jemalloc-3.6.0

2、安装Tengine-2.0.3

下载tengine
[root@iZ2832ssdf5Z tmp]# wget http://tengine.taobao.org/download/tengine-2.0.3.tar.gz
[root@iZ2832ssdf5Z tmp]# tar xf tengine-2.0.3.tar.gz
[root@iZ2832ssdf5Z tmp]# cd tengine-2.0.3
添加www用户和组
[root@iZ2832ssdf5Z tengine-2.0.3]# groupadd www
[root@iZ2832ssdf5Z tengine-2.0.3]# useradd -g www www
安装编译依赖的库
[root@iZ2832ssdf5Z tengine-2.0.3]# yum -y install pcre-devel openssl-devel libxslt-devel gd-devel GeoIP-devel
[root@iZ2832ssdf5Z tengine-2.0.3]# ./configure –prefix=/usr –conf-path=/etc/nginx/nginx.conf –error-log-path=/var/log/nginx/error.log –http-client-body-temp-path=/var/tmp/nginx/body –http-fastcgi-temp-path=/var/tmp/nginx/fastcgi –http-log-path=/var/log/nginx/access.log –http-proxy-temp-path=/var/tmp/nginx/proxy –http-scgi-temp-path=/var/tmp/nginx/scgi –http-uwsgi-temp-path=/var/tmp/nginx/uwsgi –lock-path=/var/lock/nginx.lock –pid-path=/var/run/nginx.pid –with-http_concat_module –with-http_addition_module –with-http_dav_module –with-http_geoip_module –with-http_gzip_static_module –with-http_image_filter_module –with-http_realip_module –with-http_stub_status_module –with-http_ssl_module –with-http_sub_module –with-http_xslt_module –with-pcre –with-sha1=/usr/include/openssl –with-md5=/usr/include/openssl –with-mail –with-mail_ssl_module –with-jemalloc –user=www –group=www –with-cc-opt=”-O3″ –with-cpu-opt=opteron
[root@iZ2832ssdf5Z tengine-2.0.3]# make && make install
测试是否OK
[root@iZ2832ssdf5Z tengine-2.0.3]# nginx -t
[emerg]: mkdir() “/var/tmp/nginx/body” failed (2: No such file or directory)
上面提示创建文件夹失败,要先手动创建/var/tmp/nginx目录
[root@iZ2832ssdf5Z tengine-2.0.3]# mkdir /var/tmp/nginx
再次测试OK了。
[root@iZ2832ssdf5Z tengine-2.0.3]# nginx -t
the configuration file /etc/nginx/nginx.conf syntax is ok
configuration file /etc/nginx/nginx.conf test is successful
添加nginx服务
[root@iZ2832ssdf5Z tengine-2.0.3]# 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:      /etc/nginx/nginx.conf
# config:      /etc/sysconfig/nginx
# pidfile:     /var/run/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/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/etc/nginx/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs() {
   # make required directories
   user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
   options=`$nginx -V 2>&1 | grep 'configure arguments:'`
   for opt in $options; do
       if [ `echo $opt | grep '.*-temp-path'` ]; then
           value=`echo $opt | cut -d "=" -f 2`
           if [ ! -d "$value" ]; then
               # echo "creating" $value
               mkdir -p $value && chown -R $user $value
           fi
       fi
   done
}
start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    make_dirs
    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
    sleep 1
    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

[root@iZ2832ssdf5Z tengine-2.0.3]# chmod +x /etc/rc.d/init.d/nginx
[root@iZ2832ssdf5Z tengine-2.0.3]# chkconfig –add nginx
[root@iZ2832ssdf5Z tengine-2.0.3]# chkconfig nginx on
[root@iZ2832ssdf5Z tengine-2.0.3]# chkconfig –list|grep nginx
nginx 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭

 2、安装MySQL\PHP

安装php扩展和mysql-server
[root@iZ2832ssdf5Z tengine-2.0.3]# yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-eaccelerator php-fpm mysql-server
设置mysql密码第一次安装是空密码直接回车
[root@iZ2832ssdf5Z tengine-2.0.3]# mysql -uroot -p
mysql> set password for ‘root’@’localhost’ = password(‘youpassword’);
添加mysqld到开机项
[root@iZ2832ssdf5Z tengine-2.0.3]# chkconfig –level 35 mysqld on
添加php-fpm到开机项
[root@iZ2832ssdf5Z tengine-2.0.3]# chkconfig –level 35 php-fpm on
[root@iZ2832ssdf5Z tengine-2.0.3]# vi /etc/php-fpm.d/www.conf #修改user,group 为www用户

; RPM: apache Choosed to be able to access some dir as httpd
user = www
; RPM: Keep a group allowed to write in log dir.
group = www

[root@iZ2832ssdf5Z tengine-2.0.3]# cat /etc/nginx/nginx.conf #配置文件如下

user  www www;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}

# load modules compiled as Dynamic Shared Object (DSO)
#
#dso {
#    load ngx_http_fastcgi_module.so;
#    load ngx_http_rewrite_module.so;
#}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

     gzip  on;
     gzip_min_length  1k;
     gzip_buffers     4 8k;
     gzip_http_version 1.1;
     gzip_types       text/plain application/x-javascript text/css application/xml;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /data/www;
            index  index.html index.htm index.php;
            include wordpress.conf;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           /data/www;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

[root@iZ2832ssdf5Z tengine-2.0.3]# vi /etc/nginx/wordpress.conf #添加wordpress nginx伪静态配置

rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
if (!-e $request_filename) {
rewrite ^.+?(/wp-.*) $1 last;
rewrite ^.+?(/.*\.php)$ $1 last;
rewrite ^ /index.php last;
}

[root@iZ2832ssdf5Z ~]# vi /etc/sysconfig/iptables #添加防火墙规则

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

[root@iZ2832ssdf5Z ~]# chkconfig –level 35 iptables on #添加开机启动

然后重起一下服务器,IE打开,正常,完工!

然后可以新建一个phpinfo.php代码如下

<?php 
  phpinfo();
?>

然后再次访问正常

下载并安装wordpress

[root@iZ2832ssdf5Z tengine-2.0.3]# mkdir -p /data/www/
[root@iZ2832ssdf5Z tengine-2.0.3]# cd /data/www/
[root@iZ2832ssdf5Z www]# wget http://cn.wordpress.org/wordpress-3.9-zh_CN.tar.gz
[root@iZ2832ssdf5Z www]# tar xf wordpress-3.9-zh_CN.tar.gz
[root@iZ2832ssdf5Z www]# mv wordpress/* .

然后再IE打开服务器IP安装wordpress安装比简单可以参考以下链接
http://jingyan.baidu.com/article/47a29f24073b26c0142399d6.html

 

Tengine 官方 http://tengine.taobao.org/

 

最后编辑:
作者:dnybz
这个作者貌似有点懒,什么都没有留下。