Press "Enter" to skip to content

分类: FreeBSD

FreeBSD下Nginx重启及停止操作

在FreeBSD下默认安装的文件一般情况下配置文件在/usr/local/etc/ 执行文件在/usr/local/sbin/
重新载入nginx配置命令

/usr/local/sbin/nginx -s reload

以下脚本存为nginx 给预执行权限 操作时,可以 nginx start| nginx stop | nginx test | nginx restart | nginx show

#!/usr/local/bin/bash
case $1 in
start)
        /usr/local/sbin/nginx
;;
stop)
        killall -9 nginx
;;
test)
        nginx -t -c /usr/local/etc/nginx/nginx.conf
;;
restart)
        ps auxww | grep nginx | grep master | awk '{print $2}' | xargs kill -HUP
;;
show)
        ps -aux|grep nginx

Leave a Comment

FreeBSD 8.0下用户命令自动补全[原创]

如果以上配置不能成功,那么可以添加一个新用户如 leaf 用户名

leaf# adduser       #添加命令
Username: leaf      #添加用户leaf
Full name:          #默认为空,回车
Uid (Leave empty for default):     #默认为空,回车
Login group [leaf]: wheel    #填写wheel 组
Login group is wheel. Invite leaf into other groups? []: wheel  #填写wheel 组
Login class [default]:   #默认为空,回车
Shell (sh csh tcsh bash rbash nologin) [sh]: csh     #这里要选择填写 csh 回车
Home directory [/home/leaf]:  #默认为空,回车
Home directory permissions (Leave empty for default):  #默认为空,回车
Use password-based authentication? [yes]: #默认为空,回车
Use an empty password? (yes/no) [no]:    #默认为空,回车
Use a random password? (yes/no) [no]: no 屡#输入no,回车
Enter password:             #输入密码
Enter password again:       #重复输入密码
Lock out the account after creation? [no]:   #默认为空,回车
Username   : leaf
Password   : <blank>
Full Name  :
Uid        : 1009
Class      :
Groups     : wheel wheel
Home       : /home/leaf
Home Mode  :
Shell      : /bin/csh
Locked     : no
OK? (yes/no): yes   #输入yes 结束,回车
adduser: INFO: Successfully added (leaf) to the user database.
Add another user? (yes/no): no  #选择不再添加用户,回车
Goodbye!

好了经过以上添加配置,登陆的用户就可以自动使用命令补全功能了!!!

需要删除用户可执行
rmuser <用户名>

如:

leaf# rmuser leaf    #删除leaf用户操作
Matching password entry:
leaf:*:1001:0::0:0:User &:/home/leaf:/bin/sh
Is this the entry you wish to remove? yes    #输入 yes ,回车
Remove user's home directory (/home/leaf)? yes  #输入 yes ,回车
Removing user (leaf): mailspool home passwd.
Leave a Comment

FreeBSD 8.0下webbench压力测试软件

FreeBSD 8.0下webbench压力测试软件,对于网站开发完成后做某个页面的性能压力测试是一款比较不错的软件。
1.下载软件
webbench-1.5.tar
2.下载后进行解压工作

leaf# tar -zxvf webbench-1.5.tar.gz
leaf# cd webbench-1.5
kiccleaf# make install
cc -O2 -pipe  -c webbench.c
cc -O2 -pipe   -o webbench webbench.o
install -s webbench /usr/local/bin
install -m 644 webbench.1 /usr/local/man/man1
install -d /usr/local/share/doc/webbench
install -m 644 debian/copyright /usr/local/share/doc/webbench
install -m 644 debian/changelog /usr/local/share/doc/webbench
kiccleaf# rehash

3、使用:参数说明:-c表示并发数,-t表示持续时间(秒) <网址/文件名>

leaf# webbench -c 1000 -t 30 http://192.168.1.10/index.php
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://192.168.1.10/index.php
1000 clients, running 30 sec.
Speed=38058602 pages/min, 23930171 bytes/sec.
Requests: 27676 susceed, 19001625 failed.
Leave a Comment

FreeBSD 8.0下Mysql5.5创建数据库及所属用户

