OpenBSD Apache2 mysql PHP环境搭建

在OpenBSD环境下搭建各种服务器的相关讨论。

版主: lionuxchenjun天地乾坤

回复
头像
leo
帖子: 2465
注册时间: 2010-01-21 3:27

OpenBSD Apache2 mysql PHP环境搭建

帖子 leo » 2011-03-09 0:53

安装Mysql server

代码: 全选

# export PKG_PATH=ftp://www.gobsd.org/
# pkg_add mysql-server
mysql-server-5.1.48:mysql-client-5.1.48: ok
mysql-server-5.1.48:p5-Net-Daemon-0.43: ok
mysql-server-5.1.48:p5-PlRPC-0.2018p0: ok
mysql-server-5.1.48:p5-DBI-1.609: ok
mysql-server-5.1.48:p5-DBD-mysql-4.014: ok
mysql-server-5.1.48: ok
--- +mysql-server-5.1.48 -------------------
You can find detailed instructions on how to install a database
in /usr/local/share/doc/mysql/README.OpenBSD.
#

创建默认的数据库:

代码: 全选

# /usr/local/bin/mysql_install_db
Installing MySQL system tables...
110307 13:36:00 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
OK
Filling help tables...
110307 13:36:00 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
OK
 
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
 
/usr/local/bin/mysqladmin -u root password 'new-password'
/usr/local/bin/mysqladmin -u root -h jr.gateway.2wire.net password 'new-password'
 
Alternatively you can run:
/usr/local/bin/mysql_secure_installation
 
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
 
See the manual for more instructions.
 
Please report any problems with the /usr/local/bin/mysqlbug script!
 
#

运行Mysql

代码: 全选

# mysqld_safe &
[1] 8078
# 110307 13:37:44 mysqld_safe Logging to '/var/mysql/jr.gateway.2wire.net.err'.
110307 13:37:44 mysqld_safe Starting mysqld daemon with databases from /var/mysql
 
#

设定本地mysql的root密码

代码: 全选

# mysqladmin -u root password 'gobsd.org'
创建Mysql配置文件

代码: 全选

# cp /usr/local/share/mysql/my-medium.cnf /etc/my.cnf

要让数据库的字符集编码默认是UTF-8,还要修改一下/etc/my.cnf文件,必须包含如下的内容:

代码: 全选

[client]
default-character-set=utf8
[mysqld]
default-character-set=utf8
init_connect='SET NAMES utf8'

此外基本设置里的(修改为自己觉得合适的大小)

代码: 全选

max_allowed_packet = 1M

建立Mysql登录级别

代码: 全选

mysql:\
:openfiles-cur=1024:\
:openfiles-max=2048:\
:tc=daemon:

然后重建login.conf.db文件

代码: 全选

# cap_mkdb /etc/login.conf

重新启动系统后建立一个数据库

代码: 全选

# mysql -p
Enter password:gobsd
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.48-log OpenBSD port: mysql-server-5.1.48
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>CREATE DATABASE `gobsdorg` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
分配用户leo具有数据库gobsdorg的所有权限,操作是本地,密码为gobsd:

代码: 全选

mysql> grant all on gobsdorg.* to leo@localhost identified by 'gobsd'; 
Query OK, 0 rows affected (0.00 sec)
这里注意,论坛真正运行时并不需要全部的权限,安装完成后读者请根据自己所用软件的要求来自行消减该用户权限。
退出mysql

代码: 全选

mysql> quit
Bye
#

安装apache2

代码: 全选

# export PKG_PATH=ftp://www.gobsd.org/
# pkg_add apache-httpd
apache-httpd-2.2.15:pcre-8.02p1: ok
apache-httpd-2.2.15:apr-mt-1.2.11p4: ok
apache-httpd-2.2.15:db-4.6.21p0: ok
apache-httpd-2.2.15:libiconv-1.13p1: ok
apache-httpd-2.2.15:apr-util-mt-1.2.10p4: ok
apache-httpd-2.2.15: ok
--- +apache-httpd-2.2.15 -------------------
This is the official httpd distributed by the Apache Server Project,
provided as a port for those who, for various reasons, need to run
version 2.
 
OpenBSD provides a custom Apache server, httpd(8), in the base system
which has been audited for security and may run in a chroot(2)
environment.  Users are STRONGLY encouraged to use the system httpd
rather than this port.
#

如果想在OpenBSD系统启动时自动运行Apache2,在/etc/rc.local文件里加上如下两行:

代码: 全选

echo "starting apache2..."
/usr/local/sbin/apachectl2 start
apache2的主目录在 /var/apache2/htdocs/

到目前为止安装的pkckages

代码: 全选

