FreeBSD Software Installation Method

Source: Internet
Author: User
Tags ftp site mysql code rehash
Software Installation

After FreeBSD is installed, you must install other software not included in FreeBSD. There are many ways to install software on FreeBSD. We will introduce them one by one.

Includes the following necessary software installation issues:

* Advantages and disadvantages of various installation methods.
* How to use a package.
* How to use port.
* How to compile software by yourself using traditional installation methods.

Introduction 10.1

Traditionally, there are several steps to install other software on a UNIX system:

* Download the software, which may be a binary file or an original code.
* Decompress the file, which is usually compressed using tar or gzip.
* Read the description file in the directory, which may be readme or DOC/, to learn how to install the software.
* If the downloaded code is the original code, you may need to edit the makefile or execute configure before compiling the software.
* Test and install the SDK.

Of course, we can install software in the traditional way on FreeBSD, but there are simpler options. FreeBSD provides two simple software installation methods: Package and ports.

The so-called pakcage is something someone else can help youProgramCompile it into a binary file and define where to install it. We only need to download a compression file and use the pkg_add command to quickly install the software on FreeBSD. This is the simplest step for installing software, and the installation is also the most standard. It is not flexible to modify and compile the original code as needed.

The port uses the original code to install the software. You only need to enter the Software Directory to be installed in/usr/ports/and run the command "make install" to complete the installation. FreeBSD has helped us define the steps required to install the software and other required suites. Whether it is package or ports, the software will automatically help you install it only when it depends on other software. All installed software will be recorded in/var/DB/PKG. If we want to remove the software in the future, we can add the software name with a simple command pkg_delete.

Now that port is so easy to use, why does FreeBSD require both package and ports? Let's compare the advantages of ports and package:

Advantages of package:

* A compiled compressed file is usually smaller than the file containing the original code.
* You do not need to compile pakcage any more. If your computer is slow, you can save a lot of time by installing large software such as KDE and gnome without compiling.
* When you use a package to install software, you do not have to know the software used for compiling on FreeBSD and its Process in advance.

Advantages of ports:

* In order to run the package on most computers, the compatibility issue is considered. The compilation is usually conservative. You can modify ports based on your system, such as using Pentium III or athlon processors.
* When compiling a package, the function of the software has been restricted and cannot be expanded as needed. For example, Apache has many functions that can be mounted during compilation. When using ports for installation, you can modify them as needed.
* We can use newer software by updating the port tree, while the package is usually only release with the system.
* Some software does not allow distribution of binary files. You can only download the original code.
* With the original code, you can modify and apply it on your own.
* Some people like to have the original code. They can read it and learn from it.

Next, we will describe how to use packages and ports.

10.2 use package

10.2.1 install package

There are two ways to install the package. The first is to install the package using sysinstall (the screen we saw when installing FreeBSD), and the other is to install the package manually. When using sysinstall for installation, We must select the installation source. The most common sources are networks and optical disks. However, due to the limited size of the optical disk, there are not many package software contained in the FreeBSD installation disc. Therefore, I usually choose to use the network for installation. To use manual installation, you must manually capture the required files and install them with instructions. The following two methods are described respectively:

Method 1: Use sysinstall

Suppose we want to install the software pine on FreeBSD, first we need to execute sysinstall to enter the installation screen:

# Sysinstall

Figure 10-1

Then select the configure option to go to the screen in Figure 10-2:

Figure 10-2

Select the packages option to install the package:

Figure 10-3

In Figure 10-3, we must select the installation source. Here we select FTP, and we can find more software from ftp. After FTP is selected, the figure 10-4 is displayed. Let's select the FTP platform to use:

Figure 10-4

Select "url" from the FTP site to be used. Next, a window is displayed asking us to enter the platform address, as shown in Figure 10-5. If we want to use the platform of the Alibaba Cloud account, enter freebsd.csie.nctu.edu.tw/pub/releases/ I /:

