当前位置: 移动技术网 > 科技>操作系统>Unix > Freebsd 6.0安装配置Apache+MySQL+PHP+Myphpadmin+Webmin

Freebsd 6.0安装配置Apache+MySQL+PHP+Myphpadmin+Webmin

2018年03月18日  | 移动技术网科技  | 我要评论

一、安装freebsd

a、系统分区

很多人在使用自己的作业系统时,不知道如何对系统分区,对于分区方案没有最好的,只是跟据自己的情况去分。
下面是我的分区方案。

硬盘为120g ,/(根)1g 左右就差不多了,但考滤到/root 工作目录也在这里,所以分大一点。

/home/data 主要是用来存放email /ftp用户的数据

/tmp 1g 也是考虑到临时文件多,所以给大也点。

/usr/ 10g 因为要安装软件,还有下载的软件,我没有装gui 所以只分了10g我认为足够了。

/var 3g这个目录存放的东西比较多,如日志、邮件的临时目录,如果空间不够amavisd-new 无法解开邮件进行杀毒。

 %df -h
  filesystem   size    used    avail   capacity   mounted on
  /dev/ad0s1a   1.9g   481m   1.3g    26%       /
devfs     1.0k    1.0k    0b      100%   /dev
/dev/ad0s1g    92g    353m    84g    0%     /home/data
/dev/ad0s1e    989m    224k    910m    0%    /tmp
/dev/ad0s1f    9.7g    1.8g    7.1g    20%    /usr
/dev/ad0s1d     2.9g   105m    2.6g     4%    /var
b、安装基本系统

对于系统的安装,我选择了minimal(最小系统)和ports ,因为有些没必要的包就不装,减少系统体积,

另外作为一台服务器,我从来不装gui 。

下载bsd时,只需要下载disk 1 就行了,缺少的软件包可以通过网络安装。

c、配置系统

如果你在安装后期没有配置系统,在系统启动完成后以root的身份登陆系统,运行sysinstall 进行设置,

或通过ee编辑器编辑/etc/rc.conf文件,在这里提醒各位,一会大多数服务都需要在/etc/rc.conf加入启动内容才能正常启动。

设置好固定ip,或通过dhcp 自动分配置机器ip。使用ssh 客户端进行管理服务器将会为你的工作提供方便。

使用ssh 要注意:

启用 sshd

  sshd 的启用是作为 freebsd 安装中 standard 安装过程中的一步来进行的。 要查看 sshd 是否已被启用, 请检查 rc.conf 文件中的:

sshd_enable="yes"
 

  这表示在下次系统启动时加载 openssh服务程序 。 此外,也可以手动使用 脚本 /etc/rc.d/sshd 来启动 openssh

/etc/rc.d/sshd start

 

允许用户登录 allowusers 选项

  通常限制哪些用户能够登录, 以及从何处登录会是好主意。 采用 allowusers 选项能够方便地达到这一目的。 例如, 想要只允许 root 用户从 192.168.1.32 登录, 就可以在 /etc/ssh/sshd_config 文件中加入下述设置

allowusers root@192.168.1.32

  要允许用户 admin 从任何地方登录, 则只需列出用户名:

allowusers admin

  可以在同一行指定多个用户, 例如:

allowusers root@192.168.1.32 admin

注意: 列出需要登录机器的用户很重要; 否则他们将被锁在外面。

  在完成对 /etc/ssh/sshd_config 的修改之后您必须告诉 重新加载其配置文件, 方法是执行:

#
				/etc/rc.d/sshd reload

 

a、不能用root直接登陆,需要添加一个新用户,指定到wheel 组,用此用户登陆后用使用 su - 提升到管理员。

b、 以我的securecrt 为例,session options ->authentication ->primary 选择keyboard interactive

c、如果你要使用像linux 一样的彩色显示,需要把 emulation -> terminal ->xterm 选中ansi color 并在/etc/csh.cshrc加入

 

setenv lscolors exgxfxdxcxegedabagexex 
setenv clicolor yes
set autolist

然后执行

 

sed -i.bak -e s/set\ prompt/#set\ prompt/g /root/.cshrc

退出重新登陆即可看到彩色目录了。

二、更新软件包