# pkg_info
apache-httpd-2.2.15 apache HTTP server
apr-mt-1.2.11p4     Apache Portable Runtime
apr-util-mt-1.2.10p4 companion library to APR
db-4.6.21p0         Berkeley DB package, revision 4
libiconv-1.13p1     character set conversion library
mysql-client-5.1.48 multithreaded SQL database (client)
mysql-server-5.1.48 multithreaded SQL database (server)
p5-DBD-mysql-4.014  MySQL drivers for the Perl DBI
p5-DBI-1.609        unified perl interface for database access
p5-Net-Daemon-0.43  extension for portable daemons
p5-PlRPC-0.2018p0   module for writing rpc servers and clients
pcre-8.02p1         perl-compatible regular expression library
#
安装php
Ports系统内PHP及其所有扩展全是为apache 1.3“量身定制”的,不过我们讨论的是apache2,所以如果直接使用pkg_add安装编译好的php内核和扩展,就会在运行apache2时遇到运行错误。这就需要自己动手修改ports了。
需要在以下两个文件内用CONFIGURE_ARG+来定义新的flag,
/usr/ports/www/php5/core/Makefile
/usr/ports/www/php5/extensions/Makefile
也就是将原来的

代码: 全选

CONFIGURE_ARGS+= --with-apxs=/usr/sbin/apxs \
替换为

代码: 全选

CONFIGURE_ARGS+= --with-apxs2=/usr/local/sbin/apxs2 \
有关CONFIGURE_AGS+的说明请参阅http://www.openbsd.org/faq/ports/guide.html


设置工作已经结束了,现在我们的就需要手动编译php内核及其扩展了。

代码: 全选

# cd /usr/ports/www/php5
# make install
上面的命令会按照我们的设定编译PHP内核以及所有的php扩展,如果你不想编译某些模块或者说想进行特殊的设定,自己在/usr/ports/www/php5 里运行

代码: 全选

# make show=FLAVORS
我的实验系统是i386,所以生成的packages文件在 /usr/ports/packages/i386/all/ 里面


以下是packages清单:

代码: 全选

