正在筛选分类:*BSD 下的文章 清除筛选 ✕
2016
11
12
17:04

freebsd设置交换swap分区

dd if=/dev/zero of=/usr/swap0 bs=1m count=128

chmod 0600 /usr/swap0

echo ‘md99 none swap sw,file=/usr/swap0 0 0’ >> /etc/fstab

swapon -aq

2016
11
12
05:05

freebsd挂载ntfs格式硬盘

cd /usr/ports/sysutils/fusefs-ntfs && make BATCH=yes install clean
or
pkg install fusefs-ntfs
Then add to /boot/loader.conf

fuse_load=”YES”
Now run it:

/usr/local/etc/rc.d/fusefs start

Now – make dir for NTFS partition, for example:

mkdir /mnt/ntfs

Now – you can mount your NTFS in rw mode:

ntfs-3g -o rw,locale=zh_CN.UTF-8 /dev/ada0s3 /mnt/ntfs

After all – add to /etc/fstab:

/dev/ada0s1 /mnt/ntfs ntfs-3g rw,locale=zh_CN.UTF-8, mountprog=/usr/local/bin/ntfs-3g,uid=1001,gid=1001,late 0 0

2016
07
16
07:52

freebsd安装及安全使用SSMTP

第一步:ee /ec/rc.conf中加入

sendmail_enable=”NO”

sendmail_submit_enable=”NO”

sendmail_outbound_enable=”NO”

sendmail_msp_queue_enable=”NO”
killall sendmail

第二步:安装ssmtp:

pkg install ssmtp

ee /etc/mail/mailer.conf

sendmail /usr/libexec/sendmail/sendmail
send-mail /usr/libexec/sendmail/sendmail
mailq /usr/libexec/sendmail/sendmail
newaliases /usr/libexec/sendmail/sendmail
hoststat /usr/libexec/sendmail/sendmail
purgestat /usr/libexec/sendmail/sendmail
to

sendmail /usr/local/sbin/ssmtp
send-mail /usr/local/sbin/ssmtp
mailq /usr/libexec/sendmail/sendmail
newaliases /usr/libexec/sendmail/sendmail
hoststat /usr/libexec/sendmail/sendmail
purgestat /usr/libexec/sendmail/sendmail
第三步:创建ssmtp用户

pw useradd ssmtp -g nogroup -h – -s /sbin/nologin -d /nonexistent -c “sSMTP pseudo-user”

第四步:

cd /usr/local/etc/ssmtp

chown ssmtp:wheel .

chmod 4750 .

第五步:

cp ssmtp.conf.sample ssmtp.conf

chown ssmtp:wheel . ssmtp.conf

chmod 640 ssmtp.conf

第六步:编辑ssmtp.conf文件

mailhub=smtp.exmail.qq.com:465
UseTLS=YES
AuthUser=from@mydomain.com
AuthPass=123456
FromLineOverride=YES
Hostname=serverkvm
RewriteDomain=exmail.qq.com
Root=postmaster
cp revaliases.sample revaliases

root:from@mydomain.com:smtp.exmail.qq.com:465
from:from@mydomain.com:smtp.exmail.qq.com:465
chown ssmtp:nogroup /usr/local/sbin/ssmtp
chmod 4555 /usr/local/sbin/ssmtp

测试:echo “test” | mail -v -s “test mail” your_mail@domain.com

2014
12
27
16:45

FreeBSD 10: Installing Apache 2.4, MySQL 5.5, and PHP5.5 — 找不到 libphp5.so

今天装freebsd 10,然后装apache,再装php和php扩展.没有问题.

然后重启apache,发现打不开php页面,提示下载.

刚开始以为php5安装错误了,于是又重新安装一次,发现安装php5时里面没有apache选项了,整了半天也没有发现原因,以前用freebsd8配置apache+php+mysql从来没出现过这种问题,就再试一下php53目录,make config-recursive看看里面是有apache选项的,郁闷,于是又出墙google,终于找到答案了,ls /usr/local/libexec/apache22/ 没找到libphp5.so

然后/usr/ports/www/mod_php5

make install clean;rehash安装,可是又遇到问题了,提示“Error from bsd.apache.mk. apache22 is installed (or APACHE_PORT is defined) and port requires apache”,郁闷之极,只能再google,呵呵,又被我找到答案了,万能的google啊,谢谢!关于“Error from bsd.apache.mk. apache22 is installed (or APACHE_PORT is defined) and port requires apache”请参考这篇文章

2014
11
02
19:33

FreeBSD 11 on Raspberry Pi

Install FreeBSD 11 on a Raspberry Pi

 

It seems a nice project to try out FreeBSD on a Raspberry Pi.

