Mac 开发环境

brew install mysql@5.7 && brew link mysql@5.7 --force
mysql.server start
mysql_secure_installation mysql -uroot -p (默认密码为空,直接回车)
alter user 'root'@'localhost' identified by '新密码';(MySQL 5.7. and later)

Ubuntu 16.0.4 Swift环境配置 (下载对应环境 https://swift.org/download/ Toolchain)

#.bashrc

export SWIFT_HOME=/opt/swift
export PATH=$SWIFT_HOME/usr/bin:$PATH # source .bashrc
sudo apt-get install mysql-server mysql-client libmysqlclient-dev clang libcurl3 openssl libssl-dev uuid-dev libpython2.7-dev supervisor pkg-config libcurl4-openssl-dev

Ubuntu 16.0.4 MySQL数据库配置

基础命令:service mysql restart | service mysql start | service mysql stop

sudo mysql_secure_installation

配置项较多,如下所示:

#
VALIDATE PASSWORD PLUGIN can be used to test passwords...
Press y|Y for Yes, any other key for No: N (我的选项) #
Please set the password for root here...
New password: (输入密码)
Re-enter new password: (重复输入) #
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them...
Remove anonymous users? (Press y|Y for Yes, any other key for No) : N (我的选项) #
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network...
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y (我的选项) #
By default, MySQL comes with a database named 'test' that
anyone can access...
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N (我的选项) #
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y (我的选项)

检查mysql服务状态:

systemctl status mysql.service

显示如下结果说明mysql服务是正常的:

● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: en
Active: active (running) since Tue -- :: CST; 13min ago
Main PID: (mysqld)
Tasks: (limit: )
CGroup: /system.slice/mysql.service
└─ /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pi May :: fileplay-ecs- systemd[]: Starting MySQL Community Server...
May :: fileplay-ecs- systemd[]: Started MySQL Community Server.

在Ubuntu下MySQL缺省是只允许本地访问的,使用workbench连接工具是连不上的; 
如果你要其他机器也能够访问的话,那么需要改变/etc/mysql/my.cnf配置文件;

首先用根用户进入:直接回车

sudo mysql -uroot -p
mysql> use mysql;
mysql> flush privileges;

以root进入mysql后也可用命令给root设置密码:

GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY "";

新建数据库和用户 
用root用户新建数据和用作远程访问的用户

## 创建数据库weixx
CREATE DATABASE weixx;
## 创建用户wxx(密码654321) 并赋予其weixx数据库的所有权限
GRANT ALL PRIVILEGES ON weixx.* TO wxx@localhost IDENTIFIED BY "";

进行远程访问或控制配置

## 允许wxx用户可以从任意机器上登入mysql
GRANT ALL PRIVILEGES ON weixx.* TO wxx@"%" IDENTIFIED BY "";

$sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

这里我们注释掉这一行 #bind-address = 127.0.0.1

重启mysql
service mysql restart

mysql增大超时时间(24小时,需重启)

interactive_timeout=
wait_timeout=

mysql插入数据支持中文

#
[client]
default-character-set=utf8 [mysql]
no-auto-rehash
default-character-set=utf8 [mysqld]
character-set-server=utf8
init_connect='SET NAMES utf8'

Mysql频繁出现 Mysql mysql lost connection to server during query(同时解决设置utf8后,异端无法用utf8查看数据库【中文乱码】)

[mysqld]
skip-name-resolve

Supervisor让服务器项目后台运行

apt-get install supervisor

#没有/etc/supervisor/supervisord.conf文件,可按此方法生成

echo_supervisord_conf > /etc/supervisor/supervisord.conf 
#修改supervisor配置文件 /etc/supervisor/supervisord.conf #移至文件内容结尾 去掉 [include] 前面;
files = /etc/supervisor/conf.d/*.conf
 # script.sh 执行脚本,进入代码路径,执行命令

 cd /root/Code/PerfectTemplate
.build/debug/PerfectTemplate
# cd /etc/supervisor/conf.d, 创建并编辑 vim swiftServer.conf, swiftServer是我的文件名和program名
# ; 一定一定不能少 [program:swiftServer] ; // program name
file=/tmp/supervisor.sock ;
command=sh script.sh ; // script name
process_name=%(program_name)s ;
directory=/opt ; // script path
autorestart=unexpected ; //当进程意外被kill或出现异常时,Supervisor会自动重启该进程。
user=root ; // user name
[supervisord]
[supervisorctl]

输入supervisord -c /etc/supervisord.conf让你刚刚的配置生效.

输入supervisorctl start swiftServer启动并后台运行

输入supervisorctl status查询状态

supervisor 自启动

创建/usr/lib/systemd/system/supervisord.service文件;
写入:

# dservice for systemd (CentOS 7.0+)
# by ET-CS (https://github.com/ET-CS)
[Unit]
Description=Supervisor daemon

[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
ExecStop=/usr/bin/supervisorctl shutdown
ExecReload=/usr/bin/supervisorctl reload
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target

systemctl enable supervisord

验证一下是否为开机启动:systemctl is-enabled supervisord

supervisor 定期启动应用

Swift Perfect 服务器配置(Ubuntu16.0.4 主机、虚拟机)的更多相关文章

  1. 记录一下使用Ubuntu16.0.4配置和使用docker registry

    h1, h2, h3, h4, h5, h6, p, blockquote { margin: 5px; padding: 5; } body { font-family: "Helveti ...

  2. VirtualBox 配置虚拟网卡(桥接),实现主机-虚拟机网络互通

    记录下VirtualBox 配置虚拟网卡(桥接),实现主机-虚拟机网络互通过程,网上搜出来的比较乱,讲的不明不白,因此根据自己弄过一次,确认可行的方式,做个备份,方便日后查阅. 环境: 在Oracle ...

  3. VMware 无法连接虚拟设备ide1:0,主机上没有相对应的设备,您 要在每次开启此虚拟机时都尝试连接此虚拟设备吗?

    无法连接虚拟设备ide1:0,主机上没有相对应的设备,您 要在每次开启此虚拟机时都尝试连接此虚拟设备吗? 运行VMware,出现以上错误. ide1:0一般是虚拟机的光驱,配置默认选项是“使用物理驱动 ...

  4. #Ubuntu16.0.4 LTS 安装RabbitMQ

    1.ubuntu下安装配置rabbitmq-server服务器环境:ubuntu16.0.4(向下兼容14.0.4)软件版本:RabbitMQ 3.7.5 .Erlang 20.1.7参考文档:htt ...

  5. Linux系统下安装Angular2开发环境(Ubuntu16.0和deepin)

    说明下,以下过程都是在ubuntu16.0系统下,win系统环境下的安装过程更简单,基本上可以仿效此环境来,除了不用配置系统命令(win下自动可以),node安装是exe程序,一键安装.另外,这里面像 ...

  6. 主机 & 虚拟机 & 开发板 三者的恩爱情仇

    # 主机 & 虚拟机 & 开发板 > 三者网络连通性,使用ping命令检测 @ Bridge 模式 ## 主机 & 虚拟机 主机与虚拟机相当于一个网络里的两台主机,都有各 ...

  7. 虚拟机ubuntu16.0 安装 mysql 主机配置访问

    在bantu服务器中安装如下命令 sudo apt-get install mysql-server    sudo apt-get install mysql-client安装成功之后 进入配置文件 ...

  8. (转载)虚拟机出现无法连接虚拟设备sata0:0,因为主机上没有相应设备

    虚拟主机需要镜像文件, 如果是拷贝的虚拟机,还需要桥接联网的话,更改mac地址,

  9. 使用Azure的GPU系列虚拟机Ubuntu-16.0.4安装GPU驱动并使用Tensorflow-GPU的过程。

    1.source activate python362.source activate tensorflow-gpu3.pip install tensorflow-gpu(提示安装的这个版本:ten ...

随机推荐

  1. 关于request.getServletContext()方法报错的问题

    可以通过修改pom文件来添加一个javax.servlet-api-3.1.0.jar的jar包,找到你的pom.xml文件添加代码如下: <dependency> <groupId ...

  2. 学习Pytbon第七天,集合

    list_1=[5,22,2,6,5,66,6,8] list_1=set(list_1)#把列表转成集合,天生不允许 重复 print(list_1,type(list_1) list_2=set( ...

  3. Android开发——JVM、Dalvik以及ART的区别

    )预编译也可以明显改善电池续航,因为应用程序每次运行时不用重复编译了,从而减少了 CPU 的使用频率,降低了能耗.

  4. COGS:313. [POI2001] 和平委员会

    313. [POI2001] 和平委员会 ★★☆   输入文件:spo.in   输出文件:spo.out   评测插件时间限制:1 s   内存限制:128 MB 题目描述 根据宪法,Bytelan ...

  5. 基础_String

    String str1="hello"; String str2="hello"; String str3="hello"; String ...

  6. Java EnumSet工作原理初窥

    EnumSet是Java枚举类型的泛型容器,Java既然有了SortedSet.TreeSet.HashSet等容器,为何还要多一个EnumSet<T>呢?答案肯定是EnumSet有一定的 ...

  7. MongoDB快速入门学习笔记8 MongoDB的java驱动操作

    import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; import org.bson.D ...

  8. python-生成器迭代器及递归调用

    生成器是一个可迭代的对象,它的执行会记住上一次返回时在函数体中的位置.对生成器第二次(或第 n 次)调用跳转至该函数上次执行位置继续往下执行,而上次调用的所有局部变量都保持不变. 生成器的特点:1.生 ...

  9. PHP 如何在txt里查找包含某个字符串的那一行?

    <?php $handler=fopen("1.txt","r"); while(!feof($handler)) { $m = fgets($handl ...

  10. jquery使用ajax传内容到asp.net乱码解决【转】

    转自:http://www.cnblogs.com/qiantuwuliang/archive/2009/08/02/1537160.html#undefined Jquery强大的功能越来越收到广大 ...