# cd /usr/ports/packages/i386/all/
# ls -la
total 198548
drwxr-xr-x  2 root  wheel      4096 Mar  8 06:14 .
drwxr-xr-x  6 root  wheel       512 Mar  8 00:09 ..
-rw-r--r--  3 root  wheel   3073218 Mar  8 04:55 aspell-0.60.6p4.tgz
-rw-r--r--  3 root  wheel    217546 Mar  8 02:41 atk-1.30.0p0.tgz
-rw-r--r--  3 root  wheel    135835 Mar  8 00:35 autoconf-2.13p1.tgz
-rw-r--r--  3 root  wheel    402639 Mar  8 03:00 autoconf-2.59p3.tgz
-rw-r--r--  3 root  wheel    469093 Mar  8 00:10 autoconf-2.61p3.tgz
-rw-r--r--  3 root  wheel    512100 Mar  8 03:01 autoconf-2.62p0.tgz
-rw-r--r--  3 root  wheel    442692 Mar  8 03:00 automake-1.9.6p4.tgz
-rw-r--r--  3 root  wheel    121249 Mar  8 00:39 bzip2-1.0.5.tgz
-rw-r--r--  3 root  wheel   1951220 Mar  8 02:05 c-client-2007ep0.tgz
-rw-r--r--  3 root  wheel    724451 Mar  8 02:48 cairo-1.8.10p0.tgz
-rw-r--r--  3 root  wheel   3842543 Mar  8 03:13 cups-1.4.4p1.tgz
-rw-r--r--  3 root  wheel    560349 Mar  8 01:47 curl-7.20.0.tgz
-rw-r--r--  3 root  wheel    742646 Mar  8 02:08 cyrus-sasl-2.1.23p0.tgz
-rw-r--r--  3 root  wheel    595901 Mar  8 03:07 dbus-1.2.24p4.tgz
-rw-r--r--  3 root  wheel     44179 Mar  8 03:14 desktop-file-utils-0.16p0.tgz
-rw-r--r--  3 root  wheel   2068612 Mar  8 05:25 doxygen-1.5.4p0.tgz
-rw-r--r--  3 root  wheel   1768417 Mar  8 05:48 freetds-0.82.1pre20090903p0.tgz
-rw-r--r--  3 root  wheel     40895 Mar  8 00:46 gdbm-1.8.3p0.tgz
-rw-r--r--  3 root  wheel   7198703 Mar  8 00:35 gettext-0.18.1.tgz
-rw-r--r--  3 root  wheel   2782478 Mar  8 02:40 glib2-2.24.1p2.tgz
-rw-r--r--  4 root  wheel   1392936 Mar  8 02:40 glib2-docs-2.24.1.tgz
-rw-r--r--  3 root  wheel    157338 Mar  8 02:44 glitz-0.5.6p2.tgz
-rw-r--r--  3 root  wheel    453040 Mar  8 01:52 gmake-3.81p1.tgz
-rw-r--r--  3 root  wheel    539606 Mar  8 02:01 gmp-4.3.1.tgz
-rw-r--r--  3 root  wheel   1634143 Mar  8 05:44 gnutls-2.8.6.tgz
-rw-r--r--  3 root  wheel  12213825 Mar  8 04:20 gtk+2-2.20.1.tgz
-rw-r--r--  3 root  wheel     72462 Mar  8 04:20 gtk+2-cups-2.20.1.tgz
-rw-r--r--  4 root  wheel   2835824 Mar  8 04:20 gtk+2-docs-2.20.1.tgz
-rw-r--r--  3 root  wheel     10332 Mar  8 00:09 help2man-1.29p0.tgz
-rw-r--r--  4 root  wheel      4996 Mar  8 04:20 hicolor-icon-theme-0.12.tgz
-rw-r--r--  3 root  wheel   3047186 Mar  8 02:05 imap-uw-2007ep0.tgz
-rw-r--r--  4 root  wheel     43364 Mar  8 02:24 intltool-0.40.6.tgz
-rw-r--r--  3 root  wheel    589083 Mar  8 04:28 iodbc-3.52.6p0.tgz
-rw-r--r--  3 root  wheel    282328 Mar  8 04:28 iodbc-admin-3.52.6p0.tgz
-rw-r--r--  3 root  wheel    359913 Mar  8 01:49 jpeg-8b.tgz
-rw-r--r--  3 root  wheel     34816 Mar  8 00:45 lemon-3.6.23.tgz
-rw-r--r--  3 root  wheel     26221 Mar  8 02:26 libgamin-0.1.10p3.tgz
-rw-r--r--  3 root  wheel    661931 Mar  8 05:30 libgcrypt-1.4.6.tgz
-rw-r--r--  3 root  wheel     74979 Mar  8 05:26 libgpg-error-1.9.tgz
-rw-r--r--  3 root  wheel    270101 Mar  8 01:42 libidn-1.11.tgz
-rw-r--r--  3 root  wheel    386886 Mar  8 00:11 libltdl-1.5.26p0.tgz
-rw-r--r--  3 root  wheel    175524 Mar  8 02:21 libmcrypt-2.5.8p1.tgz
-rw-r--r--  3 root  wheel    114700 Mar  8 05:33 libtasn1-2.3.tgz
-rw-r--r--  3 root  wheel    259404 Mar  8 00:11 libtool-1.5.26p4.tgz
-rw-r--r--  3 root  wheel   2088255 Mar  8 01:08 libxml-2.7.6.tgz
-rw-r--r--  3 root  wheel    619281 Mar  8 05:52 libxslt-1.1.26.tgz
-rw-r--r--  3 root  wheel    131756 Mar  8 05:35 lzo2-2.03.tgz
-rw-r--r--  3 root  wheel    500205 Mar  8 02:05 mailutil-uw-2007ep0.tgz
-rw-r--r--  3 root  wheel      4095 Mar  8 00:09 metaauto-0.9.tgz
-rw-r--r--  3 root  wheel    262264 Mar  8 02:22 mhash-0.9.9.9.tgz
-rw-r--r--  3 root  wheel   2514379 Mar  8 05:10 net-snmp-5.4.2.1p5.tgz
-rw-r--r--  3 root  wheel      9072 Mar  8 05:10 net-snmp-tkmib-5.4.2.1.tgz
-rw-r--r--  3 root  wheel   1352579 Mar  8 02:19 openldap-client-2.3.43p1.tgz
-rw-r--r--  3 root  wheel    866423 Mar  8 02:19 openldap-server-2.3.43p3.tgz
-rw-r--r--  3 root  wheel    136776 Mar  8 05:10 p5-SNMP-5.4.2.1p1.tgz
-rw-r--r--  3 root  wheel     15662 Mar  8 04:32 p5-UUID-1.6.0p1.tgz
-rw-r--r--  3 root  wheel    189036 Mar  8 02:24 p5-XML-Parser-2.36p1.tgz
-rw-r--r--  3 root  wheel    983632 Mar  8 02:56 pango-1.28.1.tgz
-rw-r--r--  3 root  wheel     10642 Mar  8 06:12 php5-bz2-5.2.13p0.tgz
-rw-r--r--  3 root  wheel   3565325 Mar  8 01:40 php5-core-5.2.13p0.tgz
-rw-r--r--  3 root  wheel     26432 Mar  8 06:12 php5-curl-5.2.13p0.tgz
-rw-r--r--  3 root  wheel     24950 Mar  8 06:12 php5-dba-5.2.13p0.tgz
-rw-r--r--  3 root  wheel     14732 Mar  8 06:12 php5-dbase-5.2.13p0.tgz
-rw-r--r--  3 root  wheel       949 Mar  8 06:12 php5-extensions-5.2.13p0.tgz
-rw-r--r--  3 root  wheel   1431450 Mar  8 01:40 php5-fastcgi-5.2.13p0.tgz
-rw-r--r--  3 root  wheel    111253 Mar  8 06:12 php5-gd-5.2.13p0.tgz
-rw-r--r--  3 root  wheel     16459 Mar  8 06:13 php5-gmp-5.2.13p0.tgz
-rw-r--r--  3 root  wheel     38184 Mar  8 06:13 php5-imap-5.2.13p0.tgz
-rw-r--r--  3 root  wheel     19015 Mar  8 06:13 php5-ldap-5.2.13p0.tgz
-rw-r--r--  3 root  wheel   1104624 Mar  8 06:13 php5-mbstring-5.2.13p0.tgz
-rw-r--r--  3 root  wheel     14196 Mar  8 06:13 php5-mcrypt-5.2.13p0.tgz
-rw-r--r--  3 root  wheel      5271 Mar  8 06:13 php5-mhash-5.2.13p0.tgz
-rw-r--r--  3 root  wheel     22237 Mar  8 06:14 php5-mssql-5.2.13p0.tgz
-rw-r--r--  3 root  wheel     24043 Mar  8 06:13 php5-mysql-5.2.13p0.tgz
-rw-r--r--  3 root  wheel     41313 Mar  8 06:13 php5-mysqli-5.2.13p0.tgz
-rw-r--r--  3 root  wheel     24927 Mar  8 06:13 php5-ncurses-5.2.13p0.tgz
-rw-r--r--  3 root  wheel     27946 Mar  8 06:13 php5-odbc-5.2.13p0.tgz
-rw-r--r--  3 root  wheel      8264 Mar  8 06:14 php5-pdo_dblib-5.2.13p0.tgz
-rw-r--r--  3 root  wheel     13548 Mar  8 06:13 php5-pdo_mysql-5.2.13p0.tgz
-rw-r--r--  3 root  wheel     14171 Mar  8 06:13 php5-pdo_pgsql-5.2.13p0.tgz
-rw-r--r--  3 root  wheel     11835 Mar  8 06:13 php5-pdo_sqlite-5.2.13p0.tgz
-rw-r--r--  3 root  wheel     44269 Mar  8 06:13 php5-pgsql-5.2.13p0.tgz
-rw-r--r--  3 root  wheel      9122 Mar  8 06:13 php5-pspell-5.2.13p0.tgz
-rw-r--r--  3 root  wheel      5042 Mar  8 06:13 php5-shmop-5.2.13p0.tgz
-rw-r--r--  3 root  wheel     12078 Mar  8 06:14 php5-snmp-5.2.13p0.tgz
-rw-r--r--  3 root  wheel    137871 Mar  8 06:13 php5-soap-5.2.13p0.tgz
-rw-r--r--  3 root  wheel     29498 Mar  8 06:14 php5-sqlite-5.2.13p0.tgz
-rw-r--r--  3 root  wheel     19351 Mar  8 06:14 php5-sybase_ct-5.2.13p0.tgz
-rw-r--r--  3 root  wheel     18157 Mar  8 06:14 php5-tidy-5.2.13p0.tgz
-rw-r--r--  3 root  wheel     40021 Mar  8 06:14 php5-xmlrpc-5.2.13p1.tgz
-rw-r--r--  3 root  wheel     14084 Mar  8 06:14 php5-xsl-5.2.13p0.tgz
-rw-r--r--  3 root  wheel    307932 Mar  8 01:50 png-1.2.44.tgz
-rw-r--r--  3 root  wheel   1485742 Mar  8 04:47 postgresql-client-8.4.4.tgz
-rw-r--r--  3 root  wheel    407940 Mar  8 04:47 postgresql-contrib-8.4.4.tgz
-rw-r--r--  4 root  wheel   2236540 Mar  8 04:47 postgresql-docs-8.4.4.tgz
-rw-r--r--  3 root  wheel   4432311 Mar  8 04:47 postgresql-server-8.4.4.tgz
-rw-r--r--  3 root  wheel    383385 Mar  8 01:08 py-libxml-2.7.6.tgz
-rw-r--r--  3 root  wheel     60039 Mar  8 05:52 py-libxslt-1.1.26.tgz
-rw-r--r--  3 root  wheel   6508905 Mar  8 00:59 python-2.5.4p5.tgz
-rw-r--r--  3 root  wheel     33695 Mar  8 00:59 python-bsddb-2.5.4p5.tgz
-rw-r--r--  3 root  wheel      7680 Mar  8 00:59 python-gdbm-2.5.4p5.tgz
-rw-r--r--  3 root  wheel    460348 Mar  8 00:59 python-idle-2.5.4p5.tgz
-rw-r--r--  3 root  wheel   3279803 Mar  8 00:59 python-tests-2.5.4p5.tgz
-rw-r--r--  3 root  wheel    272992 Mar  8 00:59 python-tkinter-2.5.4p5.tgz
-rw-r--r--  3 root  wheel    417319 Mar  8 00:59 python-tools-2.5.4p5.tgz
-rw-r--r--  3 root  wheel    650400 Mar  8 04:22 shared-mime-info-0.71.tgz
-rw-r--r--  3 root  wheel    399022 Mar  8 05:12 sqlite-2.8.17p1.tgz
-rw-r--r--  3 root  wheel    592804 Mar  8 00:45 sqlite3-3.6.23p0.tgz
-rw-r--r--  3 root  wheel     20354 Mar  8 00:45 sqlite3-tcl-3.6.23.tgz
-rw-r--r--  3 root  wheel    810092 Mar  8 01:54 t1lib-5.1.0p2.tgz
-rw-r--r--  3 root  wheel   1803123 Mar  8 00:48 tcl-8.4.19.tgz
-rw-r--r--  3 root  wheel   2336716 Mar  8 00:42 tcl-8.5.8p0.tgz
-rw-r--r--  3 root  wheel    473683 Mar  8 05:53 tidy-051026.tgz
-rw-r--r--  3 root  wheel    888489 Mar  8 03:04 tiff-3.9.4.tgz
-rw-r--r--  3 root  wheel   1746862 Mar  8 00:51 tk-8.4.19p0.tgz
-rw-r--r--  3 root  wheel    116984 Mar  8 04:32 uuid-1.6.0p1.tgz
-rw-r--r--  3 root  wheel     37361 Mar  8 02:59 xdg-utils-1.0.2p8.tgz
#
因为这并非是port系统默认的packages,所以如果你今后重新安装系统时可能还需要它们请自行备份。
本例中为了简单起见,我们安装安装了所有的模块,自然,一般情况下你不需要这样,请根据自己的需要自行安装相应的模块。上面说了,你也可以在编译过程中指定特定的编译参数来构建自己的所需的模块。

