zoukankan      html  css  js  c++  java
  • LNMP-day2-进阶


    部署LNMP环境

    http://www.cnblogs.com/wazy/p/8386493.html

    安装部署wordpress

    #下载wordpress
    [root@locahost downloads]# pwd
    /tmp/downloads
    [root@locahost downloads]# wget https://cn.wordpress.org/wordpress-4.9.1-zh_CN.tar.gz
    
    #安装和部署
    [root@locahost downloads]# tar zxf wordpress-4.9.1-zh_CN.tar.gz
    [root@locahost downloads]# rm -rf /var/www/html/*
    
    #配置nginx
    ##nginx.conf
    ################################################
    user  nginx nginx;
    worker_processes  8;
    
    error_log  /var/log/nginx/nginx_error.log crit;
    pid        /var/run/nginx.pid;
    worker_rlimit_nofile 65535;
    
    events {
        use epoll;
        worker_connections  65535;
    }
    
    
    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  60;
        tcp_nodelay on;
    
        fastcgi_connect_timeout    300;
        fastcgi_send_timeout    300;
        fastcgi_read_timeout    300;
        fastcgi_buffer_size    64k;
        fastcgi_buffers 4 64k;
        fastcgi_busy_buffers_size 128k;
        fastcgi_temp_file_write_size 128k;
    
        gzip on;
        gzip_min_length  1k;
        gzip_buffers 4 16k;
        gzip_http_version 1.0;
        gzip_comp_level 2;
        gzip_types  text/plain  application/x-javascript  text/css  application/xml;
        gzip_vary  on;
    
        include extra/www.conf;
    }
    ################################################
    
    ##www.conf
    server {
        listen    80;
        server_name    www.daniel.org;
        index    index.html index.php index.htm;
        root    /var/www/html/;
        location ~.*.(php|php5)?$ {
            fastcgi_pass    127.0.0.1:9000;
            fastcgi_index    index.php;
            include    fastcgi.conf;
        }
        location ~.*.(gif|jpg|jpeg|png|bmp|swf)$ {
            expires    365d;
        }
        location ~.*.(js|css)?$ {
            expires    365d;
        }
        access_log  /var/log/nginx/www_access.log   main;
        error_log    /var/log/nginx/www_error.log   error;
    }
    
    [root@locahost downloads]# /usr/local/nginx/sbin/nginx -s reload
    [root@locahost downloads]# chown -R nginx.nginx /var/www/html/ #给权限
    
    #Mysql配置
    mysql> drop database test;  #test库不安全,删掉
    Query OK, 0 rows affected (0.09 sec)
    
    mysql> create database wordpress;   #创建数据库wordpress
    Query OK, 1 row affected (0.00 sec)
    
    mysql> grant create,select,insert,update,delete,drop on wordpress.* to 'wordpress'@'localhost' identified by '123456'; #创建授权用户并授权
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> flush privileges; #强制生效
    Query OK, 0 rows affected (0.00 sec)
    
    #然后网页访问本机IP即可,http://IP,根据提示安装wordpress
    
    
    #站点用户安全注意事项
    #默认所有站点的目录权限为755,文件644,对于用户上传的目录我设置为web用户的权
    
    [root@locahost html]# chown -R root.root /var/www/html/#为了安全仅给所有程序root属主与用户
    [root@locahost html]# find ./ -type f|xargs chmod 644
    [root@locahost html]# find ./ -type d|xargs chmod 755
    [root@locahost html]# chown -R nginx.nginx wp-content/uploads/ #授权上传文件目录,如果是集群uploads可能要放在公共存储上

    实战配置开源产品blog程序伪静态功能

    #先在站点中的设置>固定链接>自定义结构中加上/archives/%post_id%.html,并且保存更改
    
    #配置nginx支持伪静态
    #将以下字段加入server段中(也就是www.conf中)
        location / {
            if (-f $request_filename/index.html) {
                rewrite (.*) $1/index.html break;
            }
            if (-f $request_filename/index.php) {
                rewrite (.*) $1/index.php;
            }
            if (!-f $request_filename) {
                rewrite (.*) /index.php;
            }
    
    [root@locahost nginx]# ./sbin/nginx -s reload
    #再次访问即可
    

      

    免编译方式安装配置Mysql5.5.32数据库

    #再开一台虚拟机来模拟web站点连接不同服务器的mysql服务
    
    #安装
    
    #依赖安装
    [root@mysql-master downloads]# yum install -y libaio-devel ncurses-devel
    
    #mysql软件安装
    [root@mysql-master downloads]# wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.32-linux2.6-x86_64.tar.gz --no-check-certificate
    [root@mysql-master downloads]# tar zxf mysql-5.5.32-linux2.6-x86_64.tar.gz #解压
    [root@mysql-master downloads]# mkdir /application #为软件创建软件目录,方便统一管理
    [root@mysql-master downloads]# mkdir /data   #为数据创建数据同一目录
    [root@mysql-master downloads]# mkdir /data/mysql3306 #创建实例目录
    [root@mysql-master downloads]# mv mysql-5.5.32-linux2.6-x86_64 /application/mysql-5.5.32#移动并改名
    
    #安装后配置
    [root@mysql-master downloads]# cd /application/
    [root@mysql-master application]# ln -s mysql-5.5.32/ mysql
    [root@mysql-master application]# cd mysql
    [root@mysql-master mysql]# useradd -s /sbin/nologin -M mysql #创建用户
    [root@mysql-master mysql]# scripts/mysql_install_db --basedir=/application/mysql --datadir=/data/mysql3306 --user=mysql  #初始化数据库
    [root@mysql-master mysql]# chown -R mysql.mysql /data/mysql3306/ #授权
    [root@mysql-master mysql]# cp support-files/my-small.cnf /etc/my.cnf
    [root@mysql-master mysql]# cd support-files/
    [root@mysql-master support-files]# cp mysql.server mysqld
    [root@mysql-master support-files]# chmod +x mysqld
    [root@mysql-master support-files]# sed -i 's#/usr/local/#/application/#g' mysqld
    [root@mysql-master support-files]# sed -i 's#/application/mysql/data#/data/mysql3306#g' mysqld  #设置为启动程序,修改脚本文件
    [root@mysql-master support-files]# cp mysqld /etc/init.d/
    
    #配置mysql
    [root@mysql-master support-files]# cd ..
    [root@mysql-master mysql]# service mysqld start   #启动
    [root@mysql-mastert mysql]# ps -ef | grep mysql
    root       4026      1  0 23:18 pts/1    00:00:00 /bin/sh /application/mysql/bin/mysqld_safe --datadir=/data/mysql3306 --pid-file=/data/mysql3306/mysql-master.pid
    mysql      4411   4026  0 23:18 pts/1    00:00:00 /application/mysql/bin/mysqld --basedir=/application/mysql --datadir=/data/mysql3306 --plugin-dir=/application/mysql/lib/plugin --user=mysql --log-error=/data/mysql3306/mysql-master.err --pid-file=/data/mysql3306/mysql-master.pid --socket=/tmp/mysql.sock --port=3306
    root       4723   2217  0 23:27 pts/1    00:00:00 grep mysql 
    #查看具体的一些信息
    
    #创建数据库,用户,授权
    [root@mysql-master mysql]# bin/mysqladmin -uroot password 1123.com #设置mysql root密码
    [root@mysql-master mysql]# ./bin/mysql -uroot -p
    Enter password: 
    
    mysql> create database wordpress;
    Query OK, 1 row affected (0.00 sec)
    
    mysql> grant create,delete,drop,update,select on wordpress.* to 'wordpress'@'172.16.50.%' identified by '123456';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)

      

    使用刚才的wordpress站点再次创建一次wordpress

     

     实战部署discuz bbs程序 

    (这个不给步骤,自己做)

    给个地址 www.discuz.net/forum.php,下载地址

    实战配置dscuz伪静态功能

    复制到bbs.conf中,然后重启nginx

    server {
        listen    80;
        server_name    bbs.daniel.org;
        index    index.php index.html index.htm;
        root    /var/www/bbs/;
        rewrite ^([^.]*)/topic-(.+).html$ $1/portal.php?mod=topic&topic=$2 last;
        rewrite ^([^.]*)/article-([0-9]+)-([0-9]+).html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
        rewrite ^([^.]*)/forum-(w+)-([0-9]+).html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
        rewrite ^([^.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
        rewrite ^([^.]*)/group-([0-9]+)-([0-9]+).html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
        rewrite ^([^.]*)/space-(username|uid)-(.+).html$ $1/home.php?mod=space&$2=$3 last;
        rewrite ^([^.]*)/blog-([0-9]+)-([0-9]+).html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
        rewrite ^([^.]*)/(fid|tid)-([0-9]+).html$ $1/archiver/index.php?action=$2&value=$3 last;
        rewrite ^([^.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_-]+).html$ $1/plugin.php?id=$2:$3 last;
        if (!-e $request_filename) {
            return 404;
        }
        location ~.*.(php|php5)?$ {
            fastcgi_pass    127.0.0.1:9000;
            fastcgi_index    index.php;
            include    fastcgi.conf;
        }
        location ~.*.(gif|jpg|jpeg|png|bmp|swf)$ {
            expires    365d;
        }
        location ~.*.(js|css)?$ {
            expires    365d;
        }
        access_log  /var/log/nginx/bbs_access.log   main;
        error_log    /var/log/nginx/bbs_error.log   error;
    }

  • 相关阅读:
    (五)Spring Cloud教程——Config(F版本)
    (四)Spring Cloud教程——Zuul(F版本)
    (三)Spring Cloud教程——Hystrix(F版本)
    (二)Spring Cloud教程——Ribbon 和 Feign(F版本)
    (一)Spring Cloud教程——Eureka(F版本)
    3年的坚持,最终造就著作——《Learninghard C#学习笔记》
    WPF快速入门系列(9)——WPF任务管理工具实现
    WPF快速入门系列(8)——MVVM快速入门
    [WPF实用技巧]如何使WPF的TreeView节点之间有连线
    WPF快速入门系列(7)——深入解析WPF模板
  • 原文地址:https://www.cnblogs.com/wazy/p/8399709.html
Copyright © 2011-2022 走看看