zoukankan      html  css  js  c++  java
  • OpenResity + nginx + mysq配置

    一、mySQL的安装和环境变量的配置                    

    一、安装

    网址:https://dev.mysql.com/downloads/mysql/

    密码:2017-08-10T01:05:56.945560Z 1 [Note] A temporary password is generated for root@localhost: pb6T.Zou6S*/If you lose this password, please consult the section How to Reset the Root Password in the MySQL reference manual.
    以上的安装结束之后的弹框内容(其中的密码是随机数),密码为 pb6T.Zou6S*/

    重置密码:把密码改为root

    alias mysql=/usr/local/mysql/bin/mysql
    alias mysqladmin=/usr/local/mysql/bin/mysqladmin

     

    mysqladmin -u root -p password 'root'

    此时会让你输入旧密码,则输入: pb6T.Zou6S*/

    密码修改成功,然后用新密码登录:mysql -u root -p 回车输入新密码

     

    二、环境变量配置

    1. 打开终端,输入: cd  ~  // 会进入~文件夹

    2. 然后输入:sudo vim .bash_profile   回车执行,需要输入root用户密码。sudo是使用root用户修改环境变量文件。
    3. 在文档的输入:export PATH=${PATH}:/usr/local/mysql/bin  然后esc退出insert状态,并在最下方输入:wq保存退出。
    4. 输入:source .bash_profile  回车执行,运行环境变量。
    5.  再输入mysql,即可使用。
    6.  上面的做法每次关掉终端在打开都需要重新source .bash_profile。于是 vi ~/.zshrc,在这里面添加了:

      export PATH=${PATH}:/usr/local/mysql/bin

      保存后 source ~/.zshrc 

      这样的话就可以一劳永逸了。

    7.  有的文章中提到修改~/.bashrc,如果系统是zsh的修改bashrc是无效的。 

    二、OpenResty的安装和环境变量的配置             

    一、安装Homebrew

    网址:https://brew.sh/index_zh-cn.html

    执行脚本:/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

    二、安装OpenResty

    网址:http://openresty.org/en/download.html

    网址:brew install homebrew/nginx/openresty

    三、OpenResty环境变量配置

    参考mysql的配置

    也可以把两个配置写在一起

    vi ~/.bash_profile

    export PATH=$PATH:/usr/local/mysql/bin:/usr/local/opt/openresty/bin:/usr/local/opt/openresty/nginx/sbin export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH

    三、开始一个OpenResty服务                            

    建立一个test 目录 ,目录下包含conf,log,lua文件夹,在conf文件下新建nginx.conf文件

    文件内容为:

    worker_processes  1;
    error_log logs/error.log;
    events {
        worker_connections 1024;
    }
    http {
        server {
            listen 8080;
            location / {
                default_type text/html;
                content_by_lua '
                    ngx.say("<p>hello, world</p>")
                ';
            }
        }
    }

    在iTerm中进入test文件夹

    运行: nginx -p `pwd`/ -c conf/nginx.conf

    重启:nginx -p `pwd`/ -c conf/nginx.conf -s reload

    退出:ps -ef | awk '/nginx: master process nginx/{print $2}' | xargs kill

    也可以通过关闭该端口号的进程

    lsof -i tcp: 8080 // 8080端口的任务进程

    然后根据PID杀进程:

    sudo kill -9 231  2324 // 231和2324为PID

    或者

    nginx -s reload  :修改配置后重新加载生效

    三、模块介绍                                                    

    mysql模块:https://github.com/openresty/lua-resty-mysql

    Http模块:https://github.com/pintsized/lua-resty-http

    WebSocket模块:https://github.com/openresty/lua-resty-websocket

    Redis模块:https://github.com/openresty/lua-resty-redis

    String模块:https://github.com/openresty/lua-resty-string

    四、参考文档                                                    

    10.1) Wiki,该Wiki有所有nginx lua的各种模块,方法的列表 https://www.nginx.com/resources/wiki/modules/lua/

    10.2) Github上关于nginx lua的详细介绍 https://github.com/openresty/lua-nginx-module

    10.3) Facebook官方关于React的介绍与教程 https://facebook.github.io/react/docs/hello-world.html

    https://facebook.github.io/react/tutorial/tutorial.html

  • 相关阅读:
    c#无边框窗体移动 屏蔽双击最大化
    怎么样让代码都带有注释?
    权限设置相关,利用Microsoft.Win32.Security
    计算几何常用算法概览[转]
    VS 常见快捷键
    关于读取txt文件的分段问题
    ajax 常用方法
    文件以附件形式下载的方法
    半角和全角互换
    在ubuntu 中安装 jsdoc
  • 原文地址:https://www.cnblogs.com/taryn/p/7339624.html
Copyright © 2011-2022 走看看