代码: 全选

# pwd
/usr/ports/packages/i386/all
# pkg_add php5*
php5-bz2-5.2.13p0: ok
php5-curl-5.2.13p0: ok
php5-dba-5.2.13p0: ok
php5-dbase-5.2.13p0: ok
php5-fastcgi-5.2.13p0: ok
php5-gd-5.2.13p0: ok
php5-gmp-5.2.13p0: ok
php5-imap-5.2.13p0: ok
php5-ldap-5.2.13p0: ok
php5-mbstring-5.2.13p0: ok
php5-mcrypt-5.2.13p0: ok
php5-mhash-5.2.13p0: ok
php5-mssql-5.2.13p0: ok
php5-mysql-5.2.13p0: ok
php5-mysqli-5.2.13p0: ok
php5-ncurses-5.2.13p0: ok
php5-odbc-5.2.13p0: ok
php5-pdo_dblib-5.2.13p0: ok
php5-pdo_mysql-5.2.13p0: ok
php5-pdo_pgsql-5.2.13p0: ok
php5-pdo_sqlite-5.2.13p0: ok
php5-pgsql-5.2.13p0: ok
php5-pspell-5.2.13p0: ok
php5-shmop-5.2.13p0: ok
php5-snmp-5.2.13p0: ok
php5-soap-5.2.13p0: ok
php5-sqlite-5.2.13p0: ok
php5-sybase_ct-5.2.13p0: ok
php5-tidy-5.2.13p0: ok
php5-xmlrpc-5.2.13p1: ok
php5-xsl-5.2.13p0: ok
--- +php5-bz2-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/bz2.ini to
/var/www/conf/php5/bz2.ini.
 