创建数据库名为kiccleaf

CREATE DATABASE `kiccleaf` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

创建用户并赋予相应数据库权限,创建用户名kiccleaf

CREATE USER ‘kiccleaf’@’%’ IDENTIFIED BY ‘***’;

GRANT USAGE ON * . * TO ‘kiccleaf’@’%’ IDENTIFIED BY ‘***’ WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;

添加数据库kiccleaf所属管理用户kiccleaf

GRANT ALL PRIVILEGES ON `kiccleaf` . * TO ‘kiccleaf’@’%’;

如果有必要可以编辑权限

REVOKE ALL PRIVILEGES ON `kiccleaf` . * FROM ‘kiccleaf’@’%’;

GRANT ALL PRIVILEGES ON `kiccleaf` . * TO ‘kiccleaf’@’%’;

Leave a Comment

FreeBSD8.2中用axel提高ports的安装速度

提升ports下载速度实现多线程。

首先到
cd /usr/ports/ftp/axel 之后 make install clean

安装完成后把/etc/make.conf文件编辑如下:

FETCH_CMD=axel
FETCH_BEFORE_ARGS= -n 10 -a
FETCH_AFTER_ARGS=
DISABLE_SIZE=yes

其次添加下载源地址,不用去国外下载

MASTER_SITE_FREEBSD_ORG= ftp://ftp.cn.FreeBSD.org/pub/FreeBSD/%SUBDIR%/
MASTER_SITE_GNOME=  http://mirrors.geekbone.org/gnome/%SUBDIR%/
MASTER_SITE_LOCAL=  ftp://ftp.cn.FreeBSD.org/pub/FreeBSD/ports/local-distfiles/%SUBDIR%/
MASTER_SITE_OVERRIDE=ftp://ftp.cn.freebsd.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/
Leave a Comment

FreeBSD8.2下vsftp安装配置

由于涉及FTP到解决方案,特别在FreeBSD8.2下采用ports部署vsftp,配置如下:

先创建用户:leaf 密码:123456  采用adduser命令添加此用户,关于添加用户另一章中已经有介绍。

kiccleaf# cd /usr/ports/ftp/vsftpd
kiccleaf# make install clean

可以不用选择
Options for vsftpd 2.3.4 x

===&gt; Compressing manual pages for vsftpd-2.3.4
===&gt; Registering installation for vsftpd-2.3.4
===&gt; SECURITY REPORT:
This port has installed the following files which may act as network
servers and may therefore pose a remote security risk to the system.
/usr/local/libexec/vsftpd

If there are vulnerabilities in these programs there may be a security
risk to the system. FreeBSD makes no guarantee about the security of
ports included in the Ports Collection. Please type 'make deinstall'
to deinstall the port if this is a concern.

For more information, and contact details about the security
status of this software, see the following webpage:
http://vsftpd.beasts.org/
kiccleaf#

防止修改错误先备份vsftpd.conf文件

kiccleaf# mv /usr/local/etc/vsftpd.conf /usr/local/etc/vsftpd.conf.bak
kiccleaf# ee/usr/local/etc/vsftpd.conf

在新建文件vsftpd.conf输入以下代码内容:

anonymous_enable=NO
write_enable=YES
local_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
data_connection_timeout=3
nopriv_user=nobody
listen=YES
secure_chroot_dir=/usr/local/share/vsftpd/empty
chroot_local_user=YES
tcp_wrappers=Yes
userlist_enable=Yes
userlist_deny=No
pasv_enable=Yes
pasv_min_port=65000
pasv_max_port=65100
userlist_file=/usr/local/etc/vsftpd.user_list

创建一个文件,添加可登陆的FTP用户