Figure 10-5

After entering the platform, you will be asked if you want to use the current network settings. If the network is connected, select YES. Otherwise, select no to set the network. Next, a software category menu is displayed. This category menu places different software categories under different options, where all is where all software is located, ranging from 10 to 6.

Figure 10-6

We take installing the mail software pine as an example. Because pine is under the mail category, we select mail. If you want to install pine in Chinese version, select Chinese option instead of mail. After mail is selected, all software under the mail category will appear. We select pine-4.58, 10-7:

Figure 10-7

After pine is selected, you can select "OK" to return to the previous category screen. After selecting other software to be installed in this way, you can select "Install" to install it. After installing is selected, a list of all selected software is displayed, ranging from 10 to 8. If you want to continue the installation, select OK.

Figure 10-8

Method 2: manual Installation

If you install the package manually, You must retrieve the package you want to install. As long as it is a package, its extension is. tgz. We can use the pkg_add command to install it. Below is a simple example of using package to install the lsof-4.66.1.tgz:

# Ftp-A freebsd.csie.nctu.edu.tw
Connected to freebsd.csie.nctu.edu.tw.
220 ---------- welcome to pure-ftpd ----------
220-you are user number 139 of 200 allowed.
220-local time is now. server port: 21.
220-only anonymous FTP is allowed here
220-ipv6 connections are also welcome on this server.
220 you will be disconnected after 15 minutes of inactivity.
331 Any password will work
230 any password will work
Remote system type is UNIX.
Using binary mode to transfer files.
Ftp> Cd/pub/FreeBSD/ports/packages/sysutils/
250 CWD command successful.
Ftp> Get lsof-4.71.tgz
Local: lsof-4.71.tgz remote: lsof-4.71.tgz
227 entering passive mode (140,113, 17,209,189, 16)
150-accepted data connection
150 96.1 Kbytes to download
100% | ************************************** * ***************** | 98372 136.87 kb/s ETA
226-file successfully transferred
226 0.362 seconds (measured here), 265.35 Kbytes per second
98372 bytes encoded ed in (136.70 kb/s)
Ftp> bye
221-goodbye. You uploaded 0 and downloaded 97 Kbytes.
221 logout.
# Pkg_add lsof-4.71.tgz

To install software using a package, you must first obtain the software you want to install. We can first obtain it through FTP on the FTP sites of different universities. The sub-file of packaeg is. tgz, which can be obtained from ports/packages on various FTP sites. The FTP site of the capital is put in the ftp://freebsd.csie.nctu.edu.tw/pub/ports/packages; the FTP site of the central capital is put in the ftp://freebsd.csie.ncu.edu.tw/FreeBSD/ports/packages. After entering the ports directory, we will find a bunch of directories. You can select which directory to use based on your system version. The packages directory contains the latest packages. If you want to use packages-5.4-release packages, you can choose to enter the packages-5.4-release directory. After entering this directory, there are a bunch of directories. The directory structure is the same as that in/usr/ports/in your system. Each directory is a software classification, and the "all" directory is all software.

If you only know the name of the software you want to install, but you do not know the version and the complete file name, for example, you want to download the popa3d software, but you do not know which version it is, you can first go to the all directory and then query in the following column:

Ftp> ls popa3d *
227 entering passive mode (140,113,209,200,159, 54)
150 opening ASCII mode data connection for/bin/LS.
-R -- 1 FTP csie 19007 Nov 11 12:43 popa3d-0.6.4.1.tgz
226 transfer complete.
Ftp> Get popa3d-0.6.4.1.tgz

Find the version 0.6.4.1 you want to download. Then, use the GET command to retrieve the software and exit.

Then you can use the pkg_add popa3d-0.6.4.1.tgz to install the software.

10.2.2 manage a package

If we regret it and want to remove the software we 've installed, run the command pkg_delete popa3d-0.6.4.1 to remove the popa3d-0.6.4.1, all the software we installed will be recorded in the/var/DB/PKG directory.