ln -fs /var/www/conf/php5.sample/bz2.ini \
        /var/www/conf/php5/bz2.ini
--- +php5-curl-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/curl.ini to
/var/www/conf/php5/curl.ini.
 
ln -fs /var/www/conf/php5.sample/curl.ini \
        /var/www/conf/php5/curl.ini
--- +php5-dba-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/dba.ini to
/var/www/conf/php5/dba.ini.
 
ln -fs /var/www/conf/php5.sample/dba.ini \
        /var/www/conf/php5/dba.ini
--- +php5-dbase-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/dbase.ini to
/var/www/conf/php5/dbase.ini.
 
ln -fs /var/www/conf/php5.sample/dbase.ini \
        /var/www/conf/php5/dbase.ini
--- +php5-gd-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/gd.ini to
/var/www/conf/php5/gd.ini.
 
ln -fs /var/www/conf/php5.sample/gd.ini \
        /var/www/conf/php5/gd.ini
--- +php5-gmp-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/gmp.ini to
/var/www/conf/php5/gmp.ini.
 
ln -fs /var/www/conf/php5.sample/gmp.ini \
        /var/www/conf/php5/gmp.ini
--- +php5-imap-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/imap.ini to
/var/www/conf/php5/imap.ini.
 
ln -fs /var/www/conf/php5.sample/imap.ini \
        /var/www/conf/php5/imap.ini
--- +php5-ldap-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/ldap.ini to
/var/www/conf/php5/ldap.ini.
 
ln -fs /var/www/conf/php5.sample/ldap.ini \
        /var/www/conf/php5/ldap.ini
--- +php5-mbstring-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/mbstring.ini to
/var/www/conf/php5/mbstring.ini.
 
ln -fs /var/www/conf/php5.sample/mbstring.ini \
        /var/www/conf/php5/mbstring.ini
--- +php5-mcrypt-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/mcrypt.ini to
/var/www/conf/php5/mcrypt.ini.
 
ln -fs /var/www/conf/php5.sample/mcrypt.ini \
        /var/www/conf/php5/mcrypt.ini
--- +php5-mhash-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/mhash.ini to
/var/www/conf/php5/mhash.ini.
 