kiccleaf# echo leaf &gt;&gt; /usr/local/etc/vsftpd.user_list
kiccleaf# cd /usr/local/etc/
kiccleaf# ll
total 32
-rw-r--r--  1 root  wheel  3770 Jul 12 17:39 axelrc
drwxr-xr-x  2 root  wheel   512 Jul 12 17:12 devd
drwxr-xr-x  2 root  wheel   512 Jul 12 17:12 man.d
drwxr-xr-x  2 root  wheel   512 Jul 12 17:12 pam.d
drwxr-xr-x  2 root  wheel   512 Jul 12 18:39 rc.d
-r--r--r--  1 root  wheel  5010 Jul 12 21:22 vsftpd.conf
-r--r--r--  1 root  wheel  4586 Jul 12 21:20 vsftpd.conf.dist
-rw-r--r--  1 root  wheel     1 Jul 12 21:23 vsftpd.user_list
-r--r--r--  1 root  wheel  4499 Jul 12 17:37 wgetrc.sample
kiccleaf# cat /usr/local/etc/vsftpd.user_list
leaf  #刚执行添加的用户leaf
kiccleaf# /usr/local/libexec/vsftpd &amp;
[1] 1952

添加到随系统启动项中

kiccleaf# echo vsftp_ebable=YES >>/etc/rc.conf

回去Win下采用FlashFxp进行链接测试


链接成功后

Leave a Comment

FreeBSD直接可以用命令升级,比如将FreeBSD8.1升级成FreeBSD8.2[原创]

升级FreeBSD系统FreeBSD8.1升级成FreeBSD8.2的操作过程

kiccleaf# uname -a
FreeBSD qm.w 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Fri Feb 18 02:24:46 UTC 2011     root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
kiccleaf# freebsd-update -r 8.2-RELEASE upgrade
Looking up update.FreeBSD.org mirrors... 4 mirrors found.
Fetching metadata signature for 8.1-RELEASE from update5.FreeBSD.org... done.
Fetching metadata index... done.
Fetching 1 metadata patches. done.
Applying metadata patches... done.
Fetching 1 metadata files... done.
Inspecting system... done.

The following components of FreeBSD seem to be installed:
kernel/generic world/base

The following components of FreeBSD do not seem to be installed:
src/base src/bin src/cddl src/contrib src/crypto src/etc src/games
src/gnu src/include src/krb5 src/lib src/libexec src/release src/rescue
src/sbin src/secure src/share src/sys src/tools src/ubin src/usbin
world/catpages world/dict world/doc world/games world/info
world/manpages world/proflibs

Does this look reasonable (y/n)? y

Fetching metadata signature for 8.2-RELEASE from update5.FreeBSD.org... done.
Fetching metadata index... done.
Fetching 1 metadata patches. done.
Applying metadata patches... done.
Fetching 1 metadata files... done.
Inspecting system... done.
Fetching files from 8.1-RELEASE for merging... done.
Preparing to download files... done.
Fetching 5591
60....5570....5580....5590 done.
Applying patches... done.
Fetching 47 files... done.
Attempting to automatically merge changes in files... done.
kiccleaf# freebsd-update install
Installing updates...
Kernel updates have been installed.  Please reboot and run
"/usr/sbin/freebsd-update install" again to finish installing updates.

记住以下这两步不可少,否则远程登陆不了就要跑机房咯
第一步:先更新一下ssh

kiccleaf# vi /etc/ssh/sshd_config

Port 22
PermitRootLogin no
PubkeyAuthentication yes
AuthorizedKeysFile    .ssh/id_dsa.pub
PasswordAuthentication no
PermitEmptyPasswords no

第二步:把配置ssh随系统启动

kiccleaf# cat /etc/rc.conf

sshd_enable="YES"

kiccleaf# shutdown -r now
kiccleaf# uname -a
FreeBSD qm.w 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Fri Feb 18 02:24:46 UTC 2011     root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
Leave a Comment

修改phpMyAdmin使其能够管理多台远程MySQL服务器[原创]

因为最近采用多数据维护和操作,每个数据库安装一个phpmyadmin不太现实也太繁琐。所以就对phpmyadmin进行修改实现了多mysql数据库管理的方法

经过测试版本:phpMyAdmin 3.3.5-rc1、phpMyAdmin3.4.3.1

修改方法:

第一步:打开/phpmyadmin/libraries 目录

第二步:修改config.default.php 文件(linux下可用vim编辑,FreeBSD下可用vi或是ee编辑)找到“AllowArbitraryServer
代码内容

