FreeBSD下挂载ISO文件

1、创建一个mount point
mkdir /mnt/iso

2,mount

mdconfig -a -t vnode -f freebsd.iso -u 0

mount -t cd9660 /dev/md0 /mnt/iso/
3,umount
umount /mnt/iso
mdconfig -d -u 0

用U盘安装FreeBSD系统(10.02)

用U盘安装FreeBSD系统
http://blog.csdn.net/geekoder/article/details/21945871

下载
http://mirrors.aliyun.com/freebsd/releases/ISO-IMAGES/10.2/FreeBSD-10.2-RELEASE-amd64-memstick.img

把U盘镜像文件写入到U盘的工具:
https://launchpad.net/win32-image-writer/
打开 Win32 Disk Imager,如图:

图解安装FreeBSD10.0教程
http://blog.csdn.net/geekoder/article/details/19480963

安装好FreeBSD后的一些配置(1):减少虚拟终端数

http://blog.csdn.net/geekoder/article/details/19680749

http://blog.163.com/sujoe_2006/blog/static/33531512014237923628/
1,准备安装环境
准备一块空的硬盘,或者从现有PC中划分出一块硬盘空间给freebsd。注意,freebsd只能安装在主分区,也就是说,它不同于linux可以安装在扩展分区。因此,如果你打算试用一下freebsd,那你可以使用virutalbox,vm之类的相关虚拟机来安装。具本安装过程在此不再说明,请参见(http://woothon.iteye.com/blog/1826721)。如果你要安装在当前的电脑分区中,必须先分好主分区给freebsd使用。完整安装Freebsd+桌面环境,大约需要10G空间,推荐20G。当然越大越好。具体硬件需求请见(http://www.freebsd.org/doc/zh_CN/books/handbook/install-pre.html)。

fnmp_conf


# cat /etc/nginx/nginx.conf
#20150915
user www;
worker_processes 2;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

pid logs/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

gzip on;

#4 blog
server {
listen 80;
server_name linuxchina.net;
# server_name blog.linuxchina.net;
charset utf-8;
root /word;
index index.php index.html index.htm;

# #access_log logs/host.access.log main;

location / {
try_files $uri $uri/ =404;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /word;
}
##
# # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;

# #location ~ \.php$ {
# # root html;
# # fastcgi_pass 127.0.0.1:9000;
# # fastcgi_index index.php;
# # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# # include fastcgi_params;
# #}

}

}