There are ready made images available from FreeBSD.org, so this is not very hard to accomplish. Both for FreeBSD 10 as well as for FreeBSD 11. Feeling wild, I choose for FreeBSD 11 🙂

The image can be downloaded from the FreeBSD ftp-servers.

Bunzip your image and dd it to a SD-card

 

I got the FreeBSD-11.0-CURRENT-arm-armv6-RPI-B-20140811-r269824.img.bz2 but perhaps when you read this there are allready newer images available.

On a Debian GNU/Linux laptop I ran the command:

bunzip2 FreeBSD-11.0-CURRENT-arm-armv6-RPI-B-20140811-r269824.img.bz2

Followed by:

dd if=FreeBSD-11.0-CURRENT-arm-armv6-RPI-B-20140811-r269824.img of=/dev/mmcblk0 bs=1M

Be carefull when you issue this last command, when you got the of= part wrong, you might inreversable destroy things!

Now you have a 1Gb big image on your SD card.

Put the SD card in the Raspberry Pi and power up.

The very first time you boot FreeBSD on your Raspberry Pi it seems to take ages before you get a prompt. This is because FreeBSD is expanding the partion to fill your whole SD card. In my case it was a 8 Gb SD card. I rebooted the thing and now it did not take that long to give you a prompt.

When you have a prompt, press enter and log on as root, with an empty password (just hit Enter on the password prompt).

Now you first need to add a user, make that part of the group “wheel” and give this user a password. This is needed in order to log on to your FreeBSD Raspberry Pi over ssh.

Set fixed address

Default your FreeBSD Raspberry Pi will get its network configuration over DHCP. This is great if you want that, but I like my servers to have fixed addresses.

In /etc/rc.conf you can set the fixed address of the board and add a line with the default router:

ifconfig_ue0=”inet 192.168.0.123 netmask 255.255.255.0″

defaultrouter=”192.168.0.1″

Do not forget to check /etc/resolv.conf to see if this has the right nameserver(s).

Set timezone

Become root.

Make a symbolic link for your timezone to /etc:

ln -s /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime

Update the time on your board;

ntpdate -v -b in.pool.ntp.org

And edit /etc/rc.conf, add the following line:

ntpdate_enable=”YES”

ntpd_enable=”YES”

Configure sshd

 

When your Raspberry Pi is connected to the internet, it is important to harden your sshd_config. The best is to disable password login, only allow public key authentication and only for restricted users. Something like “Match Group wheel” is a good start.

No pkg install

 

Unfortunately, installing pre-compiled binary packages with the new pkg will not work on your Raspberry Pi.

Hardware stability is an issue

 

I own several Raspberry Pies and not all of them are stable. Also the Raspberry Pi is notorious picky about the powersupply cable (USB cable) as well as the powersupply. Problems with the powersupply cable and the powersupply are hard to diagnose.

If you run into problems, the USB cable and the powersupply are the first things to check. I have seen Raspberries that, when powered on, only show a single, red, LED burning, with all the other LEDs are off. This often is the result of a USB-cable or power supply not playing nice with the Rapsberry – even if the same combination have run wihout problems for weeks.

On the other hand, there are also a couple Raspberries running in my network with high uptimes and never have shown any problem …

2014
09
01
12:22

FreeBSD install shadowsocks-libev

cd /usr/ports/net/shadowsocks-libev

make install clean;rehash

ee /etc/rc.conf 加入

shadowsocks_libev_enable=”YES”
shadowsocks_libev_flags=”-c /usr/local/etc/shadowsocks-libev/config.json”

在/usr/local/etc/shadowsocks-libev/config.json中加入

{
“server”:”136.0.16.99″,
“server_port”:1234,             //服务端端口
“local_address”: “127.0.0.1”,
“local_port”:4321,                 //客户端端口
“password”:”password”,      //客户端连接密码
“timeout”:300,
“method”:”aes-256-cfb”     //加密方式
}

然后客户端,在本地,用config.json文件内容对shadowsocks-gui进行相应配置并运行客户端,

shadowsocks-gui下载地址:http://sourceforge.net/projects/shadowsocksgui/files/dist/

最后设置浏览器代理。Chrome 推荐使用 SwitchySharp 切换代理设置。把浏览器代理设为下列参数即可:

协议: socks5

地址: 127.0.0.1

端口: 你填的 local_port

service shadowsocks-libev restart

ok应该可以科学上网了

2014
07
17
16:08

FreeBSD安装Pure-FTPd及user manager for PureFTPd

1、首先安装需要配置好apache2/mysql/php等服务!前面有过笔记。

2、安装pure-ftpd

cd /usr/ports/ftp/pure-ftpd/

make with_language=simplified-chinese install clean;rehash

安装时,会有选择项;勾选:

MYSQL Support for users in mysql database