We can use the command pkg_info to obtain the software information. For example, after we download a package, you want to know the information of the software, in terms of popa3d-0.6.4.1.tgz, if we want to know its information, you use the following command to get it:

# Pkg_info popa3d-0.6.4.1.tgz

You can also press pkg_info to find out which software you have installed.

10.3 use ports

If you want to install the software using ports, you must first check whether the/usr/ports directory is installed. If not, use/STAND/sysinstall to install the ports directory:

1. Run/STAND/sysinstall as root
2. Select configure and press ENTER
3. Select distributions and press ENTER
4. Select ports and press the Space key.
5. Select exit and press Enter.
6. Select whether you want to install it from CDROM or FTP.
7. Follow the menu and finally exit sysinstall.

Or we can also go to the http://www.freebsd.org/ports/ to manually capture the port.tar.gz file and put it under/usr. Run the following commands to install the SDK:

# Cd/usr
# Tar zxvf port.tar.gz

Now you can go to the/usr/ports directory and install the software.

Every software usually has an independent directory, and there are some files in the directory, each file has its specific purpose, which is briefly listed as follows:
You can modify this file to set the parameters when compiling and installing the software.
For readme.html, you can view the software description under all ports directories through readme.html.
Distinfo indicates the files required for installation and MD5 check data.
PKG-Comment simple software description.
PKG-descr is a more detailed description. We can usually find the location of the software webpage in it, so that we can get more information on the webpage.
PKG-plist: list the software installation list, where it will be placed on the hard disk after installation.

If you want to install a software without knowing its directory location, you can use the whereis command to find it. For example, if you want to install Qpopper, you can use whereis Qpopper to find its directory. Or if we only know the keywords of a program and do not know which directory it is placed in, we can use the following commands:

# Cd/usr/Ports
# Make search key = 'keyword'

After entering this directory, the simplest installation method is to directly install the software, and the system will automatically capture the required software on the network to come back for installation. When installing ports, the file search sequence for make is:/usr/ports/distfiles,/CDROM/ports/distfiles, and download from the network. If you do not use the network for installation, you can capture the software and place it under/usr/ports/distfiles/. In this way, when we make install, it will not capture files on the network. If the file you want is on a CD, you must mount the file drive to/CDROM before installing the software .. However, some software does not search for files on the CD. Therefore, we recommend that you copy the/ports/distfiles directory to the/usr/ports/distfiles directory on the CD, or connect the files to the network first.

When a file is obtained through the network, the preset file capturing server is usually abroad. Therefore, you can modify/etc/make. conf to specify the FTP site in China, such as editing/etc/make. conf and add:

Master_site_backup? = \
Ftp://freebsd.csie.ncu.edu.tw/distfiles/##dist_subdir }/\
Ftp://freebsd.csie.nctu.edu.tw/pub/distfiles/?#dist_subdir= }/
Master_site_override? =$ {Master_site_backup}

After installing ports, run the "make clean" command to clear the files generated during the compilation process. We recommend that you do this. Otherwise, a large number of files are generated in some processes, which is amazing. If you have installed a bunch of software before you think that there is no make clean, it doesn't matter. When installing ports, the files in the compilation process are stored in the work directory under the Software Directory. We can use the following commands to find out all the software that has not made clean and delete the temporary data:

# Find/usr/ports-depth-name work-exec Rm-RF {}\;

If you use network-based installation, the downloaded original code will exist in/usr/ports/distfiles. After you make clean, it will not be cleared.

After installing the software, you only need to make deinstall it in the ports directory of the software. Please note that do not make deinstall in the/usr/ports directory. This will remove "all" software.

There are also some less commonly used make methods, which are briefly described as follows:

