Windows环境下Linux开发环境搭建和包管理
Cygwin是windows平台上运行的unix模拟环境,Cygwin包括了一套库,该库在Win32系统下实现了POSIX系统调用的API;还有一套GNU开发工具集(比如GCC、GDB),这样可以进行简单的软件开发;还有一些UNIX系统下的常见程序
一、Cygwin的安装
1. 下载Cygwin,这个可以到这里下载 ,至于使用32位的还是64位的版本可以根据自己的系统而定,打开下载好的setup-x64.exe
注意:
1.1. 指定unix系统的根目录,以及限定那些用户可以访问这个目录。安装目录别为中文名,以免出错,接入网站如果不行,提示错误,那就重新来换一个接入网站
1.2. 选择连接方式,如果用的是外网,选择第一个(默认)即可,如果使用的是公司网或者其他需要代理的内网,记得使用相应的代理,一般如果默认浏览器有设代理,选择第二个就好,如果默认浏览器没有设代理,则使用第三项自己配置代理,【下一步】
1.3. 选择要下载和安装的包,根据你的需要选择包,选的包越多所需的下载时间越长,单击【View】可以在分类、全部、已选之间循环切换,点击每一类前面的加号可以展开,要选中每一个包,只需单击每一行前边像循环的那个图标,会在版本号和Skip之间切换,选一个最新的版本号即可,下边的那个复选框默认即可。
必要的包进行安装
(1) curl;
(2) git* (git,git-completion, git-gui, gitk);
(3) libreadline6, libiconv2;
(4) vim, ctags
(5) python;
(6) lynx
(7) wget, tar, gawk, bzip2
安装完成 查询版本:cygcheck -c cygwin
二 安装Cygwin的安装工具apt-cyg,此工具类似于Ubuntu下的apt-get工具,所有的工具都是通过他安装
去GitHub下载脚本:https://github.com/transcode-open/apt-cyg
解压刚刚下载的zip文件 复制apt-cyg 到 cygwin 安装目录下的bin文件夹下,即可安装成功
通过apt-cyg 安装vim apt-cyg install vim
给Cygwin添加more/col/whereis等命令:安装util-linux包:apt-cyg install util-linux
给Cygwin添加telnet/ftp工具:apt-cyg install inetutils
安装bind-utils包:apt-cyg install bind-utils
检查系统中已设置好DNS: ipconfig /all
Cygwin中Cygrunsrv使用说明:
cygrunsrv.exe是Cygwin/RedHat的基于Windows的GNU工具服务,用于管理window服务
cygrunsrv参数说明:
- -I: 安装服务
- -R:删除服务
- -S:启动服务
- -E:停止服务
- -Q:查询服务
- -L:显示所有服务
安装服务的参数:
- -p:指定服务程序路径
- -a:指定服务程序命令参数
- -e:指定服务程序的环境变量
- -d:服务的显示名称
三 在cmd或者powershell中可以使用Cygwin命令
在系统变量 path 中添加路径
基本常用命令详见:https://blog.csdn.net/weixin_34348111/article/details/94010646
四 Cygwin 中配置 Email
ssmtp & mutt包使用
Ssmtp
apt-cyg install ssmtp
/usr/bin/ssmtp-config
When using mutt as the mail client, add the following line to your $HOME/.muttrc file:
set sendmail="/usr/sbin/ssmtp"
Mutt
apt-cyg install mutt
Make sure you have the Cygwin ssmtp package installed
check file /etc/ssmtp/ssmtp.conf
vi .bashrc and/or .bash_profile
export MAIL=~/Mail/inbox
export EDITOR=nano
If you have nano installed (and I stongly recommend that you do)
Create the following directory structure in your HOME directory:
|
-- inbox (EMPTY FILE, NOT DIRECTORY)
|
-- sent (EMPTY FILE, NOT DIRECTORY)
|
-- received (EMPTY FILE, NOT DIRECTORY)
|
-- postponed (EMPTY FILE, NOT DIRECTORY)
Create a ~/.muttrc file that looks like this:
# The file/directory where your incoming mail will be spooled to
# (same as 'set spoolfile' below)
mailboxes ~/Mail/inbox
# Mail account setup. I know nothing about IMAP, so you're
# on your own there.
set sendmail="/usr/sbin/ssmtp"
#set pop_host="your.pop3.mail.server.com"
#set pop_last=yes
#set pop_user="your_email_username"
#set pop_pass="your_email_password"
set from="your_complete@email_address.com"
# Mail folder setup.
set folder=~/Mail
set mbox_type=mbox
set spoolfile=+inbox
set mbox=+received
set postponed=+postponed
set record=+sent
mutt command line
mutt [...] address
参数:
-a file : attach a file to message
-b address: BCC
-c address: CC
-F muttrc
-H draft: draft contain both header and body
-s subject: subject of the message
-x : emulate the mailx compose mode
环境变量:
EMAIL : user's email address
MAIL : user's spool mailbox
示例:
echo "contents" | mutt -x -s "subject" mail@address
echo | mutt -x -s "subject" -i filename mail@address
exim & minires
exim
Exim is a fully featured mail transfer agent, a drop-in replacement for sendmail.
/usr/bin/exim-config
view /etc/exim.conf
vi /etc/aliases
postmaster: your_login_name
vi /etc/reslov.conf
nameserver 10.0.0.7
search your.domain
cygrunsrv -I exim -p /usr/bin/exim -e CYGWIN=nontsec
-a "-bdf -q15m" -d "Exim Mail Transfer Agent"
-1 /var/log/exim/cygrunsrv_out.log -2 /var/log/exim/cygrunsrv_err.log
cygrunsrv -S exim