kuwei 发表于 2011-3-11 21:56:14

在FreeNAS上安装数据库

如果你想启用FreeNAS上网页服务器功能,你就必须考虑使用PHP来架设动态网站,不过网上好多安装教程都是有问题的,其原因在于是直接抄FreeBSD的安装教程。如果你按照个些教程来装,OK,装完重启之后,你个FreeNAS就准备重装了,最起码,你要用个句tar来多次,恢复返点旧版文件,其原因是因为FreeNAS的系统中到处需要php,按照FreeBSD的教程安装的话你就会将原本系统的不少文件破坏掉,这将导致你的FreeNAS连启动都不店。

好了,我们在这里只需要考虑在已有PHP环境的基础上安装数据库,要考虑用最少的文件做最多的野,呢个也是FreeNAS的设想。下面动手:

一般人选择数据库都会考虑MySQL,因为MySQL一般比较我人用,不过我就考虑,MySQL已经被Oracle收购左了,之后的世界真是不知会点,虽然Oracle暂时没将产品完全clear掉的先例,不过MySQL对于Oracle的影响实在太大了,以后真是不知会点,我推荐使用PostgreSQL,呢个数据库其实在开源界好有名,而且性能非常好,很多高手都用它来代替Oracle呢类企业级数据库的,所以今日的主角就是它了,不过为了方便大多数人需要,也写一些MySQL方面的内容。

首先需要为你的PHP添加数据库支持,呢度有些问题,直接添加的话有可能会令你的系统文件版本出来问题,所以,呢处我们需要手工安装相关的文件,首先下载以下几个包

php5-mysql-5.2.12.tbz

php5-mysqli-5.2.12.tbz

php5-pdo_mysql-5.2.12.tbz

php5-pdo_pgsql-5.2.12.tbz

php5-pgsql-5.2.12.tbz

在一个单独目录内用tar -xf 文件名的方式将呢几个文件解压,解压后对应于目录将inclue和lib中的文件拷贝到usr/local下面

修改usr/local/etc/php.ini,加入以下内容

extension_dir = /usr/local/lib/php/extensions将扩展的指定,方便以后操作
extension = pgsql.so
extension = mysql.so
extension = mysqli.so
extension = pdo_pgsql.so
extension = pdo_mysql.so
加入一系列的扩展,然后你写一个PHP脚本,运行php php脚本名 > 1.htm

就会看到出现几个错误,呢个就证明你的设置是没错架了,但缺少两个文件:

libpq.so.5
libmysqlclient.so.15

然后首先用pkg_add -r databases/postgresql-server-8.2.15_1来安装postgreSQL,点解有新版不用,因为刚刚安装的几个库的支持是支持7.3原版系统所带的数据库,分别是mysql 5.0.90和postgresql 8.2.15,为了减少出现问题的情况,所以就安装直接支持的版本,甘就会安全点。安装过程中他会帮你安装埋个client架了,所以一装好就搞店。

之后的配置,你自己慢慢搞了。

最后附上PostgreSQL的安装信息,因为呢些信息对于使用配置是好有用的,很多人安装之后都不看,到时想找也麻烦。

The PostgreSQL port has a collection of "side orders":

postgresql-doc
For all of the html documentation

p5-Pg
A perl5 API for client access to PostgreSQL databases.

postgresql-tcltk
If you want tcl/tk client support.

postgresql-jdbc
For Java JDBC support.

postgresql-odbc
For client access from unix applications using ODBC as access
method. Not needed to access unix PostgreSQL servers from Win32
using ODBC. See below.

ruby-postgres, py-PyGreSQL
For client access to PostgreSQL databases using the ruby & python
languages.

p5-postgresql-plperl, postgresql-pltcl & postgresql-plruby
For using perl5, tcl & ruby as procedural languages.

postgresql-contrib
Lots of contributed utilities, postgresql functions and
datatypes. There you find autovacuum, pgcrypto and many other cool
things.

etc...



=========== BACKUP YOUR DATA! =============
As always, backup your data before
upgrading. If the upgrade leads to a higher
minor revision (e.g. 7.3.x -> 7.4), a dump
and restore of all databases is
required. This is *NOT* done by the port!

Press ctrl-C *now* if you need to pg_dump.
===========================================

pgsql:*:70:
You already have a group "pgsql", so I will use it.
pgsql:*:70:70::0:0:PostgreSQL Daemon:/usr/local/pgsql:/bin/tcsh
You already have a user "pgsql", so I will use it.

For procedural languages and postgresql functions, please note that
you might have to update them when updating the server.

If you have many tables and many clients running, consider raising
kern.maxfiles using sysctl(8), or reconfigure your kernel
appropriately.

The port is set up to use autovacuum for new databases, but you might
also want to vacuum and perhaps backup your database regularly. There
is a periodic script, /usr/local/etc/periodic/daily/502.pgsql, that
you may find useful. You can use it to backup and perfom vacuum on all
databases nightly. Per default, it perfoms `vacuum analyze'. See the
script for instructions. For autovacuum settings, please review
~pgsql/data/postgresql.conf.

To allow many simultaneous connections to your PostgreSQL server, you
should raise the SystemV shared memory limits in your kernel. Here are
example values for allowing up to 180 clients (configurations in
postgresql.conf also needed, of course):
options         SYSVSHM
options         SYSVSEM
options         SYSVMSG
options         SHMMAXPGS=65536
options         SEMMNI=40
options         SEMMNS=240
options         SEMUME=40
options         SEMMNU=120

If you plan to access your PostgreSQL server using ODBC, please
consider running the SQL script /usr/local/share/postgresql/odbc.sql
to get the functions required for ODBC compliance.

Please note that if you use the rc script,
/usr/local/etc/rc.d/postgresql, to initialize the database, unicode
(UTF-8) will be used to store character data by default.Set
postgresql_initdb_flags or use login.conf settings described below to
alter this behaviour. See the start rc script for more info.

To set limits, environment stuff like locale and collation and other
things, you can set up a class in /etc/login.conf before initializing
the database. Add something similar to this to /etc/login.conf:
---
postgres:\
      :lang=en_US.UTF-8:\
      :setenv=LC_COLLATE=C:\
      :tc=default:
---
and run `cap_mkdb /etc/login.conf'.
Then add 'postgresql_class="postgres"' to /etc/rc.conf.

======================================================================

To initialize the database, run

/usr/local/etc/rc.d/postgresql initdb

You can then start PostgreSQL by running:

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

For postmaster settings, see ~pgsql/data/postgresql.conf

NB. FreeBSD's PostgreSQL port logs to syslog by default
    See ~pgsql/data/postgresql.conf for more info

======================================================================

To run PostgreSQL at startup, add
'postgresql_enable="YES"' to /etc/rc.conf

来自:http://osxppc.blog.163.com/blog/static/689598442010102842846990/

penguin563 发表于 2014-1-15 20:49:20

架站就交給專業,寫php程人還是別研究了。
页: [1]
查看完整版本: 在FreeNAS上安装数据库