Make fetch: capture the required original file.
Make fetch-list: displays the files required for installation.
Make checksum: capture the original file and check its correctness with MD5.
Make extract: capture and unlock the original file.
Make configure: Configure but do not continue to compile.
Make all install: capture the original file, compile and install it.
Make reinstall: if an unexpected interruption occurs, use this command to continue installation.
Make package: pack the ports into packages.

After installing the new software, if the shell is CSH or tcsh, we may have to execute the command rehash to recreate the hash table, you can find the installed program in the specified instruction path. Otherwise, you must enter the complete path of the program or log on again to use the program.

We can see the installed software in the/var/DB/PKG directory. Each software has a directory containing the software installation information, contains the Software Description and directories to which the software is installed. Some software requires you to install a set of software before you install it. If you do not install the software required by it in advance, the software will usually automatically help you install it. So we will see some software under/var/DB/pkg that we did not install. Since software may depend on each other, how do we know the relationship between these software? The pkg_tree software allows us to view the relationship between software. We can use port to install this software:

# Cd/usr/ports/sysutils/pkg_tree
# Make install clean

Then we can use pkg_tree | more to see the relationship between various software (don't forget to rehash it ).

10.4 update the port tree

When FreeBSD release is enabled, all software in the ports directory is tested in advance. Because different software is often mutually dependent, sometimes we need to install software A, and the system will automatically capture other required software. These software versions may depend on each other. Therefore, before release, ports suspends updates to each software version to ensure that the release version works properly.

However, after the release, the software version in the ports directory may have been updated. Some software version updates may only add new functions, and some updates may involve system security. If you want to use ports to install the latest software version, you can use some tools to update the entire port tree before installing the software.

Sometimes, after the port tree is updated, some software may fail to be installed due to version dependency issues, you only need to re-update the port tree in a few days.

The method for updating the port tree is very simple. We can use CVSup to keep ports up-to-date. CVSup is a set of tools used to maintain the synchronization between the original software code and the development team. After we execute CVSup, it checks and updates the version of the original code to the configured software server over the network. We can use CVSup to update the port tree, or update the FreeBSD original code in the/usr/src directory.

First, we must install CVSup because we do not use graphical interfaces, so install CVSup-without-Gui:

# Cd/usr/ports/NET/CVSup-without-Gui
# Make install clean

There is a configuration file example in the system that uses CVSup to update the port tree. You can directly modify it or copy it before modifying it. Copy the sample file to/root and modify it:

# Cp/usr/share/examples/CVSup/ports-supfile/root/

Next, open/root/ports-supfile with the file editing software and find the host part to set the CVSup server to be used.

# defaults that apply to all the collections
# important: change the next line to use one of the CVSup mirror sites
# listed at http://www.freebsd.org/doc/handbook/mirrors.html.
* default host = cvsup.tw.freebsd.org
* default base =/usr
* default prefix =/usr
* default release = CVS tag =.
* default Delete use-rel-suffix
# If your network link is a T1 or faster, comment out the following line.
* default compress

# ports collection.
# the easiest way to get the ports tree is to use the "ports-all"
# mega-collection. it uses des all of the individual "ports-*"
# collections,
ports-all
# These are the individual colleal that make up "ports-all ". if you
# use these, be sure to comment out "ports-all" above.
# Be sure to always CVSup the ports-base collection if you use Y of the
# other individual collections below. ports-base is a mandatory collection
# For the ports collection, and your ports may not build correctly if it
# is not kept up to date.
# ports-base
# ports-archivers
# ports-astro
# ports-audio
# ports-benchmarks
......... ............

In the above example, we set the CVSup server to cvsup.tw.freebsd.org. This server is maintained by the Bank of Communications staff. You can use other cvsup1 ~ Cvsup13.tw.freebsd.org server. For example, cvsup3 is located at Sun Yat-sen University, and cvsup13 is a giga and ultra-Media Server. The ports-all in the last line indicates that all files under the/usr/ports directory are to be updated. You can also update only some of the directories. You only need to mark ports-all as the well font size "#" and remove the # Of the ports-base line in the file, then you can remove the other # font size according to the directory you want to update. For example, we only need to update the/usr/ports/WWW directory and Mark ports-all as #. Then we need to remove ports-base and ports-WWW starting #.

After setting, we can start to update ports.

# CVSup-g-L 2/root/ports-supfile

In the preceding command, parameter G indicates that no graphic interface is used, and parameter l and the number 2 following it indicate the record details of the update process. The number ranges from 0 ~ 2. the last file name indicates the configuration file to be used.

Before using ports to install software, it is a good habit to execute CVSup. You can get the latest version of the software at any time, but your machine must be connected to the Internet before it can be updated.

10.5 use portupgrade to update software

What if a new version of the software comes out after a bunch of software is installed using port? FreeBSD's ports management tool has a handy software-portupgrade.

Normally, software in ports is dependent. For example, Apache will automatically install libexpat, anti-spam software will automatically install a bunch of Perl modules. When updating the software, we must confirm that all the dependent software is updated together after the update, so as not to cause the update to fail. However, this does not mean that we must update the software frequently. We recommend that you use portupgrade only when necessary to upgrade the software. Do not run it once if nothing happens. Because the software is not the latest, it is the best. No one can ensure that the updated software still maintains what you expected.

Portupgrade retains your original profile when updating the software. For example, when updating Apache, it retains the settings of httpd. conf. Using portupgrade is a safer way to update the ports software.

After you use CVSup to update the port tree, run the following command to check whether the software version currently installed is the same as the version in the port tree:

# Pkg_version-V
Ispell-3.2.06_12 = up-to-date with port
Jasper-1.701.0 = up-to-date with port
Jpeg-6b_3 = up-to-date with port
Kde-3.3.0 <needs updating (port has 3.3.1)
Kdeaccessibility-3.3.0 <needs updating (port has 3.3.1)
...

The software to be updated in the above output will contain the word "<needs updating. You can select the software you want to update and then use portupgrade to update the software. First, we must use ports to install portupgrade:

# Cd/usr/ports/sysutils/portupgrade
# Make install clean

If you only want to upgrade a software, not all dependent software, you only need to use portupgrade pkgname. If you want to upgrade all other software that is dependent on the software, you can add the parameter-R. If you want to update dependent software that contains dependent software, you can use the-R parameter. In addition, you can use the parameter-m to require more parameters to be passed in when compiling (make) ports. You can also use the parameter-F to force updates even if the version is the same.

Suppose the software we want to update is a perl-5.8, we can use the following command to update:

# Portupgrade-RF "perl-5.8. *"-M "enable_suidperl = yes"

Tips

We do not recommend that you use portupgrade to install all software, especially parameter-a to update all software. On the one hand, new software may not be better, on the other hand, it is difficult for us to ensure that the updated software will work normally. In addition, when installing the software, we may not only use make install, but also add some parameters after make to support more features. Using portupgrade directly may not always retain these features. We will introduce portupgrade to make it easier for you to update Perl when installing open webmail.

10.6 traditional installation methods

After introducing FreeBSD's exclusive package and port installation methods, we will introduce in detail how to install software on traditional Unix machines.

Sometimes, the software we want to install may not be in the port, or the software version in the port has not been updated. In this case, we must use the traditional Installation Method to install the software. Basically, the traditional installation method, as mentioned at the beginning of this chapter, requires the following steps:

* Download the software from the software website or other FTP sites, which may be a binary file or original code.
* Decompress the file, which is usually compressed by tar, Gzip, or Bzip2.
* Read the description file in the directory, which may be readme or DOC/, to learn how to install the software.
* If the downloaded code is the original code, you may need to edit the makefile or execute configure before compiling the software.
* Test and install the SDK.

Take MYSQL as an example.

Download and decompress

First, download the latest source code from the MySQL website. Generally, most of the original code uses the command tar package as an archive and then compressed into gzip or Bzip2 format. Therefore, most of the file extensions you download are .tar.gz,. tgz, or .tar.bz2.

The file with the extension .tar.gz or. tgz is in tar + GZIP format, and the original MySQL code is of this type. Run the following command to decompress the package:

# Tar zxvf mysql-4.1.13.tar.gz

If the file extension is .tar.bz2, it is in tar + Bzip2 format. in this format, we can use the following command to decompress the file:

# Tar jxvf mysql-4.1.13.tar.bz2

We can see that the above two formats can be decompressed using tar, but the GZIP format must use the parameter Z, while the Bzip2 format must use the parameter J. Other parameters of the command tar indicate that X indicates unzipping, V indicates the unzipping process, and F indicates the name of the file to be decompressed.

After uninstallation, we can proceed to the next step to start installation.

View instructions

Each software is similar in installation, but some software may have its own unique steps in addition to the general installation process. Therefore, before installation, we must first take a look at the instructions to learn how to install.

Most open source code software may have readme or install files to describe the installation steps. Some software may have other files, but we can know which file should be viewed from the file name. Take MYSQL as an example. In its original code packaging, there is a file named install-source, which should be the installation instruction file we want to see. After opening this file in the document editor, you can see some installation instructions. MySQL instructions are quite detailed, but we can focus on the installation:

2.8.1 source installation overview
----------------------------------

The basic commands you must execute to install a MySQL Source
Distribution are:

Shell> groupadd MySQL
Shell> useradd-G MySQL
Shell> gunzip | mysql-VERSION.tar.gz | tar-xvf-
Shell> Cd mysql-version
Shell>./configure -- prefix =/usr/local/MySQL
Shell> make
Shell> make install
Shells> CP support-files/my-medium.cnf/etc/My. CNF
Shell> Cd/usr/local/MySQL
Shell> bin/mysql_install_db -- user = MySQL
Shell> chown-r root.
Shell> chown-r MySQL VaR
Shell> chgrp-r MySQL.
Shell> bin/mysqld_safe -- user = MySQL &

We can see that the installation steps are very detailed, and there are command examples. Simply put, we should first add a user for MySQL and add a MySQL group. Then extract the original code, compile, install, and set the installation.

Compile

In the installation steps of MySQL, you must perform configure before compiling. In fact, most open source code software compilation processes use the following three steps:

#./Configure
# Make
# Make install

The first command is configure, which can be used to check your current system settings and decide whether to add certain functions according to your environment. You can also use the following commands to view which parameters can be used in the configure command:

#./Configure -- help | more

In principle, we can directly execute configure unless there are special requirements. Take MYSQL as an example. We Add the following parameters after the configure command:

#./Configure -- prefix =/usr/local/MySQL \
-- With-low-memory \
-- With-charset = big5

We use -- prefix to specify the path to be installed. This is a parameter available for all software that uses configure. In addition, we also specify not to use too much memory (-- With-low-memory) during compilation, and set MySQL to support the Chinese text set (-- With-charset = big5 ).

After running the configure check environment and setting the installed project, we can use make to compile. The command "make" calls the compiler GCC to convert the original code into an execution file.

Install

After compilation, we can use the following command to install:

# Make install

You can see the installation process of the program. After the installation is complete, we must set the installation according to different software requirements. Taking MYSQL as an example, we must first use mysql_install_db to initialize the database and set the owner of some directories to MySQL.

Then you can start MySQL. If we want to start MySQL at startup, we must add its startup command to/etc/rc. local, or in/usr/local/etc/rc. d. Add a MySQL. SH and write the startup command in the file, and then MySQL. SH is set to executable. In this way, FreeBSD will automatically execute it at startup.

The above is the general process of traditional software installation: Configure, make, make install, in fact, it is not difficult to use.
Tips

The traditional installation process is prone to errors when executing make. If you encounter problems, you can search for the keyword of the first error generated by make on Google, you can find similar problems and solutions.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.