系统配置
创建新用户
1 2 3 4 5 6 7 8 9
| adduser -U wluser -s /bin/bash passwd wluser passwd:xxxx
visudo ==== wluser ALL=(ALL) ALL ===== su wluser
|
导入环境变量
1 2 3 4 5
| export MAIL_SERVER=smtp.163.com export MAIL_PORT=25 export MAIL_USERNAME= export MAIL_PASSWORD= ...
|
安装python3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| $ sudo mkdir /usr/local/python3 # 创建安装目录
# 下载 Python 源文件 $ wget --no-check-certificate https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz # 注意:wget获取https的时候要加上:--no-check-certificate
$ tar -xzvf Python-3.6.0.tgz # 解压缩包
$ cd Python-3.6.0 # 进入解压目录
$ sudo ./configure --prefix=/usr/local/python3 # 指定创建的目录
$ sudo make
$ sudo make install
$ sudo ln -s /usr/local/python3/bin/python3 /usr/bin/python3
$ cd /usr/bin
$ sudo mv python python.bak
$ sudo ln -s /usr/local/python3/bin/python3 /usr/bin/python
$ sudo vim /usr/bin/yum 改为: #!/usr/bin/python2
$ sudo vim /usr/libexec/urlgrabber-ext-down 改为: #!/usr/bin/python2
# 首先安装 epel 扩展源 $ sudo yum -y install epel-release
# 安装 python-pip $ sudo yum -y install python-pip
# 清除 cache $ sudo yum clean all
|
mysql
下载安装mysql
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| # 5.6 版本 wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm wget http://repo.mysql.com/mysql-community-release-el7-7.noarch.rpm
# rpm安装源 rpm -ivh mysql-community-release-el7-7.noarch.rpm # yum安装 yum install -y mysql-server # 设置默认目录权限 chown -R wluser:wluser /var/lib/mysql # 重启mysql service mysqld restart
# 创建数据库 create database `databasename` default character set utf8 collate utf8_general_ci;
# 更改root密码 update user set password=password('qwer1234') where user='root';
# 远程登录用户 grant all privileges on *(db name).* to 'username'@'%' identified by 'qwe123' with grant option
flush privileges;
# 创建本地登录用户 use awesome; grant all privileges on megablog.* to 'john'@'localhost' identified by 'qwe123'; flush privileges;
# 重启mysql service mysql restart
|
openresty
安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| 1. 安装完以后,如果不是root安装,很容易访问首页会出现403 forbin的现象。
2. 安装依赖 sudo yum install pcre-devel openssl-devel gcc curl
3. 下载openresty
4. 解压 tar -zxvf openresty.tar.gz
5. 安装 ./configure --with-luajit \ --without-http_redis2_module \ --with-http_iconv_module \ --with-http_postgres_module gmake gmake install
|
nginx.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| events { worker_connections 1024; }
http { include mime.types; default_type application/octet-stream; #lua_shared_dict limit 50m; #lua_package_path "/opt/openresty/nginx/conf/waf/?.lua"; #init_by_lua_file "/opt/openresty/nginx/conf/waf/init.lua"; #access_by_lua_file "/opt/openresty/nginx/conf/waf/access.lua";
#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; ... # 省略的配置全部注释掉 include "/home/wluser/opt/nginx/conf/www.microblog.com.conf"; }
|
网站配置
1 2 3 4 5 6 7 8 9 10 11
| upstream microblog { server 127.0.0.1:8000; } server { listen 80; server_name www.microblog.com; location / { proxy_pass http://microblog; } }
|
gunicorn
1 2
| # 启动四个线程 gunicorn -b 127.0.0.1:8000 -w 4 run:app -D
|
总结
本来还想再上个waf的,但是出现问题,对于lua+nginx还不是太熟,就先放下了。后面继续完善