Freebsd 6.0 Installation Configuration Apache+MySQL+PHP+Myphpadmin+Webmin


I. Installation of Freebsd

A. System partition

When many people use their own operating system, they do not know how to partition the system. There is no best partition scheme for them, just according to their own situation.
Below is my partition plan.

The hard disk is 120G, / (root) 1G or so, but the filter / root working directory is also here, so it’s bigger.

/ Home/data is mainly used to store the data of email/ftp users.

/ tmp 1G also takes into account the large number of temporary files, so it is also a big point.

/ Usr / 10G because to install software, and download software, I did not install GUI, so only 10 G I think enough.

/ The directory of VaR 3G stores a lot of things, such as temporary directories of logs and mail. If the space is not enough, amavisd-new can’t unlock the mail to kill virus.

 %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. Installation of basic systems

For system installation, I chose minimal (minimum system) and ports, because some unnecessary packages are not installed, reducing system volume.

And as a server, I never install GUI.

When downloading BSD, you just need to download DISK 1. The missing packages can be installed through the network.

C. Configuration System

If you do not configure the system at the later stage of installation, login as root after the system is started and run sysinstall to set it up.

Or edit the / etc / rc. conf file through the EE editor, to remind you that most services need to add startup content in / etc / rc. conf to start normally.

Set up fixed IP or automatically assign machine IP through DHCP. Using SSH client to manage the server will facilitate your work.

Attention should be paid to using SSH:

Enabling sshd

  sshdEnabled as FreeBSD InstallationStandardOne step in the installation process. To viewsshdCheck if it is enabledrc.confIn the document:



This means loading the next time the system startsOpenSSHService Proceduressshd(8)。 In addition, it can also be used manually.rc(8)Script/etc/rc.d/sshdTo startOpenSSH

/etc/rc.d/sshd start


Allow users to log inAllowUsersoption

It's usually a good idea to limit which users can log in and where to log in. UseAllowUsersOptions can easily achieve this goal. For example, if you want to allow onlyrootUsers from192.168.1.32Log in, and you'll be able to/etc/ssh/sshd_configAdd the following settings to the file:

AllowUsers [email protected]

Allow usersadminTo log in from anywhere, you only need to list the username:

AllowUsers admin

Multiple users can be specified on the same line, for example:

AllowUsers [email protected] admin

Be careful:It is important to list the users who need to log on to the machine; otherwise they will be locked out.

On completion/etc/ssh/sshd_configAfter the modification, you must tellsshd(8)Reload its configuration file by executing:

				/etc/rc.d/sshd reload


A. You can't login directly with root. You need to add a new user to the wheel group. After login with this user, you can use Su - to upgrade to the administrator.

B. Take my Secure CRT for example, Session options - > Authentication - > Primary chooses keyboard Interactive

C. If you want to use a color display like LINUX, you need to select ANSI Color from Emulation - > Terminal - > Xterm and add it to / etc / csh. cshrc


setenv LSCOLORS ExGxFxdxCxegedabagExEx 
setenv CLICOLOR yes
set autolist

Then execute


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

You can see the color catalog when you exit and re-login.

II. Updating Software Packages

The best way to use Freebsd is to install the software conveniently and also to install the latest package, which is a powerful posts system. If your system does not choose posts at installation time, how do you operate Handbook of BSD?

To update the ports, first modify the FTP address of the default download of the system:

#vi /etc/make.conf

Add the following four connection addresses, the first is HTTP connection and the rest are FTP.


CVSUP has many websites. You can choose the fastest one to update posts. Check for details.

Before using cvsup, you must connect to the Internet and install the software cvsup

A. Installing cvsup-without-gui


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

B. Update ports
After installing the cvsup software,


% /usr/local/bin/cvsup -gL 2 -h /usr/share/examples/cvsup/ports-supfile

Installation of database MySQL


There are many versions of MySQL, so you can install them on your own.

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

Add in / etc / rc. conf


Copy configuration files (not required)

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

In this note:

1. If you don't add the above content to / etc / rc. conf, you can't start MySQL manually.
2. If you want to know what the software should add to / etc / rc. conf,

Open the / usr / local / etc / rc. D directory and find the startup script for this software. Then open the file, if you have detailed instructions.

%/usr/local/etc/rc.d/ start
 Starting mysql.