include /usr/local/etc/nginx/hosts/*.conf;
}


server {
listen 80;
server_name evanlinux.com;
charset utf-8;
access_log off;
root /data/www/wiki;
index index.php index.htm index.html;
location ~ .*\.(gif|jpg|jpeg|png|bmp|ico|swf|html|htm|mp3|wma|js|css)$ {
expires 7d;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
}

#evan@bsdvps:~ % cat /usr/local/etc/nginx/hosts/wiki.conf
#include /usr/local/etc/nginx/hosts/*.conf;

fnmp(pkg)

首先添加一个普通帐号并加入到管理员组

root@freebsds # adduser
Username: eva
Login group is eva. Invite evan into other groups? []: wheel #一定要有这个

在你的freebsd首次使用portsnap必须执行下面2步:

portsnap fetch
portsnap extract
这2步可以合成使用:
portsnap fetch extract
portsnap fecth是从网上获取portsnap快照的最新压缩包,听闻这个压缩包官方每小时更新一次。
portsnap extract 则是把这个压缩包创立到/usr/ports。哪怕你以前已经手工安装了ports,他也会重新创立一次。

以后更新,只需要执行下面2步:
portsnap fetch
portsnap update
这2步可以合成使用:

[root@bsd01 ~]# portsnap fetch update
portsnap第一次运行extract命令时,可能需要一段时间,以后更新使用update的时候,速度就块很多了。

#Update all your ports

portsnap fetch update && portupgrade -a #第二个是没用的吧
#you must run ‘portsnap extract’ before running ‘portsnap update’.
portsnap extract && portsnap update
rehash

# 这里db 用mariadb ps mariadb 可见mariadb

#pkg upgrade
pkg install nginx mariadb100-server php56-extensions php56-bz2 php56-curl php56-exif php56-fileinfo php56-gd php56-mbstring php56-mcrypt php56-pdo_mysql php56-openssl php56-zip php56-zlib pecl-APCu pecl-intl

sysrc 'nginx_enable=YES' 'php_fpm_enable=YES' 'mysql_enable=YES'

#ln -s /usr/local/share/certs/ca-root-nss.crt /etc/ssl/cert.pem

**********************
1.配置mariadb start
cp /usr/local/share/mysql/my-medium.cnf /usr/local/etc/my.cnf
cd /usr/local
mysql_install_db

#sysrc 已搞定了
#echo 'mysql_enable="YES"' >> /etc/rc.conf

service mysql-server onestart
/usr/local/bin/mysql_secure_installation

1.配置mariadb the end
**********************

**********************
2.配置php start

cd /usr/local/etc
vi php-fpm.conf

#ln 164
;listen = 127.0.0.1:9000
listen = /var/run/php-fpm.sock

#ln 176
;listen.owner = www
;listen.group = www
;listen.mode = 0660
#Enable these by removing the comment marker at the beginning:
listen.owner = www
listen.group = www
listen.mode = 0660

cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

vi php.ini
#Uncomment the cig.fix_pathinfo line and set it to "0":
;cgi.fix_pathinfo=1
#772
cgi.fix_pathinfo=0
#Save and close the file when you are finished.

service php-fpm restart

2.配置php the end
PHP-FPM completely configured
**********************
3.Configure nginx start
service nginx start
cd /usr/local/etc/nginx
cp nginx.conf nginx.confbak
vi nginx.conf

mkdir -p /var/log/nginx
mkdir -p /data/www
chmod -R 0777 /data/www
chown -R www /data/www
mkdir -p /usr/local/etc/nginx/logs/
chown -R www /usr/local/etc/nginx/logs/
service nginx restart

root@free:/usr/local/etc # cat nginx/nginx.conf
user www;
worker_processes 2;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

pid logs/nginx.pid;

events {
use kqueue;#kqueue 是 FreeBSD 上的一种的多路复用机制
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

gzip on;

server {
listen 80;
server_name 192.168.1.161;
charset utf-8;
root /data/www;
index index.php index.html index.htm;
#access_log logs/host.access.log main;

location / {
try_files $uri $uri/ =404;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /data/www;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;

#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
}

}

}

cat hosts/wiki.conf
server {
listen 80;
server_name evanlinux.com;
charset utf-8;
access_log off;
root /data/wiki;
index index.php index.htm index.html;
location ~ .*\.(gif|jpg|jpeg|png|bmp|ico|swf|html|htm|mp3|wma|js|css)$ {
expires 7d;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
}

3.Configure nginx the end

/usr/local/etc/rc.d/php-fpm start

CREATE DATABASE wordpress;
use mysql;
CREATE USER evan@localhost IDENTIFIED BY 'evan';
GRANT ALL PRIVILEGES ON wordpress.* TO evan@localhost;
FLUSH PRIVILEGES;

#https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-nginx-on-a-freebsd-10-1-server

ps 有时用wordpress 自己的导入功能文件太大

1.改 php.ini #xml 文件为66M左右
upload_max_filesize 改为80
post_max_size 改为 80

2. nginx.conf
找到http{}段,添加
client_max_body_size 80m;

重启NGINX
kill -HUP `cat /usr/local/etc/nginx/logs/nginx.pid `

Nginx出现“413 Request Entity Too Large”错误解决方法

默认upload_max_filesize = 2M,即文件上传的大小为2M,如果你想上传超过8M的文件,比如20M,你必须设定upload_max_filesize = 20M。
  但是光设置upload_max_filesize = 20M还是无法实现大文件的上传功能,你必须修改php.ini配置文件中的post_max_size选项,其代表允许POST的数据最大字节长度,默认为8M。如果POST数据超出限制,那么$_POST和$_FILES将会为空。要上传大文件,你必须设定该选项值大于upload_max_filesize指令的值,我一般设定upload_max_filesize和post_max_size值相等。另外如果启用了内存限制,那么该值应当小于memory_limit选项的值。

mysqldump –default-character-set=utf8 -uroot -pevan wordpress >wpnow.sql

**********************
老是403 记住真的的权限问题 要8进制 亲

这样就搞定了
chmod -R 0777 /data/www/

安装完 WordPress 后你应该做好这24件事
http://www.chinaz.com/web/2014/0627/357330.shtml

在 FreeBSD 10.0 上安装和配置 Nginx+PHP+APC+MySQL

freesbsd ports 安装 nginx+mariadb(mysql分支) +php

How To Install WordPress with Nginx on a FreeBSD 10.1 Server

https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-nginx-on-a-freebsd-10-1-server

##参考这个
Howto Install and Configure FEMP Stack (FreeBSD 10.2, Nginx, MariaDB, PHP)

How To Install an Nginx, MySQL, and PHP (FEMP) Stack on FreeBSD 10.1

How To Install WordPress with Nginx on a FreeBSD 10.1 Server
https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-nginx-on-a-freebsd-10-1-server

如何 evan su root

如何添加key

自己的机器 没事 pkg install vim

conf 配置文件一般 在 /usr/local/etc/

/usr/local/etc/nginx

freesbsd ports 安装 nginx+mariadb(mysql分支) +php


18:49 portsnap fetch
12 18:56 portsnap extract
13 19:07 portsnap update
14 19:07 portsnap fetch extract
15 19:21 portsnap fetch update

#30号
pkg install databases/mariadb100-server

freenas like
https://forums.freenas.org/index.php?threads/how-to-owncloud-using-nginx-php-fpm-and-mysql.17786/

#err 没有; 结束
root@free:/usr/local/etc/nginx # service nginx restart
Performing sanity check on nginx configuration:
nginx: [emerg] directive “index” is not terminated by “;” in /usr/local/etc/nginx/nginx.conf:43
nginx: configuration file /usr/local/etc/nginx/nginx.conf test failed

FreeBSD 10 编译 Nginx, PHP, MariaDB
http://my.oschina.net/jarly/blog/195331

FreeBSD 10 Mariadb Server Install Command

https://www.digitalocean.com/community/tutorials/how-to-install-an-nginx-mysql-and-php-femp-stack-on-freebsd-10-1

FreeBSD 10 Mariadb Server Install Command

在 FreeBSD 10.0 上安装和配置 Nginx+PHP+APC+MySQL

How to Install MariaDB 10 on FreeBSD 10

http://www.tuicool.com/articles/6jQ3qiF

Install Apache, MariaDB And PHP In FreeBSD10

https://fosskb.wordpress.com/2014/04/12/famp-installing-apache2-4-mariadb-php-on-freebsd-10/

How to install mariadb on FreeBSD

http://www.cyberciti.biz/faq/how-to-install-mariadb-databases-on-a-freebsd-v10-unix-server/
https://forums.freebsd.org/threads/mariadb-in-freebsd.48133/

maridb
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’
http://blog.csdn.net/wyzxg/article/details/4720041

http://www.360doc.com/content/08/0215/16/25127_1045525.shtml

ports install err 不能启动
failed precmd routine for mysql

FreeBSD 10.0 与 pkg 时代的到来

pkg delete curl

FreeBSD查看端口(查看开放端口)

用linux时常常是netstat ,现在用bsd 一时老是转不过来哈哈 于是记一下
FreeBSD有一个简单的查看方法,使用sockstat工具

sockstat -4l

列出所有监听中的IPv4端口,输出类似:

root@bsd:~ # sockstat -4l
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
root sendmail 837 3 tcp4 127.0.0.1:25 *:*
root sshd 834 4 tcp4 *:22 *:*
mysql mysqld 802 23 tcp4 6 *:3306 *:*

-4 = IPv4端口

-l = 监听中的端口

sockstat -4c

列出所有已链接状态的IPv4端口,输出类似

-c = 只显示链接状态的端口

root@bsd:~ # sockstat -4c
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
evan sshd 21649 3 tcp4 104.236.183.134:22 116.22.232.20:13301
evan sshd 21649 8 tcp4 104.236.183.134:19648 74.125.239.112:443
evan sshd 21649 11 tcp4 104.236.183.134:27935 74.125.239.133:443

最后一列(FOREIGN ADDRESS)为外部链接客户IP和端口,该命令可以有效的检查当前连接到服务器的客户信息!

如果不指定任何参数,sockstat将列出上面所有参数的结果合集

from http://www.ibssz.com/wiki/Category:BSD

SSH隧道与端口转发实现翻墙

SSH 隧道

换了freebsd 发现原来的命令不能用了,搞了几天没有满意的结果,今天不小心看到, 还是官方文档有用呀 google半天都没 结果

#4freebsd 位于 localhost 的 7070 端口 被用于转发 localhost 的连接到远程主机的 22 端口。
ssh -2 -N -f -p 22 -D 7070 evan@ip

#下面这个不成功 虽然7070通
ssh -2 -N -f -L 7070:localhost:22 evan@ip

OpenSSH 能够创建隧道以便用加密的会话来封装其他协议。

上述 ssh 命令使用了下面这些选项:

-2
强制 ssh 使用第2版的协议 (如果需要和较老的 SSH 一同工作请不要使用这个选项)。

-N
表示不使用命令行, 或者说只使用隧道。 如果省略, ssh 将同时初始化会话。

-f
强制 ssh 在后台执行。

-L
表示产生一条 本地端口:远程主机:远程端口 形式的隧道。

user@ip
远程 SSH 服务器。

SSH 隧道通过监听 localhost 上面指定端口来完成工作。 它将把本机主机/端口上接收到的连接通过 SSH 连接转发到远程主机/端口。

https://www.freebsd.org/doc/zh_CN.UTF-8/books/handbook/openssh.html

如果是linux 那么命令为

ssh -i id_rsa -p 22 -qtfnN -D 7070 evan@ip

将SSH2兼容格式的公钥转换成为Openssh兼容格式

ssh-keygen -i -f Identity.pub >> /root/.ssh/authorized_keys2

freesbsd ports 安装 nginx+mariadb(mysql分支) +php

ps 2015 准备更新 一下 基于 freebsd 10.1

因为各种原因特别想用绝对自由 这里没有mysql 而是用mariadb
开始
首先是更新ports
portsnap fetch extract #第一次更新时用,直接下载ports并且解压
portsnap fetch update #以后更新时使用
portsnap extract

1.#安装nginx
cd /usr/ports/www/nginx
make config-recursive
make install clean

2.#安装php
cd /usr/ports/lang/php5
#在php5-extensions的config页面中,需要勾选PHP-FPM项。
make config-recursive
make install clean
cd /usr/ports/lang/php5-extensions/
#您的PHP似乎没有安装运行WordPress所必需的MySQL扩展
#这个有些要选择一下下 支持mysql gd什么 MYSQL PDO_MYSQL
make config
make install clean

3.#安装mariadb
http://www.freshports.org/databases/mariadb-server
cd /usr/ports/databases/mariadb55-server/ && make config
make install clean
cp /usr/local/share/mysql/my-medium.cnf /var/db/mysql/my.cnf

echo 'mysql_enable="YES"' >> /etc/rc.conf
cat /etc/rc.conf
/usr/local/etc/rc.d/mysql-server start
mysql -uroot -p

4.#配置php
vi /usr/local/etc/php-fpm.conf
-; events.mechanism = epoll
+events.mechanism = kqueue
...
-listen = 127.0.0.1:9000
+listen = /var/run/php-fpm.sock
...
-;listen.owner = www
-;listen.group = www
-;listen.mode = 0666
+listen.owner = www
+listen.group = www
+listen.mode = 0666

cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

echo 'php_fpm_enable="YES"' >> /etc/rc.conf
Start PHP-FPM:
Code:
# /usr/local/etc/rc.d/php-fpm start

Configure nginx

/usr/local/etc/rc.d/nginx restart
其它
添加root密码:
MariaDB [(none)]> set password for root@localhost=password('password'); 
Query OK, 0 rows affected (0.00 sec) 
# set root password 
MariaDB [(none)]> set password for root@'127.0.0.1'=password('password'); 
Query OK, 0 rows affected (0.00 sec)

mysqladmin -u root password yourpassword
8、安装eaccelertor

cd /usr/ports/www/eaccelerator
make install clean
vi /usr/local/etc/php/extensions.ini
添加

extension=eaccelerator.so
安装Memcache扩展

cd /usr/ports/databases/pecl-memca

mkdir -p /usr/local/etc/nginx/logs

echo 'nginx_enable="YES"' >> /etc/rc.conf
echo 'php_fpm_enable="YES"' >> /etc/rc.conf

其它参考
安装与配置nginx下的php (PHP-FPM模式)
https://wiki.freebsdchina.org/howto/n/php_php-fpm_nginx

fnmp
http://forums.freebsd.org/showthread.php?t=30268

How to Install Nginx and PHP-FPM on FreeBSD

http://203.208.46.148/search?q=freebsd+nginx&ie=UTF-8&oe=UTF-8&hl=zh-CN&btnG=+Search+

http://bin63.com/how-to-install-nginx-and-php-fpm-on-freebsd
http://os.51cto.com/art/201101/244084_1.htm
http://www.yangjia.org/2013/01/25/%E5%B0%8F%E5%86%85%E5%AD%98-freebsd-%E4%BC%98%E5%8C%96%E5%8F%8A%E9%83%A8%E7%BD%B2-nmp.html

卸载
make deinstall clean

FreeBSD 的 Ports 系统
https://wiki.freebsdchina.org/faq/ports

FreeBSD 网络配置
https://wiki.freebsdchina.org/faq/networking

https://www.digitalocean.com/community/tutorials/how-to-install-an-nginx-mysql-and-php-femp-stack-on-freebsd-10-1
http://netkiller.github.io/journal/freebsd.php.html

在 FreeBSD 10.0 上安装和配置 Nginx+PHP+APC+MySQL


#不错
http://forums.freebsd.org/showthread.php?p=213791
#这个源码的
http://www.excms.cn/manual/install-freebsd-nginx.html
https://hackademics.eu/repo/1/
http://bbs.linuxtone.org/thread-6474-1-1.html
freebsd desktop
https://wiki.freebsdchina.org/doc/d/freebsd_desktop
https://wiki.freebsdchina.org/software/v/virtualbox-additions

install rednotebook1.10 on freebsd

由 Ports 安裝系統 python
cd /usr/ports/lang/python27
su root
make install
make clean

由 Ports 安裝 py-gtk2
cd /usr/ports/x11-toolkits/py-gtk2
su root
make install
make clean

由 ports 安裝 py-yaml
cd /usr/ports/devel/py-yaml
su root
make install
make clean

由 ports 安裝 py-webkitgtk
cd /usr/ports/www/py-webkitgtk
su root
make install
make clean

由 ports 安裝 py-chardet
cd /usr/ports/textproc/py-chardet
su root
make install
make clean

下載及解壓 RedNoteBook 源碼
下載最新版 RedNoteBook 1.1.7 網址 http://sourceforge.net/projects/ … 1.7.tar.gz/download
得到一個 rednotebook-1.1.7.tar.gz 檔案,現在可以解壓了
su –
tar zxvf rednotebook-1.1.7.tar.gz

解壓增加了一個 rednotebook-1.1.7 目錄

以 root 身份安裝 RedNoteBook
萬事俱備,現在可以安裝
su –
cd ~/rednotebook-1.1.7
sudo python setup.py install –record ~/install-files.log

安裝完成, 創建了 在 /usr/local/bin/rednotebook,用戶可以在 X11 中啟動 rednotebook 了

http://bbs.chinaunix.net/thread-3568241-1-1.html