ln -fs /var/www/conf/php5.sample/mhash.ini \
        /var/www/conf/php5/mhash.ini
--- +php5-mssql-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/mssql.ini to
/var/www/conf/php5/mssql.ini.
 
ln -fs /var/www/conf/php5.sample/mssql.ini \
        /var/www/conf/php5/mssql.ini
--- +php5-mysql-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/mysql.ini to
/var/www/conf/php5/mysql.ini.
 
ln -fs /var/www/conf/php5.sample/mysql.ini \
        /var/www/conf/php5/mysql.ini
--- +php5-mysqli-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/mysqli.ini to
/var/www/conf/php5/mysqli.ini.
 
ln -fs /var/www/conf/php5.sample/mysqli.ini \
        /var/www/conf/php5/mysqli.ini
--- +php5-ncurses-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/ncurses.ini to
/var/www/conf/php5/ncurses.ini.
 
ln -fs /var/www/conf/php5.sample/ncurses.ini \
        /var/www/conf/php5/ncurses.ini
--- +php5-odbc-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/odbc.ini to
/var/www/conf/php5/odbc.ini.
 
ln -fs /var/www/conf/php5.sample/odbc.ini \
        /var/www/conf/php5/odbc.ini
--- +php5-pdo_dblib-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/pdo_dblib.ini to
/var/www/conf/php5/pdo_dblib.ini.
 
ln -fs /var/www/conf/php5.sample/pdo_dblib.ini \
        /var/www/conf/php5/pdo_dblib.ini
--- +php5-pdo_mysql-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/pdo_mysql.ini to
/var/www/conf/php5/pdo_mysql.ini.
 
ln -fs /var/www/conf/php5.sample/pdo_mysql.ini \
        /var/www/conf/php5/pdo_mysql.ini
--- +php5-pdo_pgsql-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/pdo_pgsql.ini to
/var/www/conf/php5/pdo_pgsql.ini.
 
ln -fs /var/www/conf/php5.sample/pdo_pgsql.ini \
        /var/www/conf/php5/pdo_pgsql.ini
--- +php5-pdo_sqlite-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/pdo_sqlite.ini to
/var/www/conf/php5/pdo_sqlite.ini.
 
ln -fs /var/www/conf/php5.sample/pdo_sqlite.ini \
        /var/www/conf/php5/pdo_sqlite.ini
--- +php5-pgsql-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/pgsql.ini to
/var/www/conf/php5/pgsql.ini.
 
ln -fs /var/www/conf/php5.sample/pgsql.ini \
        /var/www/conf/php5/pgsql.ini
--- +php5-pspell-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/pspell.ini to
/var/www/conf/php5/pspell.ini.
 
ln -fs /var/www/conf/php5.sample/pspell.ini \
        /var/www/conf/php5/pspell.ini
--- +php5-shmop-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/shmop.ini to
/var/www/conf/php5/shmop.ini.
 
ln -fs /var/www/conf/php5.sample/shmop.ini \
        /var/www/conf/php5/shmop.ini
--- +php5-snmp-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/snmp.ini to
/var/www/conf/php5/snmp.ini.
 
ln -fs /var/www/conf/php5.sample/snmp.ini \
        /var/www/conf/php5/snmp.ini
--- +php5-soap-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/soap.ini to
/var/www/conf/php5/soap.ini.
 
ln -fs /var/www/conf/php5.sample/soap.ini \
        /var/www/conf/php5/soap.ini
--- +php5-sqlite-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/sqlite.ini to
/var/www/conf/php5/sqlite.ini.
 
ln -fs /var/www/conf/php5.sample/sqlite.ini \
        /var/www/conf/php5/sqlite.ini
--- +php5-sybase_ct-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/sybase_ct.ini to
/var/www/conf/php5/sybase_ct.ini.
 
ln -fs /var/www/conf/php5.sample/sybase_ct.ini \
        /var/www/conf/php5/sybase_ct.ini
--- +php5-tidy-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/tidy.ini to
/var/www/conf/php5/tidy.ini.
 
ln -fs /var/www/conf/php5.sample/tidy.ini \
        /var/www/conf/php5/tidy.ini
--- +php5-xmlrpc-5.2.13p1 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/xmlrpc.ini to
/var/www/conf/php5/xmlrpc.ini.
 
ln -fs /var/www/conf/php5.sample/xmlrpc.ini \
        /var/www/conf/php5/xmlrpc.ini
--- +php5-xsl-5.2.13p0 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/xsl.ini to
/var/www/conf/php5/xsl.ini.
 
ln -fs /var/www/conf/php5.sample/xsl.ini \
        /var/www/conf/php5/xsl.ini
#
然后根据系统提示运行ln-fs,此处略去。

接下来是调整apche2的配置文件/etc/apache2/httpd2.conf,让apache支持php索引

代码: 全选

DirectoryIndex index.html
设置为

代码: 全选

DirectoryIndex index.html index.php
让apache2支持对.php文件代码的分析

代码: 全选

<IfModule mime_module>
...........
</IfModule>
里加上