采用freebsd 最好的地方就是安装软件方便,还可以装到最新的软件包,这就是强大的posts 系统。如果你的系统安装时没有选择posts ,具休如何操作看bsd 的handbook.

对ports 进行更新,首先修改系统默认下载的ftp地址:

#vi /etc/make.conf

添加下列四个连接地址,第一个为http连接其余都是ftp.

master_site_override?= \
\
ftp://ftp.freebsdchina.org/pub/freebsd/ports/distfiles/${dist_subdir}/ \
ftp://ftp.tw.freebsd.org/pub/ports/distfiles/${dist_subdir}/ \
ftp://freebsd.csie.nctu.edu.tw/pub/ports/distfiles/${dist_subdir}/ \

cvsup 的站点很多,你可以选择离你最快的站点去更新posts ,具体查看 freebsd.org /freebsdchina.org.cn

在使用cvsup之前你必须连接到互联网,并需要安装cvsup 这个软件

a、安装cvsup-without-gui

 

 % cd /usr/ports/net/cvsup-without-gui/
 % make install clean
 

b、更新ports
安装完cvsup软件后,

 

% /usr/local/bin/cvsup -gl 2 -h cvsup4.freebsdchina.org /usr/share/examples/cvsup/ports-supfile
三、安装数据库 mysql 

 

mysql 版本很多,大家可以据自己需要自行安装。

%cd /usr/ports/databases/mysql41-server/
%make install clean

在/etc/rc.conf 加入

mysql_enable="yes"

复制配置文件(非必需)

cp /usr/local/share/mysql/my-small.cnf /usr/local/etc/my.cnf

在此说明:

1、如果不在/etc/rc.conf 加入以上内容,手工是无法启动mysql的。
2、如果你想知道这个软件应该在/etc/rc.conf加入什么内容,

打开/usr/local/etc/rc.d 目录,找到此软件的启动脚本。然后打开文件,如果有详细的说明。

%/usr/local/etc/rc.d/mysql-server.sh start
 starting mysql.

如何去检查一个服务是否正常启动:1、通过ps查看进程,2、检查所打开的端口。

%ps aux|grep mysql
mysql 94899  0.2  0.5  1644  1240  p0  s     3:52pm   0:00.07 /bin/sh /usr/local/bin/mysqld_safe --
mysql 94919  0.0 10.8 55564 27428  p0  s     3:52pm   0:01.54 /usr/local/libexec/mysqld --defaults-
%

%netstat -an|grep 3306
tcp4       0      0  *.3306                 *.*                    listen

mysql安装时,服务器的密码为空,建议你装好系统后,第一时间去更改密码。

% /usr/local/bin/mysqladmin -u root -p password 你的新密码 
enter password: 

如果你服务器只供本站内部使用建议在 my.cnf 里加入下面内容,以增加服务器的安全性。

[mysqld]
bind_address=127.0.0.1
 
四、安装apache 1、安装apache server 作为网络的今天apache web服务器已经是街知港闻了。
				
% cd /usr/ports/www/apache22/
% make install clean
 
     │                     options for python 2.4.3                       │
     │ │ [x] threads          enable thread support                     │ │
     │ │ [ ] huge_stack_size  use a larger thread stack                 │ │
     │ │ [x] ucs4             use ucs4 for unicode support              │ │
     │ │ [x] pymalloc         use python's internal malloc              │ │
     │ │ [ ] ipv6             enable ipv6 support                       │ │
     │ │ [ ] fpectl           enable floating point exception handling
 

在/etc/rc.conf 中加入:

apache22_enable="yes"

如果启动时出现httpd: could not reliably determine the

server's fully qualified domain name, using mail.sharesky.cn for servername 的错误,

在/usr/local/etc/apache22/httpd.conf 约第144行的位置加入下面的内容。

servername mail.extmail.org

启动apahce

% /usr/local/etc/rc.d/apache22.sh start
performing sanity check on apache22 configuration:
syntax ok
starting apache22.
2、安装php
% cd /usr/ports/www/mod_php4/
% make install clean
                  options for mod_php4 4.4.2_1,1                    x  
               x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x  
               x x         [ ] debug      enable debug                            x x  
               x x         [x] multibyte  enable zend multibyte support           x x  
               x x         [ ] ipv6       enable ipv6 support                     x x  
               x x         [x] openssl    build static openssl extension       

