码迷,mamicode.com
首页 > Web开发 > 详细

LNMP+Xcache+Discuz

时间:2016-12-25 02:21:08      阅读:429      评论:0      收藏:0      [点我收藏+]

标签:lnmp+xcache+discuz

[root@node1 ~]# yum groupinstall "Development Tools" "Server Platform Development" -y


[root@node1 ~]# yum -y install pcre-devel


www.nginx.org 下载nginx的压缩包

[root@node1 tool]# du -sh nginx-1.10.2.tar.gz 

892Knginx-1.10.2.tar.gz

[root@node1 tool]# tar -xf nginx-1.10.2.tar.gz 

[root@node1 tool]# cd nginx-1.10.2

[root@node1 nginx-1.10.2]# ll

total 692

drwxr-xr-x. 6 1001 1001   4096 Dec 23 13:00 auto

-rw-r--r--. 1 1001 1001 264254 Oct 18 23:03 CHANGES

-rw-r--r--. 1 1001 1001 402997 Oct 18 23:03 CHANGES.ru

drwxr-xr-x. 2 1001 1001   4096 Dec 23 13:00 conf

-rwxr-xr-x. 1 1001 1001   2481 Oct 18 23:03 configure

drwxr-xr-x. 4 1001 1001   4096 Dec 23 13:00 contrib

drwxr-xr-x. 2 1001 1001   4096 Dec 23 13:00 html

-rw-r--r--. 1 1001 1001   1397 Oct 18 23:03 LICENSE

drwxr-xr-x. 2 1001 1001   4096 Dec 23 13:00 man

-rw-r--r--. 1 1001 1001     49 Oct 18 23:03 README

drwxr-xr-x. 9 1001 1001   4096 Dec 23 13:00 src


[root@node1 nginx-1.10.2]# groupadd -g 111 nginx

[root@node1 nginx-1.10.2]# useradd -r -u 111 -g 111 nginx


[root@node1 ~]# ./configure \

>   --prefix=/usr \

>   --sbin-path=/usr/sbin/nginx \

>   --conf-path=/etc/nginx/nginx.conf \

>   --error-log-path=/var/log/nginx/error.log \

>   --http-log-path=/var/log/nginx/access.log \

>   --pid-path=/var/run/nginx/nginx.pid  \

>   --lock-path=/var/lock/nginx.lock \

>   --user=nginx \

>   --group=nginx \

>   --with-http_ssl_module \

>   --with-http_flv_module \

>   --with-http_stub_status_module \

>   --with-http_gzip_static_module \

>   --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/ \

>   --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \

>   --http-scgi-temp-path=/var/tmp/nginx/scgi \

>   --with-pcre \

>   --with

[root@node1 nginx]# make 

[root@node1 nginx]# make install


[root@node1 nginx]# vim /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@node1 nginx]# chmod  +x /etc/rc.d/init.d/nginx 

[root@node1 nginx]# bash -n /etc/rc.d/init.d/nginx 

[root@node1 nginx]# chkconfig --add nginx

[root@node1 nginx]# chkconfig --list nginx

nginx          0:off1:off2:off3:off4:off5:off6:off

[root@node1 nginx]# service nginx start

Starting nginx:                                            [  OK  ]


技术分享

      

nginx在你安装的目录下(/usr/)创建了一个html页面


[root@node1 html]# vim /etc/nginx/nginx.conf

        location / {

            root   /web/html;

            index  index.html index.htm;

        }

"/etc/nginx/nginx.conf" 117L, 2661C            

 

[root@node1 nginx]# mkdir -pv /web/html

mkdir: created directory `/web‘

mkdir: created directory `/web/html‘

[root@node1 nginx]# cd /web/html/

[root@node1 html]# vim index.html

 

<h1> My Nginx_Web Server</h1>

[root@node1 html]# service nginx reload


技术分享