PRIVSEP Enable privileges separation

PERUSERLIMITS Per-user concurrency limits

THROTTLING Bandwidth throttling

BANNER Show pure-ftpd welcome upon session start

UTF8 Support for charset conversion (expreimental)

安装完成后 添加pureftpd_enable=”YES”到/etc/rc.conf文件中。

3、创建MySQL数据库,登陆mysql

INSERT INTO mysql.user (Host, User, Password, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, Grant_priv, References_priv, Index_priv, Alter_priv, ssl_cipher, x509_issuer, x509_subject)

VALUES(‘localhost’,’ftp’,PASSWORD(‘tmppasswd’),’Y’,’Y’,’Y’,’Y’,’N’,’N’,’N’,’N’,’N’,’N’,’N’,’N’,’N’,’N’, Hex(“”), Hex(“”), Hex(“”));

 

FLUSH PRIVILEGES;

CREATE DATABASE ftpusers;

USE ftpusers;

 

drop table if exists ftpusers.admin;

CREATE TABLE ftpusers.admin (

Username varchar(35) NOT NULL default ”,

Password char(32) binary NOT NULL default ”,

PRIMARY KEY (Username)

) ;

— Data for table ‘admin’

INSERT INTO ftpusers.admin VALUES (‘Administrator’,MD5(‘tmppasswd’));

— Table structure for table ‘users’

drop table if exists ftpusers.users;

CREATE TABLE ftpusers.users (

`User` varchar(16) NOT NULL default ”,

`Password` varchar(32) binary NOT NULL default ”,

`Uid` int(11) NOT NULL default ’14’,

`Gid` int(11) NOT NULL default ‘5’,

`Dir` varchar(128) NOT NULL default ”,

`QuotaFiles` int(10) NOT NULL default ‘500’,

`QuotaSize` int(10) NOT NULL default ’30’,

`ULBandwidth` int(10) NOT NULL default ’80’,

`DLBandwidth` int(10) NOT NULL default ’80’,

`Ipaddress` varchar(15) NOT NULL default ‘*’,

`Comment` tinytext,

`Status` enum(‘0′,’1’) NOT NULL default ‘1’,

`ULRatio` smallint(5) NOT NULL default ‘1’,

`DLRatio` smallint(5) NOT NULL default ‘1’,

PRIMARY KEY (`User`),

UNIQUE KEY `User` (`User`)

) ;

— Data for table ‘users’

INSERT INTO ftpusers.users VALUES (‘ftpuser_1’,MD5(‘tmppasswd’),65534, 31, ‘/usr’, 100, 50, 75, 75, ‘*’, ‘Ftp user (for example)’, ‘1’, 0, 0);

 

 

配置pure-ftpd.conf

cp /usr/local/etc/pure-ftpd.conf.sample pure-ftpd.conf

编辑pure-ftpd.conf文件 ee pure-ftpd.conf

MySQLConfigFile /usr/local/etc/pureftpd-mysql.conf

CreateHomeDir yes

DisplayDotFiles no

保存退出

配置pureftpd-mysql.conf

cd /usr/local/etc/

fetch http://machiel.generaal.net/files/pureftpd/v2.x/pureftpd-mysql.conf

或者自己网站上镜像下载

/usr/local/etc/rc.d/pure-ftpd restart

 

安装User manager for PureFTPd

cd /usr/ports/www/usermanager/

make install clean;rehash

 

以上全部正确安装完毕后:进入ftp目录下载

http://machiel.generaal.net/files/pureftpd/ftp_v2.1.tar.gz或自己网站镜像

解压后http://ip/ftp/install.php安装即可。

Step [1 – 7]

This configuration script has carried out a few checks to see if everything is ready to start the configuration.

Checking if config.php exists OK!

Checking if config.php is writable OK!

Checking if PHP Extension MYSQL is enabled OK!

Checking if PHP Extension PCRE is enabled OK!

Checking if PHP Extension POSIX is enabled OK!

Checking if PHP Extension SESSION is enabled OK!

Please choose your configuration type:.选择New installation,create a new database.

 

Step [3 – 7]输入正确的root用户和root的密码。

Settings MySQL database.直接按默认设置(要是你改过密码,就输入你的密码)

Step [4 – 7]语言选择中文,选择Quota support,Ratio support(上传下载比可以选择或不选择)按Save按钮保存配置文件,然后点Setp5进行下一步。

Step [5 – 7]这里你可以更改管理员Administator的密码,也可以创建一个自己的帐号代替Administrator

Step [6 – 7]系统有一些提示,说需要编辑那2个配置文件,因为前面已经编辑过了。所以直接下一步。

Step [7 – 7]恭喜你安装完成了。建议把install.php文件更改一下名称