How to check whether a service is started properly: 1. Check the process through ps, 2. Check the open port.

%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

When MySQL is installed, the password of the server is empty. It is recommended that you change the password as soon as you install the system.

%/ usr/local/bin/mysqladmin-u root-p password Your new password

If your server is for internal use only, it is recommended to add the following to my. CNF to increase the security of the server.


IV. Installation of Apache


1. Install Apache server

As a network today, Apache Web server is already known from the street.
% 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

Add in/etc/rc.conf:


If httpd: Can not reliably determine the

Errors in server's fully qualified domain name, using for ServerName,

Add the following at about line 144 of / usr / local / etc / apache22 / httpd. conf.


Start apahce

% /usr/local/etc/rc.d/ start
Performing sanity check on apache22 configuration:
Syntax OK
Starting apache22.

2. Installing 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       

Add in / usr / local / etc / apache22 / httpd. conf

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

Add directory index. php, about 212 lines at httpd. conf

 DirectoryIndex index.html index.php

Restart or reload Apache to make it effective

% /usr/local/etc/rc.d/ reload
Performing sanity check on apache22 configuration:
Syntax OK
Performing a graceful restart

3. Installing PHP extensions

% cd /usr/ports/lang/php4-extensions/
% make install clean

Here we suggest that if it is not necessary to try not to install the GD library to avoid wasting time, you can choose the installation module according to your own needs.

               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. Install phpMyAdmin management database

To get rid of the tedious installation process, you choose to install it manually. First download the package, then decompress it, and then copy it to / usr / local / www / Apache 22 / 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 

Change $cfg ['Servers'] [$i] ['auth_type']='config'; to

$cfg['Servers'][$i]['auth_type']     = 'http'; 
Open the page and pop up the validation window.

Open http://ip/php myadmin to manage your MySQL database


You may notice that the version you downloaded is different from the one I downloaded. It can’t be copied.
Setting phpMyAdmin
PHpMyAdmin-2.8.1 Port Installation Method.
# whereis phpmyadmin
phpmyadmin: /usr/ports/databases/phpmyadmin

cd /usr/ports/databases/phpmyadmin
make install clean
#cd /usr/local/www/phpMyAdmin/
Get intophpmyadminThe libraries directory below!
Modify config. default. PHP
#vi libraries/config.default.php

Find $cfg [‘PmaAbsoluteUri’]=’;
Modify it to $cfg [‘PmaAbsoluteUri’]=’http://your 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’]      = ”;
Write down your Mysql username and password! Save out!

Because the PATH of phpMyAdmin is: / usr / local / www / phpMyAdmin
So we need to build an Alias in APACHE:
#vi /usr/local/etc/apache22/httpd.conf
Add the following to the Alias group:
    Alias /phpmyadmin “/usr/local/www/phpMyAdmin/”
    <Directory /usr/local/www/phpMyAdmin/>

    Order allow,deny
    Allow from all

Save Exit.
Pop up the validation window.Modify/usr/local/www/phpMyAdmin/libraries/config.default.php
In: $cfg [‘Servers’] [$i] [‘auth_type’]= “config”
Replace with:
$cfg[‘Servers’][$i][‘auth_type’]     = ‘http’;
# /usr/local/etc/rc.d/ reload
Then usehttp://yourIP/phpmyadmin access!

5. Setting up a virtual host using the same IP:

Cancel the central host and shield the well number in front of Server Name.

Add virtual host settings, for example, assuming you’re working on a domain namewww.domain.tldProvide services, and you want to add a name to the same IP addresswww.otherdomain.tldThe virtual host, you just need to be inhttpd.confAdd the following:

NameVirtualHost *

<VirtualHost *>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain

<VirtualHost *>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain

It's the same as adding an alias.

6 Install WEBMIN

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

make install clean

cd /usr/local/etc/webmin

sh start

Then visit http://IP:10000

Recommended Today

Java Engineer Interview Questions

The content covers: Java, mybatis, zookeeper, Dubbo, elasticsearch, memcached, redis, mysql, spring, spring boot, springcloud, rabbitmq, Kafka, Linux, etcMybatis interview questions1. What is mybatis?1. Mybatis is a semi ORM (object relational mapping) framework. It encapsulates JDBC internally. During development, you only need to pay attention to the SQL statement itself, and you don’t need to […]