在/usr/local/etc/apache22/httpd.conf 里加入

addtype application/x-httpd-php .php
addtype application/x-httpd-php-source .phps

加入目录索引 index.php,约在httpd.conf 的212行

 directoryindex  index.php

restart或reload apache 使之生效

% /usr/local/etc/rc.d/apache22.sh reload
performing sanity check on apache22 configuration:
syntax ok
performing a graceful restart

3、安装php 扩展

% cd /usr/ports/lang/php4-extensions/
% make install clean
在这里建议大家,如果没有必要尽量不要安装gd库免得浪费时间,大家可据自己需要选择安装模块
               lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
               x                 options for php4-extensions 1.0                    x  
               x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x  
               x x  [ ] bcmath       bc style precision math functions            x x  
               x x  [x] bz2          bzip2 library support                        x x  
               x x  [ ] calendar     calendar conversion support                  x x  
               x x  [ ] crack        crack support                                x x  
               x x  [x] ctype        ctype functions                              x x  
               x x  [x] curl         curl support                                 x x  
               x x  [ ] dba          dba support                                  x x  
               x x  [ ] dbase        dbase library support                        x x  
               x x  [ ] dbx          dbx support                                  x x  
               x x  [ ] dio          direct i/o support                           x x  
               x x  [ ] domxml       dom support                                  x x  
               x x  [ ] exif         exif support                                 x x  
               x x  [ ] fileinfo     fileinfo support                             x x  
               x x  [ ] filepro      filepro support                              x x  
               x x  [ ] fribidi      fribidi support     
			     x x  [x] ftp          ftp support                                  x x  
               x x  [ ] gd           gd library support                           x x  
               x x  [x] gettext      gettext library support                      x x  
               x x  [ ] gmp          gnu mp support                               x x  
               x x  [x] iconv        iconv support                                x x  
               x x  [ ] imagick      imagemagick support                          x x  
               x x  [x] imap         imap support                                 x x  
               x x  [ ] interbase    interbase 6 database support (firebird)      x x  
               x x  [ ] ldap         openldap support                             x x  
               x x  [x] mbstring     multibyte string support                     x x  
               x x  [ ] mcal         modular calendar access library support      x x  
               x x  [x] mcrypt       encryption support                           x x  
               x x  [ ] mcve         mcve support                                 x x  
               x x  [ ] mhash        crypto-hashing support                       x x  
			     x x  [ ] ming         ming shockwave flash support                 x x  
               x x  [ ] mnogosearch  mnogosearch support                          x x  
               x x  [ ] mssql        ms-sql database support                      x x  
               x x  [x] mysql        mysql database support                       x x  
               x x  [ ] ncurses      ncurses support (cli only)                   x x  
               x x  [ ] odbc         unixodbc support                             x x  
               x x  [x] openssl      openssl support                              x x  
               x x  [ ] oracle       oracle support                               x x  
               x x  [x] overload     user-space object overloading support        x x  
               x x  [ ] panda        panda support                                x x  
               x x  [ ] pcntl        pcntl support (cli only)                     x x  
               x x  [x] pcre         perl compatible regular expression support   x x  
               x x  [ ] pdf          pdflib support (implies gd)                  x x  
               x x  [ ] pfpro        payflow pro support                          x x  
			     x x  [ ] pgsql        postgresql database support                  x x  
               x x  [x] posix        posix-like functions                         x x  
               x x  [ ] pspell       pspell support                               x x  
               x x  [ ] readline     readline support (cli only)                  x x  
               x x  [ ] recode       recode support                               x x  
               x x  [x] session      session support                              x x  
               x x  [ ] shmop        shmop support                                x x  
               x x  [ ] snmp         snmp support                                 x x  
               x x  [ ] sockets      sockets support                              x x  
               x x  [ ] sybase_ct    sybase database support                      x x  
               x x  [ ] sysvmsg      system v message support                     x x  
               x x  [ ] sysvsem      system v semaphore support                   x x  
               x x  [ ] sysvshm      system v shared memory support               x x  
               x x  [x] tokenizer    tokenizer support                            x x  
			     x x  [ ] wddx         wddx support (implies xml)                   x x  
               x x  [x] xml          xml support                                  x x  
               x x  [ ] xmlrpc       xmlrpc-epi support                           x x  
               x x  [ ] xslt         xslt sablotron support                       x x  
               x x  [ ] yaz          yaz support (ansi/niso z39.50)               x x  
               x x  [ ] yp           yp/nis support                               x x  
               x x  [ ] zip          zip support                                  x x  
               x x  [x] zlib         zlib support                                 x x  
 
 
