遗留问题,目前不能在chroot环境里用femail外发论坛email地址验证邮件,欢迎有经验的朋友请跟贴指教,有关postgresql的优化,请参阅none兄的帖子,http://www.gobsd.org/showthread.php?t=3198&page=2 , 他的实际应用经验是“大大的”,:), 希望可以对我们这些初学者不吝赐教。:D
(受none兄煽动,实际上跑论坛程序,数据库也不会太大,体会不出postgresql稳定和高性能的优势,我在自己的Intel(R) Pentium(R) 4 CPU 1300MHz , 1.2 G内存的老机器上跑了一个几十万个帖子的phpbb论坛,居然还凑合能运行。)
设置packages的“路径”:
代码: 全选
# export PKG_PATH=ftp://gobsd.org/pub/OpenBSD/snapshots/packages/i386/
代码: 全选
# pkg_add postgresql-server postgresql-client postgresql-docs
postgresql-server-9.1.3:postgresql-client-9.1.3: ok
useradd: Warning: home directory `/var/postgresql' doesn't exist, and -m was not specified
postgresql-server-9.1.3: ok
postgresql-docs-9.1.3: ok
The following new rcscripts were installed: /etc/rc.d/postgresql
See rc.d(8) for details.
Look in /usr/local/share/doc/pkg-readmes for extra documentation.
代码: 全选
# su - _postgresql
$ mkdir /var/postgresql/data
$ initdb -D /var/postgresql/data -U postgres -E UTF8 -A md5 -W
The files belonging to this database system will be owned by user "_postgresql".
This user must also own the server process.
The database cluster will be initialized with locale C.
The default text search configuration will be set to "english".
fixing permissions on existing directory /var/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 40
selecting default shared_buffers ... 28MB
creating configuration files ... ok
creating template1 database in /var/postgresql/data/base/1 ... ok
initializing pg_authid ... ok
Enter new superuser password: 这里输入你的密码
Enter it again: 再输入一次
setting password ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... not supported on this platform
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
Success. You can now start the database server using:
postgres -D /var/postgresql/data
or
pg_ctl -D /var/postgresql/data -l logfile start
$
我的修改是:在/etc/sysctl.conf里加上下列三句:
代码: 全选
kern.seminfo.semmni=256
kern.seminfo.semmns=2048
kern.shminfo.shmmax=100663296
代码: 全选
postgresql:\
:openfiles-cur=1024:\
:tc=daemon:
代码: 全选
# [ -f /etc/login.conf.db ] && cap_mkdb /etc/login.conf
设置postgresql随机启动,
代码: 全选
# echo 'postgresql_user=mypgsqluser' >> /etc/rc.conf.local
# echo 'pkg_scripts="postgresql"' >> /etc/rc.conf.local
代码: 全选
# pkg_add php-5.3.10
php-5.3.10:libiconv-1.14: ok
php-5.3.10:libxml-2.7.8p5: ok
php-5.3.10:gettext-0.18.1p1: ok
php-5.3.10:femail-0.98: ok
php-5.3.10:femail-chroot-0.98p0: ok
php-5.3.10: ok
--- +femail-chroot-0.98p0 -------------------
By default, femail will use `localhost' for smtphost. Make sure to
review FAQ Section 10.16 discussing name resolution with httpd(8)'s
default chroot(2).
Additionally, one may create a custom femail.conf; see femail(8).
If you're using femail with PHP inside a chroot jail, be aware that
PHP's built-in "mail" function uses popen(), which requires /bin/sh.
--- +php-5.3.10 -------------------
To enable the php-5.3 module please create a symbolic
link from /var/www/conf/modules.sample/php-5.3.conf
to /var/www/conf/modules/php.conf.
ln -s /var/www/conf/modules.sample/php-5.3.conf \
/var/www/conf/modules/php.conf
The recommended php configuration has been installed
to /etc/php-5.3.ini.
# ln -s /var/www/conf/modules.sample/php-5.3.conf \
> /var/www/conf/modules/php.conf
代码: 全选
# cp -p /bin/sh /var/www/bin/sh
代码: 全选
unix_socket_directory = '/var/www/tmp'
代码: 全选
# rm -rf /var/www/tmp
# mkidr /var/www/tmp
# chown _postgresql:_postgresql /var/www/tmp
# chmod 755 /var/www/tmp
代码: 全选
# ln -s /var/www/tmp/.s.PGSQL.5432 /tmp
# ln -s /var/www/tmp/.s.PGSQL.5432.lock /tmp
代码: 全选
# ln -s /var/www/tmp/.s.PGSQL.5432 /tmp/.s.PGSQL.5432
# ln -s /var/www/tmp/.s.PGSQL.5432.lock /tmp/.s.PGSQL.5432.lock
安装PHP扩展
代码: 全选
pkg_add php-bz2-5.3.10 php-curl-5.3.10 php-xsl-5.3.10 php-soap-5.3.10 php-pgsql-5.3.10 php-mcrypt-5.3.10 php-gd-5.3.10 php-pgsql-5.3.10
php-bz2-5.3.10:bzip2-1.0.6: ok
php-bz2-5.3.10: ok
php-curl-5.3.10:libidn-1.24: ok
php-curl-5.3.10:curl-7.25.0: ok
php-curl-5.3.10: ok
php-xsl-5.3.10:libgpg-error-1.10: ok
php-xsl-5.3.10:libgcrypt-1.4.6p1: ok
php-xsl-5.3.10:libxslt-1.1.26p3: ok
php-xsl-5.3.10: ok
php-soap-5.3.10: ok
php-pgsql-5.3.10: ok
php-mcrypt-5.3.10:libmcrypt-2.5.8p1: ok
php-mcrypt-5.3.10:libltdl-2.4.2: ok
php-mcrypt-5.3.10: ok
php-gd-5.3.10:png-1.5.10: ok
php-gd-5.3.10:jpeg-8c: ok
php-gd-5.3.10:t1lib-5.1.2: ok
php-gd-5.3.10: ok
--- +php-bz2-5.3.10 -------------------
You can enable this module by creating a symbolic
link from /etc/php-5.3.sample/bz2.ini to
/etc/php-5.3/bz2.ini.
ln -fs /etc/php-5.3.sample/bz2.ini \
/etc/php-5.3/bz2.ini
--- +php-curl-5.3.10 -------------------
You can enable this module by creating a symbolic
link from /etc/php-5.3.sample/curl.ini to
/etc/php-5.3/curl.ini.
ln -fs /etc/php-5.3.sample/curl.ini \
/etc/php-5.3/curl.ini
--- +php-gd-5.3.10 -------------------
You can enable this module by creating a symbolic
link from /etc/php-5.3.sample/gd.ini to
/etc/php-5.3/gd.ini.
ln -fs /etc/php-5.3.sample/gd.ini \
/etc/php-5.3/gd.ini
--- +php-mcrypt-5.3.10 -------------------
You can enable this module by creating a symbolic
link from /etc/php-5.3.sample/mcrypt.ini to
/etc/php-5.3/mcrypt.ini.
ln -fs /etc/php-5.3.sample/mcrypt.ini \
/etc/php-5.3/mcrypt.ini
--- +php-pgsql-5.3.10 -------------------
You can enable this module by creating a symbolic
link from /etc/php-5.3.sample/pgsql.ini to
/etc/php-5.3/pgsql.ini.
ln -fs /etc/php-5.3.sample/pgsql.ini \
/etc/php-5.3/pgsql.ini
--- +php-soap-5.3.10 -------------------
You can enable this module by creating a symbolic
link from /etc/php-5.3.sample/soap.ini to
/etc/php-5.3/soap.ini.
ln -fs /etc/php-5.3.sample/soap.ini \
/etc/php-5.3/soap.ini
--- +php-xsl-5.3.10 -------------------
You can enable this module by creating a symbolic
link from /etc/php-5.3.sample/xsl.ini to
/etc/php-5.3/xsl.ini.
ln -fs /etc/php-5.3.sample/xsl.ini \
/etc/php-5.3/xsl.ini
修改apache配置文件以支持PHP语法。(参以前的教程)
修改 /var/www/conf/httpd.conf 文件中的下列内容:
将原内容:
代码: 全选
DirectoryIndex index.html
代码: 全选
DirectoryIndex index.php
如果两个文件全需要,则修改为:
代码: 全选
DirectoryIndex index.php index.html
代码: 全选
httpd_flags=""
我们这里用一个常见的应用——phpbb3来测试一下postgresql数据库,将下载好的文件解压后放到OpenBSD的默认的web服务器根目录 /var/www/htdocs 里:
先重新建立一个初始化数据库:
代码: 全选
# su - _postgresql
代码: 全选
$ psql -d template1 postgres
Password for user postgres:
psql (9.1.3)
Type "help" for help.
template1=# create database phpbb3;
template1-# create role leo with superuser login password 'gobsd.org';
template1-# \q
$ exit
#
代码: 全选
chmod 777 /var/www/htdocs/{cache,files,store,config.php,images/avatars/upload}
其余的web服务器设置请看以前的讨论,这里略了,我实际操作时没有问题,就是在域名设置时要有些注意的地方。
如果您有问题请跟贴讨论。
php邮件功能设置探讨:(目前没有解决的问题)
安装php时,自动安装了femail,这个package可以工作在chrooted环境下,但是我们还需要配置一下,其配置文件为 /etc/femail.conf
我的内容:
代码: 全选
# cat /etc/femail.conf
smtphost = localhost
myname = www.gobsd.org
将
代码: 全选
; sendmail_path ="/var/www/bin/femail -t -i"
代码: 全选
sendmail_path ="/bin/femail -t -i"
代码: 全选
;sendmail_from = [email protected]
代码: 全选
sendmail_from = [email protected]
代码: 全选
# cp /bin/sh /var/www/bin
# cp /etc/resolv.conf /var/www/etc/resolv.conf
# cp /etc/hosts /var/www/etc/hosts
遗留问题,目前不能在chroot环境里用femail外发论坛email地址验证邮件,有知道的朋友请跟贴说明,查询 /var/www/logs/error_log, 显示:“femail: remote host refuses our greeting” ,不知道是哪里配置的问题,是否当垃圾邮件拒收了,看来邮件服务器这块还真要琢磨一下了。
有关postgresql的优化,请参阅none兄的帖子:
http://www.gobsd.org/showthread.php?t=3198&page=2
他的实际应用经验是“大大的”,:),希望可以对我们这些初学者,不吝赐教。
有问题欢迎来 http://www.gobsd.org/newthread.php?do=newthread&f=5 探讨。