linux软件包安装之源码安装
源码:特定的语言 写出的文本 如c语言等等。程序的源码文件其实就是一般的纯文本文件, 在源码编写完毕之后,再来将这个文件编译成操作系统看懂的二级制程序。而编译的就需要一些 “编译程序”经过编译程序的编译与连接之后,就会生成可执行的二进制程序。
编译的过程中需要编译器 但是源码是各种各样的 故而所需要的编译器和各类文件 。故而要有编译环境。在linux安装了这四类软组 Development Libraries 、 X Software Development Legacy Software Development、Development Tools编译环境就会具备。编译之后生成四种文件(可执行 头文件 库文件 以及man手册)。
编译过程中还会生成目标文件拓展名为.o, 目标文件有规律的链接一起, 才可以生成可执行文件,如何链接需要makefile文件。makefile中包含了.o的连接关系 然后 基于一个makefile的说明文件就可以生成可执行文件。如何生成makefile文件以及怎么生成.o文件,在编译之前要配置,配置作用生成makefile文件这些文件都位于拆解目录下,然后安装。 makeinstall的 生成由源代码开发商提供一个可执行脚本./configure配置。 (拆解位置 /usr/local/src 安装位置 /usr/local 头文件的位置/usr/include或者/include 库文件的位置/lib /usr/lib)
以源代码安装vsftp-3.0.2为例:
一、源代码文件一般都是打包在再压缩的拓展名为.tar.gz 或者.tar.bz2
解包格式如下:[root@localhost src]# tar -zxvf vsftpd-3.0.2.tar.gz -C /usr/local/src -C 表示在特定目录下解压
二、切换到源代码所解压的位置的目录 查看src目录下的内容
[root@localhost ~]# cd /usr/local/src
[root@localhost src]# ll
显示vsftpd-3.0.2文件下的内容
Install指导安装文件 或者readme文件 查看INSTALL文件下的内容指导安装 分页显示INSTALL文件下的内容
[root@localhost vsftpd-3.0.2]# less INSTALL
---------------------------------------------------------------------------------------------------------------------------
INSTALL
INSTALL
=======
This file details how to build and install / run vsftpd from the vsftpd
distribution .tar.gz file.
Step 1) Build vsftpd.
Switch to the directory created when you unpacked the vsftpd .tar.gz file.
e.g.:
cd vsftpd-1.1.2
edit "builddefs.h" to handle compile-time settings (tcp_wrappers build,
etc).
Just type "make" (and mail me to fix it if it doesn't build ;-).
This should produce you a vsftpd binary. You can test for this, e.g.: #进行编译
[chris@localhost vsftpd]$ ls -l vsftpd
-rwxrwxr-x 1 chris chris 61748 Sep 27 00:26 vsftpd 编译后产生二进制文件
Step 2) Satisfy vsftpd pre-requisites
#满足一些先决条件
2a) vsftpd needs the user "nobody" in the default configuration. Add this
user in case it does not already exist. e.g.:
[root@localhost root]# useradd nobody
useradd: user nobody exists
2b) vsftpd needs the (empty) directory /usr/share/empty in the default
configuration. Add this directory in case it does not already exist. e.g.:
#需要有/usr/share/empty目录
[root@localhost root]# mkdir /usr/share/empty/
mkdir: cannot create directory `/usr/share/empty': File exists
2c) For anonymous FTP, you will need the user "ftp" to exist, and have a
valid home directory (which is NOT owned or writable by the user "ftp").
The following commands could be used to set up the user "ftp" if you do not
have one:#对于匿名用户需要ftp用户存在并且有home目录
[root@localhost root]# mkdir /var/ftp/
[root@localhost root]# useradd -d /var/ftp ftp
(the next two are useful to run even if the user "ftp" already exists).
[root@localhost root]# chown root.root /var/ftp
[root@localhost root]# chmod og-w /var/ftp
Step 3) Install vsftpd config file, executable, man page, etc.
#执行make install
Running "make install" will try to copy the binary, man pages, etc. to
somewhere sensible.
Or you might want to copy these things by hand, e.g.:
cp vsftpd /usr/local/sbin/vsftpd
cp vsftpd.conf.5 /usr/local/man/man5
cp vsftpd.8 /usr/local/man/man8
"make install" doesn't copy the sample config file. It is recommended you
do this:
cp vsftpd.conf /etc
#将vsftpd..conf 拷贝至/etc目录下
Step 4) Smoke test (without an inetd).
vsftpd can run standalone or via an inetd (such as inetd or xinetd). You will
typically get more control running vsftpd from an inetd. But first we will run
it without, so we can check things are going well so far.
Edit /etc/vsftpd.conf, and add this line at the bottom:
#vsftpd可以独立运行或者通过默认inetd(超级守护进程)执行 如果独立执行的话,在/etc/vsftpd.conf下加上
#listen=YES
listen=YES
This tells vsftpd it will NOT be running from inetd.
Right, now let's try and run it!
Log in as root.
Make sure you are not running other FTP servers (or vsftpd will not be able
to use the FTP port, 21).
Run the binary from wherever you put it, e.g.:
[root@localhost root]# /usr/local/sbin/vsftpd &
[1] 2104
If all is well, you can now connect! e.g.:
[chris@localhost chris]$ ftp localhost
Connected to localhost (127.0.0.1).
220 (vsFTPd 1.1.1)
Name (localhost:chris): ftp
331 Please specify the password.
Password:
230 Login successful. Have fun.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (127,0,0,1,229,133)
150 Here comes the directory listing.
d--x--x--x 2 0 0 4096 Jan 14 2002 bin
d--x--x--x 2 0 0 4096 Apr 21 20:52 etc
drwxr-xr-x 2 0 0 4096 Apr 21 20:52 lib
drwxr-sr-x 2 0 50 4096 Jul 26 22:58 pub
226 Directory send OK.
ftp>
Step 5) Run from an inetd of some kind (optional - standalone mode is now
recommended)
You may want to run the binary from an inetd of some kind, because this can
give you extra features - e.g. xinetd has a lot of settings. (Note that
vsftpd's inbuilt listener covers most of the more useful xinetd settings).
5a) If using standard "inetd", you will need to edit /etc/inetd.conf, and add
a line such as:
ftp stream tcp nowait root /usr/sbin/tcpd /usr/local/sbin/vsftpd
(Make sure to remove or comment out any existing ftp service lines. If you
don't have tcp_wrappers installed, or don't want to use them, take out the
/usr/sbin/tcpd part).
inetd will need to be told to reload its config file:
kill -SIGHUP `pidof inetd`
5b) If using "xinetd", you can follow a provided example, by looking at the
file EXAMPLE/INTERNET_SITE/README. Various other examples show how to leverage
the more powerful xinetd features.
Step 6) Set up PAM for local logins (optional)
#为本地登录建立pam文件 pam认证
If you are running vsftpd on a PAM enabled machine, you will need to have a
/etc/pam.d/ftp file present, otherwise non-anonymous logins will fail. [NOTE -
if you have an older version of PAM, that file might be /etc/pam.conf]
For a standard setup, you can just copy a provided example file:
cp RedHat/vsftpd.pam /etc/pam.d/ftp
Step 7) Customize your configuration
As well as the above three pre-requisites, you are recommended to install a
config file. The default location for the config file is /etc/vsftpd.conf.
There is a sample vsftpd.conf in the distribution tarball. You probably want
to copy that to /etc/vsftpd.conf as a basis for modification, i.e.:
cp vsftpd.conf /etc
The default configuration allows neither local user logins nor anonymous
uploads. You may wish to change these defaults.
Other notes
===========
Tested platforms (well, it builds)
- Any modern, well featured platform should work fine! Recent versions of
the platforms listed below, and often older ones, should work fine.
- Fedora Core
- RedHat Linux
- RedHat Enterprise Linux
- Solaris / GNU tools (Solaris 8 or newer)
- SuSE Linux
- Debian Linux
- OpenBSD
- FreeBSD
- NetBSD
- HP-UX / GNU tools
- IRIX / GNU tools
- AIX / GNU tools
- Mac OS X (note; older versions have setgroups() problem. 10.3.4 reported OK)
--------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------
以上是INSTALL文件的详细
按照INSTALL文件的说明执行过程如下:
按照INSTALL文件的说明执行过程如下:
一、编辑”builddefs.h”文件 设置完成之后执行编译工作
执行编译工作
[root@localhost vsftpd-3.0.2]# make
二、满足vsftpd的先决条件
A.创建nobody账号 以匿名身份登录ftp服务器的时候使用的身份
首先查一下系统有没有nobody用户
[root@localhost vsftpd-3.0.2]# grep nobody /etc/passwd
不存在话需要创建
B.vsftpd在运行的时候需要一个空目录 空目录位置在/usr/share/empty
[root@localhost vsftpd-3.0.2]# mkdir /usr/share/empety
还要创建匿名用户登录的家目录,并且为ftp账号指明一个家目录/var/ftp 并将/var/ftp文件的所有者和所属组改成root 并且other用户和组用户是没有写的权利的
[root@localhost vsftpd-3.0.2]# mkdir /var/ftp/
[root@localhost vsftpd-3.0.2]# useradd -d /var/ftp ftp
useradd: user ftp exists
[root@localhost vsftpd-3.0.2]# chown root.root /var/ftp
[root@localhost vsftpd-3.0.2]# chmod og-w /var/ftp
三、直接安装
[root@localhost vsftpd-3.0.2]# make install
将服务配置文件vsftp.conf文件拷贝到/etc目录下
[root@localhost vsftpd-3.0.2]# cp ./vsftpd.conf /etc
四、测试
如果以独立进程的方式启动修改/etc/vsftpd.conf 文件
[root@localhost vsftpd-3.0.2]# vim /etc/vsftpd.conf
后台运行:[root@localhost vsftpd-3.0.2]# vsftpd &
登陆测试:
查看本地用户能否登陆:
解决方式:
[root@localhost ~]# vim /etc/vsftpd.conf
测试本地用户能否进行上传、创建文件等操作
PAM认证机制:
[root@localhost vsftpd-3.0.2]# cp RedHat/vsftpd.pam /etc/pam.d/ftp
五、头文件 库文件 脚本 手册的解决方式
[root@localhost local]# man vsftpd.conf
六、编辑控制脚本 位于/etc/init.d/下