# vi /usr/local/www/apache22/data/test.php 
输入:
<?php phpinfo(); ?> 4、安装phpmyadmin 管理数据库

为了去除无聊的安装过程,这里选择手工安装,先下载软件包,然后解压,再复制到/usr/local/www/apache22/data 下面

%cd /usr/ports/databases/phpmyadmin/
%make fetch
%cd /usr/ports/distfile
%tar jxvf phpmyadmin-2.7.0-pl2.tar.bz2
%cp -r /usr/ports/distfiles/phpmyadmin-2.7.0-pl2 /usr/local/www/apache22/data/phpmyadmin
%cd /usr/local/www/apache22/data/phpmyadmin/
%ee config.default.php 

将$cfg['servers'][$i]['auth_type'] = 'config'; 改为

$cfg['servers'][$i]['auth_type']     = 'http'; 
打开页面弹出验证窗口。

打开http://ip/phpmyadmin 就可以管理你的mysql 数据库了

推出保存 #chmod 755 test.php
大家注意,可能你下载的版本与我下载的不一样,不能照搬。 设置phpmyadmin phpmyadmin-2.8.1 版的port 安装方法. # whereis phpmyadmin
phpmyadmin: /usr/ports/databases/phpmyadmin
cd /usr/ports/databases/phpmyadmin make install clean   #cd /usr/local/www/phpmyadmin/ 进入phpmyadmin下的libraries 目录! 修改 config.default.php #vi libraries/config.default.php
找到$cfg['pmaabsoluteuri'] = '';
修改成 $cfg['pmaabsoluteuri'] = 'http://你的ip/phpmyadmin';
找到
$cfg['servers'][$i]['auth_type']     = 'config';    // authentication method (config, http or cookie based)?
$cfg['servers'][$i]['user']          = 'root';      // mysql user
$cfg['servers'][$i]['password']      = '';
写上你的mysql用户名and密码!保存退出!
因为phpmyadmin的path 是:/usr/local/www/phpmyadmin 所以我们需要在apache里面建立一个alias: #vi /usr/local/etc/apache22/httpd.conf 在alias 组加入下列内容: ***************************************************        alias /phpmyadmin "/usr/local/www/phpmyadmin/"
    <directory /usr/local/www/phpmyadmin/>
    order allow,deny
    allow from all
    </directory> ***************************************************
保存退出.
弹出验证窗口。 修改/usr/local/www/phpmyadmin/libraries/config.default.php 中的:$cfg['servers'][$i]['auth_type']     = "config" 改成: $cfg['servers'][$i]['auth_type']     = 'http';     # /usr/local/etc/rc.d/apache22.sh reload   然后用 ip/phpmyadmin访问!

5 使用同一个ip的虚拟主机设置方法:

取消中心主机,在servername 前面加井号屏蔽. 

添加虚拟主机设置,比如说,假设你正在为域名提供服务, 而你又想在同一个ip地址上加一个名叫www.otherdomain.tld的虚拟主机, 你只需在httpd.conf中加入以下内容:

namevirtualhost *

<virtualhost *>
servername www.domain.tld
serveralias domain.tld *.domain.tld
documentroot /www/domain
</virtualhost>

<virtualhost *>
servername www.otherdomain.tld
documentroot /www/otherdomain
</virtualhost>

和添加别名是雷同的.

6 安装webmin

mail# whereis webmin
webmin: /usr/ports/sysutils/webmin
cd /usr/ports/sysutils/webmin

make install clean

cd /usr/local/etc/webmin

sh start

然后访问 http://ip:10000

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网