代码: 全选

AddType application/x-httpd-php .php
添加php的DSO模块支持。

代码: 全选

LoadModule php5_module /usr/local/lib/php/libphp5.so


安装pear

代码: 全选

# pkg_add pear
pear-1.7.2:pear-utils-1.7.2: ok
pear-1.7.2: ok

安装

代码: 全选

# pkg_add p5-XML-Parser
编辑 /var/www/conf/php.ini
找到:

代码: 全选

; Maximum size of POST data that PHP will accept.
post_max_size = 8M
这会限制每个帖子的大小,放大一些吧,我是改为50M。
找到:

代码: 全选

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M
这会限制上传文件大小,请自己根据需要修改
找到:

代码: 全选

; Maximum number of files that can be uploaded via a single request
max_file_uploads = 20
一次最多上传的文件数,请自行修改。
还有两个我是一般要修改的:

代码: 全选

short_open_tag = On
display_errors = On
这里请注意,配置文档里强烈建议在生产环境里关闭第二条选项,而以日志文档的方式代替,我打开这个只是因为每种论坛程序需要的php模块可能略有差别,有时候可能因为缺少模块安装过程无法继续或运行不正常,这无法在这里一一列举了,而且就我所尝试的程序也很有限,大家在实际应用中应该结合自己的情况并具体错误提示找出适合的php5插件,一旦你确认运行无误后请自行将第二个参数修改为Off。

最后说一下rewrite规则的设定,apache2的配置文件在 /etc/apache2/httpd2.conf, 请确保这里没有被注释掉:

代码: 全选

LoadModule rewrite_module /usr/local/lib/apache2/mod_rewrite.so

此外,再将下列代码里面的红色部分设置为All

代码: 全选

<Directory "/var/apache2/htdocs">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks
 
    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride [color=red][B]All[/B][/color]
    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all


好了,到此为止,基本上OpenBSD+Apache2+Mysql+PHP的环境就算搭建完毕了,剩下的内容请参阅原来我写的apache 1.3的帖子、或者根据您的实际情况自我调整,这里就不多说了。
附件
apache2.PNG

junfengfan
铜 Cu
帖子: 236
注册时间: 2010-02-03 18:37

帖子 junfengfan » 2011-03-09 13:13

看到了,试试看能不能做出来~~~

junfengfan
铜 Cu
帖子: 236
注册时间: 2010-02-03 18:37

apache1.3.29 如何通过ports重新再安装一次?

帖子 junfengfan » 2011-03-09 16:43

apache1.3.29 如何通过ports重新再安装一次?从而把它的最大连接数改成512,再编译;另外是不是mysql5,你如果apache连接数太大,mysql5速度却不能跟上?二者这间是不是有个最佳值?

头像
leo
帖子: 2465
注册时间: 2010-01-21 3:27

帖子 leo » 2011-03-09 20:25

你在apache 1.3.29的帖子里和大家讨论apache2, 帮你搞定了apache2, 你却又在apache2的相关帖子里和大家讨论apache 1.3.29......也太善于“跑题了”,呵呵,你不怕把看帖子的人搞得精神分裂了?
想起了一个笑话——你和他讲公正,他和你讲和谐。你和他讲腐败,他要你顾大局。你和他讲民主,他和你讲稳定压倒一切。 你和他讲法律,他和你讲政治; 你和他讲政治,他和你讲民意; 你和他讲民意,他和你耍流氓; 你和他耍流氓,他和你讲法律。

自己重新开一个帖子或在原来apache1.3.29的帖子里讨论吧——这样方便其他查看的朋友根据标题进行索引。

junfengfan
铜 Cu
帖子: 236
注册时间: 2010-02-03 18:37

帖子 junfengfan » 2011-03-10 7:28

呵呵~~~ 你讲的有道理~~~ ;谢谢;make install 真费时间~~~估计在我的4000+电脑上需要跑14小时~~~

头像
leo
帖子: 2465
注册时间: 2010-01-21 3:27

帖子 leo » 2011-03-10 12:22

junfengfan 写了:呵呵~~~ 你讲的有道理~~~ ;谢谢;make install 真费时间~~~估计在我的4000+电脑上需要跑14小时~~~
对CPU类型不熟悉,4000+是什么的CPU?AMD?
我的老机器上一宿就编译完了。

代码: 全选

# sysctl hw
hw.machine=i386
hw.model=Intel(R) Pentium(R) 4 CPU 1300MHz ("GenuineIntel" 686-class)
hw.ncpu=1
hw.byteorder=1234
hw.pagesize=4096
hw.disknames=wd0,cd0,fd0
hw.diskcount=3
hw.cpuspeed=1286
hw.setperf=100
hw.vendor=Dell Computer Corporation
hw.product=OptiPlex GX400
hw.serialno=DDNQH01
hw.uuid=44454c4c-44c6-104e-8051-c4c04f483031
hw.physmem=1341190144
hw.usermem=1341177856
hw.ncpufound=1