[root@node1 zxl]# vim /etc/nginx/nginx.conf

        location / {

            root   /web/html;

            index  index.html index.htm;

        }

        location /zxl {

            root   /web;

            index index.html index.hml;

       

[root@node1 web]# mkdir zxl

[root@node1 web]# vim zxl/index.html


[root@node1 web]# service nginx reload


<h1>www.zxl.com</h1>

技术分享

[root@node1 zxl]# vim /etc/nginx/nginx.conf

  error_page 404 /404.html;

[root@node1 zxl]# vim /web/html/404.html


<h1>error! 404</h1>

~                  

技术分享

[root@node1 zxl]# vim /etc/nginx/nginx.conf

        location / {

            root   /web/html;

            index  index.html index.htm;

            allow 192.168.139.0;

            deny 192.168.139.4;

        }


[root@node2 zxl]# curl http://192.168.139.2

<html>

<head><title>403 Forbidden</title></head>

<body bgcolor="white">

<center><h1>403 Forbidden</h1></center>

<hr><center>nginx/1.10.2</center>

</body>

</html>


Forbidden禁止访问

[root@node1 zxl]# htpasswd -c -m /etc/nginx/.users tom #此命令是httpd自带的

[root@node1 zxl]# htpasswd  -m /etc/nginx/.users jerry


[root@node1 zxl]# vim /etc/nginx/nginx.conf

        location / {

            root   /web/html;

            index  index.html index.htm;

            allow 192.168.139.0;

            deny 192.168.139.4;

            auth_basic "limit area......";

            auth_basic_user_file /etc/nginx/.users;


        }


[root@node1 zxl]# service nginx reload


技术分享


[root@node1 zxl]# vim /etc/nginx/nginx.conf

  location /status {

               stub_status on;

         }

[root@node1 zxl]# service nginx reload


技术分享

Active connections: 1 当前活动连接数 1
server accepts handled requests
 9 9 53 服务器接受了9个连接,服务器共处理了9个连接,共接受了53个请求(一个长连接可能多个请求)
Reading: 0 Writing: 1 Waiting: 0 
  Nginx正在读首部的请求个数
  正在处理请求的主体的请求个数,或正在想client发送响应的个数
  处于长连接的连接个数


定义基于域名的

虚拟主机

[root@node1 zxl]# vim /etc/nginx/nginx.conf

 server {

        listen       80;

        server_name  localhost; #为原来的server加一个域名


            server_name www.b.org;

      }

再定义一个server便可

server {

              listen 80;

              server_name www.a.org;

              location / {

                    root /web/a.org;

                    index index.html;

            }

[root@node1 zxl]# service nginx reload

[root@node2 zxl]# vim /etc/hosts

192.168.139.2 www.a.org

192.168.139.2 www.b.org

[root@node2 zxl]# curl http://www.a.org/index.html

<h1>www.a.org</h1>

[root@node2 zxl]# curl http://www.b.org/index.html

<h1> My Nginx_Web Server</h1>


创建LNMP: PHP+Msql


[root@node1 ~]# groupadd mysql

[root@node1 ~]# useradd -g mysql mysql

[roqot@node1 ~]# mkdir /mydata/data -p

[root@node1 ~]# chown -R mysql:mysql /mydata/data

[root@node1 ~]# cd /tool

[root@node1 tool]# tar -xf mysql-5.6.34.tar.gz 

[root@node1 tool]# cd mysql-5.6.34

 

[root@node1 mysql-5.6.34]# 

  

cmake \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_DATADIR=/usr/local/mysql/data \

-DSYSCONFDIR=/etc \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=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


[root@node1 mysql-5.6.34]# make && make install

[root@node1 mysql]# chown -R mysql:mysql ./*

[root@node1 mysql]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data

[root@node1 mysql]# chown -R root /usr/local/mysql/* 

[root@node1 mysql]# cp support-files/mysql.server /etc/init.d/mysqld 

[root@node1 mysql]# chkconfig --add mysql

[root@node1 mysql]# service mysqld start

[root@node1 mysql]# /usr/local/mysql/bin/mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.6.34-log Source distribution


Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.


Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.


mysql> \q

Bye

[root@node1 mysql]# 

[root@node1 mysql]# vim /etc/ld.so.conf.d/mysql-x86_64.conf 

/usr/local/mysql/lib

[root@node1 mysql]# ldconfig  -v

[root@node1 lib64]# ln -sv /usr/local/mysql/include/ /usr/include/mysql

`/usr/include/mysql‘ -> `/usr/local/mysql/include/‘

[root@node1 mysql]# vim /etc/man.config

MANPATH /usr/local/mysql/man

[root@node1 mysql]# vim /etc/profile.d/mysql.sh


exportPATH=$PATH:/usr/local/mysql/bin

[root@node1 mysql]# source /etc/profile



[root@node2 mysql]# yum -y install libmcrypt libmcrypt-devel mhash mhash-devel mcrypt

[root@node1 tool]# tar -xf php-5.3.27.tar.bz2 

[root@node1 php-5.3.27]# yum -y install libxml2-devel

[root@node1 php-5.3.27]# yum install -y libcurl-devel

[root@node1 php-5.3.27]# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql/ --with-openssl --enable-fpm --enable-sockets --enable-sysvshm --with-mysql=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-libxml-dir=/usr --enable-xml --with-mhash --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --with-curl


如果出现如下错误

configure: error: Cannot find libmysqlclient under /usr

[root@node1 php-5.3.27]#cp /usr/lib64/mysql/libmysqlclient.so.15.0.0 /usr/lib/libmysqlclient.so

PHP 默认是去 /usr/lib/ 搜索 libmysqlclient.so 这个文件,搜不到就报那个错误。cp 一个过去就行了。

 

看到下面这个,说明PHP配置成功


+--------------------------------------------------------------------+

| License:                                                           |

| This software is subject to the PHP License, available in this     |

| distribution in the file LICENSE.  By continuing this installation |

| process, you are bound by the terms of this license agreement.     |

| If you do not agree with the terms of this license, you must abort |

| the installation process at this point.                            |

+--------------------------------------------------------------------+


Thank you for using PHP.

[root@node1 php-5.3.27]# make && make install

/tool/php-5.3.27/sapi/cli/php: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory

make: *** [ext/phar/phar.php] Error 127

[root@node1 php-5.3.27]# vim /etc/ld.so.conf.d/mysql-x86_64.conf 


/usr/local/mysql/lib

/usr/lib64/mysql

/usr/local/lib


[root@node1 php-5.3.27]# ldconfig -v

[root@node1 php-5.3.27]# make && make install

make install时出现以下错误

cp: cannot stat `ext/phar/phar.phar‘: No such file or directory

make: *** [install-pharcmd] Error 1

解决如下

[root@node1 php-5.3.27]# cd ext/phar/

[root@node1 phar]# cp ./phar.php ./phar.phar

继续

[root@node1 php-5.3.27]# make install

OK!终于成功了


[root@node1 php-5.3.27]# cp php.ini-production /etc/php.ini

[root@node1 php-5.3.27]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

[root@node1 php-5.3.27]# chmod +x /etc/init.d/php-fpm 

[root@node1 php-5.3.27]# chkconfig --add php-fpm

[root@node1 php-5.3.27]# chkconfig php-fpm  on

[root@node1 php-5.3.27]# cd /usr/local/php

[root@node1 php]# ls

bin  etc  include  lib  man  sbin  share  var

[root@node1 php]# cd etc/

[root@node1 etc]# ls

pear.conf  php-fpm.conf.default

[root@node1 etc]# cp php-fpm.conf.default php-fpm.conf

[root@node1 etc]# vim /usr/local/php/etc/php-fpm.conf

pm.max_children = 150

pm.start_servers = 8

pm.min_spare_servers = 5

pm.max_spare_servers = 10

pid = /usr/local/php/var/run/php-fpm.pid


[root@node1 etc]# service php-fpm start

Starting php-fpm  done

[root@node1 etc]#  ps aux | grep php-fpm

root      34955  0.4  0.9 102272  4420 ?   Ss   23:22   0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)                                                                    

nobody    34956  0.0  0.7 102272  3568 ?     S    23:22   0:00 php-fpm: pool www                                                                                                            

nobody    34957  0.0  0.7 102272  3568 ?     S    23:22   0:00 php-fpm: pool www                                                                                                            

nobody    34958  0.0  0.7 102272  3568 ?     S    23:22   0:00 php-fpm: pool www                                                                                                            

nobody    34959  0.0  0.7 102272  3568 ?     S    23:22   0:00 php-fpm: pool www                                                                                                            

nobody    34960  0.0  0.7 102272  3568 ?     S    23:22   0:00 php-fpm: pool www                                                                                                            

nobody    34961  0.0  0.7 102272  3568 ?     S    23:22   0:00 php-fpm: pool www                                                                                                            

nobody    34962  0.0  0.7 102272  3568 ?     S    23:22   0:00 php-fpm: pool www                                                                                                            

nobody    34963  0.0  0.7 102272  3572 ?     S    23:22   0:00 php-fpm: pool www                                                                                                            

root      34965  3.0  0.1 103316   884 pts/0  S+   23:23   0:00 grep php-fpm


php安装配置完成,进行PHP和Nginx结合

[root@node1 etc]# cd /etc/nginx/

[root@node1 nginx]# vim nginx.conf

  location ~ \.php$ {

            root           /web/html;

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

            include        fastcgi_params;

        }


[root@node1 nginx]# vim fastcgi_params


#pid = /usr/local/php/var/run/php-fpm.pid

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;

fastcgi_param  SERVER_SOFTWARE    nginx;

fastcgi_param  QUERY_STRING       $query_string;

fastcgi_param  REQUEST_METHOD     $request_method;

fastcgi_param  CONTENT_TYPE       $content_type;

fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;

fastcgi_param  REQUEST_URI        $request_uri;

fastcgi_param  DOCUMENT_URI       $document_uri;

fastcgi_param  DOCUMENT_ROOT      $document_root;

fastcgi_param  SERVER_PROTOCOL    $server_protocol;

fastcgi_param  REMOTE_ADDR        $remote_addr;

fastcgi_param  REMOTE_PORT        $remote_port;

fastcgi_param  SERVER_ADDR        $server_addr;

fastcgi_param  SERVER_PORT        $server_port;

fastcgi_param  SERVER_NAME        $server_name;

在主页面下加入index.php


[root@node1 nginx]# vim nginx.conf

   location / {

            root   /web/html;

       index.php  index  index.html index.htm;


        }


[root@node1 html]# cd /web/html

[root@node1 html]# mv index.html index.html.bak

[root@node1 html]# vim index.php


<h1> My Nginx_Web Server</h1>

<?php

phpinfo();

?>

[root@node1 html]# service nginx reload


技术分享

http://xcache.lighttpd.net/ 


http://jiayimeng.blog.51cto.com/

[root@node1 xcache-3.2.0]tar xf xcache-3.0.3.tar.gz

[root@node1 xcache-3.2.0]cd xcache-3.0.3

[root@node1 xcache-3.2.0]/usr/local/php/bin/phpize

[root@node1 xcache-3.2.0]./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config

[root@node1 xcache-3.2.0]make 

Build complete.

Don‘t forget to run ‘make test‘.


[root@node1 xcache-3.2.0]make text

Thank you for helping to make PHP better.


[root@node1 xcache-3.2.0]make install

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/

 

zend_extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/xcache.so

[root@node1 xcache-3.2.0]# mkdir /etc/php.d

[root@node1 xcache-3.2.0]#  cp xcache.ini /etc/php.d

[root@node1 xcache-3.2.0]# vim /etc/php.d/xcache.ini 

在[xcache-common]下加入:

extension  = /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/xcache.so

[root@node1 xcache-3.2.0]# service php-fpm restart

Gracefully shutting down php-fpm . done

Starting php-fpm [24-Dec-2016 21:41:10] NOTICE: PHP message: PHP Warning:  Module ‘XCache‘ already loaded in Unknown on line 0

 done

技术分享

Xcache与PHP结合完成


测试php与mysql是否结合

[root@node1 ~]# vim /web/html/index.php 


<h1> My Nginx_Web Server</h1>

<?php

$link=mysql_connect(‘localhost‘,‘root‘,‘‘);

if(!$link) echo "<h1>Link Fail</h1>";

else echo "<h1>Link Success</h1>";

mysql_close();

?>

[root@node1 html]# service nginx restart

技术分享

Mysql与PHP结合完成

安装Discuz论坛

http://www.discuz.net/forum.php


mysql>  GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘192.168.%.%‘ IDENTIFIED BY ‘123456‘;

Query OK, 0 rows affected (0.18 sec)


[root@node1 tool]# unzip Discuz_X3.2_SC_GBK_\(1\).zip 

复制到你的web主页面下

[root@node1 tool]# mv upload/* /web/html/

接下来直接进行浏览器web界面安装


技术分享

技术分享

技术分享

技术分享

技术分享

技术分享


OK!LNMP+Xcache+Discuz安装配置完成

技术分享



LNMP+Xcache+Discuz

标签:lnmp+xcache+discuz

原文地址:http://11107124.blog.51cto.com/11097124/1885867

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!