$cfg['AllowArbitraryServer'] = false;
修改成:
$cfg['AllowArbitraryServer'] = true;

第三步:保存后去浏览器输入地址http://youdomain.com/phpmyadmin/
查看结果:

phpmyadmin登陆界面
phpmyadmin登陆界面
Leave a Comment

FreeBSD 8.2下SSH配置KEY登陆

首先我们找到系统下/etc/ssh/sshd_config 文件并用 ee /etc/ssh/sshd_config 打开内容如下:

# $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm Exp $
# $FreeBSD: src/crypto/openssh/sshd_config,v 1.49.2.1.2.1 2009/10/25 01:10:29 kensmith
Exp $
# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options change a
# default value.
# Note that some of FreeBSD's defaults differ from OpenBSD's, and
# FreeBSD has a few additional options.
#VersionAddendum FreeBSD-20090522
Port 222  #可修改端口号,防止攻击,默认为22端口
#Protocol 2
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
# Disable legacy (protocol version 1) support in the server for new
# installations. In future the default will change to require explicit
# activation of protocol 1
Protocol 2
# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 1024
# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
PermitRootLogin no    #是否允许ROOT用户直接登陆系统 yes  是  no 否
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#RSAAuthentication yes
#PubkeyAuthentication yes
AuthorizedKeysFile .ssh/id_dsa.pub  #修改使用用户目录下KEY公共文件
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# Change to yes to enable built-in password authentication.
#修改可以密码进行登陆
PasswordAuthentication no     # 不允许用户使用密码方式登录
PermitEmptyPasswords no       # 禁止空密码的用户进行登录
# Change to no to disable PAM authentication
#ChallengeResponseAuthentication yes
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
# Set this to 'no' to disable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
#UsePAM yes
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10
#PermitTunnel no
#ChrootDirectory none
# no default banner path
#Banner none
# override default of no subsystems
Subsystem sftp /usr/libexec/sftp-server
# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# ForceCommand cvs server
OK,以上SSH配置修改完成!进行重启SSH服务,
leaf# /etc/rc.d/sshd restart
Stopping sshd.
Starting sshd.
进入下一步生成Key
leaf# ssh-keygen -t dsa   输入生成语句
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):  # 默认回车即可,或是选择你要存放的位置
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):  #输入密匙的密码
Enter same passphrase again:     #再次输入密匙的密码
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
11:d6:63:26:84:fc:4f:6d:c3:9a:fa:50:ff:08:f4:0b root@leaf
The key's randomart image is:
+--[ DSA 1024]----+
|     . o+.       |
|      o...=      |
|       ..+ +     |
|        ... =    |
|        Soo+ .   |
|         o+o     |
|        ..E o    |
|        .. o +   |
|         .. o .  |
+-----------------+
leaf# ll /root/  #查看root目录是否生成了.ssh目录
total 16
-rw-r--r--  2 root  wheel   812 Mar  9 06:53 .cshrc
-rw-------  1 root  wheel  2369 Mar 10 07:26 .history
-rw-r--r--  1 root  wheel   155 Nov 21 22:57 .k5login
-rw-r--r--  1 root  wheel   303 Nov 21 22:57 .login
-rw-------  1 root  wheel   332 Feb  4 00:55 .mysql_history
-rw-r--r--  2 root  wheel   265 Nov 21 22:57 .profile
drwx------  2 root  wheel   512 Mar 12 06:37 .ssh
leaf# ll /root/.ssh/  #查看.ssh目录下是否有id_dsa 和id_dsa.pub 两个文件
total 4
-rw-------  1 root  wheel  736 Mar 12 06:37 id_dsa      #确认私钥已经建立
-rw-r--r--  1 root  wheel  603 Mar 12 06:37 id_dsa.pub  #确认公钥已经建立

接下去下载id_dsa 文件,并配置到相应的用户SSH登陆软件中。记住下载完id_dsa文件后,记得删除id_dsa文件!
执行以下操作:
leaf# rm -r id_dsa
Leave a Comment