junfengfan
铜 Cu
帖子: 236
注册时间: 2010-02-03 18:37

帖子 junfengfan » 2011-03-10 14:25

对;amd 双核 4000+;在vmware 上跑的虚拟机。
# sysctl hw
hw.machine=i386
hw.model=AMD Athlon(tm) 64 X2 Dual Core Processor 4000+ ("AuthenticAMD" 686-class, 512KB L2 cache)
hw.ncpu=1
hw.byteorder=1234
hw.pagesize=4096
hw.disknames=wd0,cd0
hw.diskcount=2
hw.sensors.acpiac0.indicator0=On (power supply)
hw.cpuspeed=13838
hw.vendor=VMware, Inc.
hw.product=VMware Virtual Platform
hw.version=None
hw.serialno=VMware-56 4d f2 d8 92 85 eb 0a-05 61 23 ea 25 40 25 f9
hw.uuid=564df2d8-9285-eb0a-0561-23ea254025f9
hw.physmem=267939840
hw.usermem=267927552
hw.ncpufound=1

头像
leo
帖子: 2465
注册时间: 2010-01-21 3:27

帖子 leo » 2011-03-10 14:43

因为是虚拟机,这个就不好说时间了,不是没有概念,环境不一样,但是感觉上如果宿主没有繁重任务的话,编译全部的PHP不会超过3-4个小时。

junfengfan
铜 Cu
帖子: 236
注册时间: 2010-02-03 18:37

回复: OpenBSD Apache2 mysql PHP环境搭建

帖子 junfengfan » 2011-08-17 7:54

我在openbsd4.9下面,如果按照默认安装openbsd4.9,编译php时却出现
error code 1
stop in /usr/ports/www/php5/core (line 1721 of /usr/ports/infrastructure/mk/bsd.prort.mk) 等.
我用df查看了一下,/usr 空间用了99%,只有1%空间可用,是不是空间不够用了,不能编译?

头像
leo
帖子: 2465
注册时间: 2010-01-21 3:27

回复: OpenBSD Apache2 mysql PHP环境搭建

帖子 leo » 2011-08-17 19:18

junfengfan 写了:我在openbsd4.9下面,如果按照默认安装openbsd4.9,编译php时却出现
error code 1
stop in /usr/ports/www/php5/core (line 1721 of /usr/ports/infrastructure/mk/bsd.prort.mk) 等.
我用df查看了一下,/usr 空间用了99%,只有1%空间可用,是不是空间不够用了,不能编译?
看着似乎是配置文件的问题,你这里的“等”也很关键。:D

此外,如果是用了df -h,再提供具体的剩余的字节数,可能大家更容易判断。

junfengfan
铜 Cu
帖子: 236
注册时间: 2010-02-03 18:37

回复: OpenBSD Apache2 mysql PHP环境搭建

帖子 junfengfan » 2011-08-18 19:27

junfengfan 写了:我在openbsd4.9下面,如果按照默认安装openbsd4.9,编译php时却出现
error code 1
stop in /usr/ports/www/php5/core (line 1721 of /usr/ports/infrastructure/mk/bsd.prort.mk) 等.
我用df查看了一下,/usr 空间用了99%,只有1%空间可用,是不是空间不够用了,不能编译?

我把/usr空间加大到6.5G,再编译php5成功;如果不先安装mysql-server ,apache2,直接编译,当然先解压ports,能不能成功?

头像
leo
帖子: 2465
注册时间: 2010-01-21 3:27

回复: OpenBSD Apache2 mysql PHP环境搭建

帖子 leo » 2011-08-18 20:25

你这里说的“直接编译”是什么意思?是说不修改php的以下Makefile吗?
/usr/ports/www/php5/core/Makefile
/usr/ports/www/php5/extensions/Makefile

此外,我现在在5.0的current下,ports的变化比较大,在4.9下可否编译成功你在自己的4.9环境下试试不就知道了?

junfengfan
铜 Cu
帖子: 236
注册时间: 2010-02-03 18:37

回复: OpenBSD Apache2 mysql PHP环境搭建

帖子 junfengfan » 2011-12-07 10:23

openbsd5.0 amd64下面 没有 、/usr/ports/www/php5 就是php5这个目录,所以也就不能编译php5了,或者说 apache2 php5 在amd64位下不能操作。一会儿我用nginx装一下 nginx php mysql

头像
leo
帖子: 2465
注册时间: 2010-01-21 3:27

回复: OpenBSD Apache2 mysql PHP环境搭建

帖子 leo » 2011-12-08 2:28

junfengfan 写了:openbsd5.0 amd64下面 没有 、/usr/ports/www/php5 就是php5这个目录,所以也就不能编译php5了,或者说 apache2 php5 在amd64位下不能操作。一会儿我用nginx装一下 nginx php mysql
那是什么时候发的帖子?你就不能重新发个主题吗?:)
现在php早就出5.3了,5.2都不维护了。
找php目录下的 php-5.2 或者 php-5.3 目录试试。

回复

在线用户

正浏览此版面之用户: 没有注册用户 和 2 访客