一. gogs集成包下載:
1.下載gogs?安裝包;
2.上傳gogs_**.tar.gz文件到linux服務(wù)器上
scp? /path/filename? username@servername: /path/
3. 解壓文件
tar zxvf gogs_**.tar.gz.tar.gz
二.配置app.ini文件
創(chuàng)建 custom/conf/app.ini文件 詳情參考配置手冊?
liunx 移動文件操作
Linux下移動命令是mv(move的縮寫),可以用來移動文件或者將文件改名。
命令格式:
mv?[選項]?源文件或目錄?目標文件或目錄
命令參數(shù):
-b?:若需覆蓋文件,則覆蓋前先行備份遵湖;
-f?:force?強制的意思谊囚,如果目標文件已經(jīng)存在磕谅,不會詢問而直接覆蓋锅减;
-i?:若目標文件?(destination)?已經(jīng)存在時,就會詢問是否覆蓋悴品;
-u?:若目標文件已經(jīng)存在,且?source?比較新简烘,才會更新(update)苔严。
命令實例:
將文件log1.txt,log2.txt孤澎,log3.txt移動到目錄test3中
[root@localhost?test]#?mv?log1.txt?log2.txt?log3.txt?test3
[root@localhost?test]#?cd?test3/
[root@localhost?test3]#?ll
三.安裝git
使用默認配置進行安裝届氢,如果想修改配置,可以使用 ./configure --help 來獲取幫助
$ ./configure
$ make
$ make install
2亥至、初始化配置
GIT默認安裝在 /usr/local/bin 悼沈,安裝之后可以驗證一下是否安裝好
$ whereis git
git: /usr/local/bin/git
$ git ?--version
git version 1.7.6
$ git ?--help
首先需要指定用戶名和電子郵件地址
$ git config ?--global user.name “GIT Admin”
$ git config ?--global user.emal obugs.net@gmail.com
再驗證一下配置信息
www.2cto.com
$ git config ?--list
user.name=GIT Admin
user.email=obugs.net@gmail.com
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
其實這些配置是存放在個人主目錄下的 .gitconfig 文件中的
$ cat ~/.gitconfig
[user]
name = GIT Admin
email = obugs.net@gmail.com
四.搭建mysql服務(wù)器
1、顯示數(shù)據(jù)庫
show databases;2姐扮、選擇數(shù)據(jù)庫 use數(shù)據(jù)庫名;
3絮供、顯示數(shù)據(jù)庫中的表show tables;
4、顯示數(shù)據(jù)表的結(jié)構(gòu)describe 表名;
5茶敏、顯示表中記錄SELECT*FROM表名
6壤靶、建庫createdatabse 庫名;
7、建表 createtable表名 (字段設(shè)定列表)惊搏;
mysql>createtablename(->idintauto_incrementnotnullprimarykey,->unamechar(8),->genderchar(2),->birthday date );
Query OK,0rows affected (0.03sec)
mysql>show tables;+------------------+|Tables_in_userdb|+------------------+|name|+------------------+1rowinset(0.00sec)
mysql>describe name;+----------+---------+------+-----+---------+----------------+|Field|Type|Null|Key|Default|Extra|+----------+---------+------+-----+---------+----------------+|id|int(11)|NO|PRI|NULL|auto_increment||uname|char(8)|YES||NULL|||gender|char(2)|YES||NULL|||birthday|date|YES||NULL||+----------+---------+------+-----+---------+----------------+4rowsinset(0.00sec)
注: auto_increment 自增primarykey主鍵
8贮乳、增加記錄insertintoname(uname,gender,birthday)values('張三','男','1971-10-01');
9忧换、修改記錄updatenamesetbirthday='1971-01-10'whereuname='張三';
10、刪除記錄deletefromnamewhereuname='張三';
11向拆、刪除表droptable表名
12亚茬、刪除庫dropdatabase庫名;
13、備份數(shù)據(jù)庫mysqldump-u root-p--opt 數(shù)據(jù)庫名>備份名; //進入到庫目錄
14浓恳、恢復mysql-u root-p 數(shù)據(jù)庫名<備份名;//恢復時數(shù)據(jù)庫必須存在刹缝,可以為空數(shù)據(jù)庫
15、數(shù)據(jù)庫授權(quán) 格式:grant select on 數(shù)據(jù)庫.* to 用戶名@登錄主機 identified by "密碼"
例1颈将、增加一個用戶user001密碼為123456梢夯,讓他可以在任何主機上登錄,并對所有數(shù)據(jù)庫有查詢晴圾、插入颂砸、修改、刪除的權(quán)限死姚。首先用以root用戶連入MySQL人乓,然后鍵入以下命令:
mysql>grantselect,insert,update,deleteon*.*touser001@"%" Identifiedby"123456";
例2、增加一個用戶user002密碼為123456,讓此用戶只可以在localhost上登錄,也可以設(shè)置指定IP知允,并可以對數(shù)據(jù)庫test進行查詢撒蟀、插入、修改温鸽、刪除的操作 (localhost指本地主機保屯,即MySQL數(shù)據(jù)庫所在的那臺主機)
//這樣用戶即使用知道user_2的密碼,他也無法從網(wǎng)上直接訪問數(shù)據(jù)庫涤垫,只能通過MYSQL主機來操作test庫姑尺。
//首先用以root用戶連入MySQL,然后鍵入以下命令:
mysql>grantselect,insert,update,deleteontest.*touser002@localhostidentifiedby"123456";
2.開啟服務(wù)器功能
啟動mysql的命令:server mysqlad start
/ect/init.d/mysql start (前面為mysql的安裝路徑)
重啟mysql的命令? service mysqld restart;
/ect/init.d/mysql restart (前面為mysql的安裝路徑)
關(guān)閉mysql的命令:? service mysqld stop蝠猬;
/ect/init.d/mysql shutdown (前面為mysql的安裝路徑)
3.遇到Access denied for user'root'@'localhost'(using password:YES)問題
# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’;
mysql> FLUSH PRIVILEGES;
mysql> quit
# /etc/init.d/mysql restart
# mysql -uroot -p
Enter password: <輸入新設(shè)的密碼newpassword>
5.遇到Host 'XXX' is not allowed to connect to this MySQL問題
創(chuàng)建遠程登陸用戶并授權(quán)
>grant?all?PRIVILEGES?on?discuz.*to?ted@'123.123.123.123'identified?by'123456';
上面的語句表示將 discuz 數(shù)據(jù)庫的所有權(quán)限授權(quán)給 ted 這個用戶切蟋,允許 ted 用戶在 123.123.123.123 這個 IP 進行遠程登陸,并設(shè)置 ted 用戶的密碼為 123456 榆芦。
下面逐一分析所有的參數(shù):
all PRIVILEGES 表示賦予所有的權(quán)限給指定用戶柄粹,這里也可以替換為賦予某一具體的權(quán)限,例如:select,
insert ,update ,delete ,create,drop 等匆绣,具體權(quán)限間用“,”半角逗號分隔驻右。discuz.*
表示上面的權(quán)限是針對于哪個的,discuz 指的是數(shù)據(jù)庫崎淳,后面的 *
表示對于所有的表堪夭,由此可以推理出:對于全部數(shù)據(jù)庫的全部表授權(quán)為“*.*”,對于某一數(shù)據(jù)庫的全部表授權(quán)為“數(shù)據(jù)庫名.*”,對于某一數(shù)據(jù)庫的某一表授
權(quán)為“數(shù)據(jù)庫名.表名”森爽。
ted 表示你要給哪個用戶授權(quán)恨豁,這個用戶可以是存在的用戶,也可以是不存在的用戶爬迟。
123.123.123.123 表示允許遠程連接的 IP 地址橘蜜,如果想不限制鏈接的 IP 則設(shè)置為“%”即可。
123456 為用戶的密碼雕旨。
執(zhí)行了上面的語句后扮匠,再執(zhí)行下面的語句,方可立即生效凡涩。
>flush?privileges;
6安裝sequel pro
1.sequel pro 下載
2.連接mysql
六.啟動 gogs服務(wù)
1.第一次啟動 設(shè)置app.ini 中的字段為 INSTALL_LOCK = false
./gogs web
nohup ./gogs web &
2.在瀏覽器 中設(shè)置啟動配置http://host/install
使用同github