您好,登錄后才能下訂單哦!
linux主要目錄
/boot /etc /usr /var /dev /lib /tmp /bin /sbin /proc /sys /mnt /media /home /root /misc /opt /srv /usr/share/man /etc, /bin, /sbin, /lib #系統啟動就需要用到的程序,這些目錄不能掛載額外的分區,必須在根文件系統的分區上 /usr/ #操作系統核心功能,可以單獨分區 #單獨分區,系統重裝不影響軟件使用 bin sbin lib /usr/local #第三方軟件 bin sbin lib etc man /opt /proc /sys 不能單獨分區,默認為空; /dev: 設備,不能單獨分區; udev /root: 不能單獨分區 /var:建議單獨分區 /boot:內核,initrd(initramfs) 內核: POST-->BIOS(HD)-->(MBR)bootloader(文件系統結構,ext2, ext3, xfs)-->內核
Linux下rpm包x86、i386、i486、i586、i686和x86_64這些后綴含義
http://blog.csdn.net/iamlaosong/article/details/50114993
http://huanglianfeng.blog.51cto.com/4813074/1355429http://huanglianfeng.blog.51cto.com/4813074/1355429
軟件包管理器的核心功能:
1、制作軟件包;
2、安裝、卸載、升級、查詢、校驗;
Redhat, SUSE, Debian Redhat, SUSE: RPM Redhat Package Manager PRM is Package Manager Debian: dpt
依賴關系:
X-->Y-->Z
X-->Y-->Z
前端工具:yum, apt-get
后端工具:RPM, dpt
yum: Yellowdog Update Modifier
rpm命令:
rpm:
數據庫:/var/lib/rpm
rpmbuild:
安裝、查詢、卸載、升級、校驗、數據庫的重建、驗正數據包等工作;
rpm命名:
包:組成部分
主包: bind-9.7.1-1.el5.i586.rpm 子包: bind-libs-9.7.1-1.el5.i586.rpm bind-utils-9.7.1-1.el5.i586.rpm 包名格式: name-version-release.arch.rpm bind-major.minor.release-release.arch.rpm
主版本號:重大改進
次版本號:某個子功能發生重大變化
發行號:修正了部分bug,調整了一點功能
[root@localhost ~]# uname -r 2.6.32-504.el6.x86_64 [root@localhost ~]# uname -a Linux localhost 2.6.32-504.el6.x86_64 #1 SMP Tue Sep 16 01:56:35 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux [root@localhost ~]#
bind-9.7.1.tar.gz
rpm包:
二進制格式
rpm包作者下載源程序,編譯配置完成后,制作成rpm包
bind-9.7.1-1.noarch.rpm
bind-9.7.1-1.ppc.rpm
rpm
1、安裝
rpm -i /PATH/TO/PACKAGE_FILE -h: 以#顯示進度;每個#表示2%; -v: 顯示詳細過程 -vv: 更詳細的過程 rpm -ivh /PATH/TO/PACKAGE_FILE --nodeps: 忽略依賴關系; --replacepkgs: 重新安裝,替換原有安裝; --force: 強行安裝,可以實現重裝或降級;
2、查詢
rpm -q PACKAGE_NAME: 查詢指定的包是否已經安裝 rpm -qa : 查詢已經安裝的所有包 rpm -qi PACKAGE_NAME: 查詢指定包的說明信息; rpm -ql PACKAGE_NAME: 查詢指定包安裝后生成的文件列表; rpm -qc PACEAGE_NEME:查詢指定包安裝的配置文件; rpm -qd PACKAGE_NAME: 查詢指定包安裝的幫助文件; rpm -q --scripts PACKAGE_NAME: 查詢指定包中包含的腳本 rpm -qf /path/to/somefile: 查詢指定的文件是由哪個rpm包安裝生成的; 如果某rpm包尚未安裝,我們需查詢其說明信息、安裝以后會生成的文件; rpm -qpi /PATH/TO/PACKAGE_FILE rpm -qpl
3、升級
rpm -Uvh /PATH/TO/NEW_PACKAGE_FILE: 如果裝有老版本的,則升級;否則,則安裝; rpm -Fvh /PATH/TO/NEW_PACKAGE_FILE:如果裝有老版本的,則升級;否則,退出; --oldpackage: 降級
4、卸載
rpm -e PACKAGE_NAME --nodeps
5、校驗
rpm -V PACKAGE_NAME
6、重建數據庫
rpm --rebuilddb: 重建數據庫,一定會重新建立; --initdb:初始化數據庫,沒有才建立,有就不用建立;
7、檢驗來源合法性,及軟件包完整性;
加密類型:
對稱:加密解密使用同一個密鑰
公鑰:一對兒密鑰,公鑰,私鑰;公鑰隱含于私鑰中,可以提取出來,并公開出去;
單向:
# ls /etc/pki/rpm-gpg/ RPM-GPG-KEY-redhat-release rpm -K /PAPT/TO/PACKAGE_FILE dsa, gpg: 驗正來源合法性,也即驗正簽名;可以使用--nosignature,略過此項 sha1, md5: 驗正軟件包完整性;可以使用--nodigest,略過此項 rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release: 導入密鑰文件
rpm包安裝問題、cpio: read failed - Bad file descriptor (下載包格式不完整,需要重新下載)
[root@localhost Downloads]# rpm -ivh cpp-4.4.7-17.el6.x86_64.rpm warning: cpp-4.4.7-17.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY Preparing... ########################################### [100%] 1:cpp ########################################### [100%] error: unpacking of archive failed on file /usr/libexec/gcc/x86_64-redhat-linux/4.4.4/cc1;58d83374: cpio: read failed - Bad file descriptor [root@localhost Downloads]# ls cloog-ppl-0.15.7-1.2.el6.x86_64.rpm gcc-4.4.7-17.el6.x86_64.rpm lftp-4.0.1.tar.bz2 mpfr-2.4.1-6.el6.x86_64.rpm cloog-ppl-0.15.7-1.2.el6.x86_64.rpm.1 gcc-4.5.1.tar.bz2 lftp-4.7.7.tar.xz ppl-0.10.2-11.el6.x86_64.rpm cpp-4.4.7-17.el6.x86_64.rpm gcc-c++-4.4.7-17.el6.x86_64.rpm libgcc-4.4.7-17.el6.x86_64.rpm readline-5.2.tar.gz cpp-4.4.7-17.el6.x86_64.rpm.1 gcc-c++-4.4.7-3.el6.x86_64.rpm libgomp-4.4.7-17.el6.x86_64.rpm [root@localhost Downloads]# rm -rf cpp-4.4.7-17.el6.x86_64.rpm.1 [root@localhost Downloads]# rm -rf cpp-4.4.7-17.el6.x86_64.rpm [root@localhost Downloads]# wget ftp://mirror.switch.ch/mirror/centos/6/os/x86_64/Packages/cpp-4.4.7-17.el6.x86_64.rpm --2017-03-26 14:33:44-- ftp://mirror.switch.ch/mirror/centos/6/os/x86_64/Packages/cpp-4.4.7-17.el6.x86_64.rpm => “cpp-4.4.7-17.el6.x86_64.rpm” Resolving mirror.switch.ch... 130.59.113.36, 2001:620:0:1002::20 Connecting to mirror.switch.ch|130.59.113.36|:21... connected. Logging in as anonymous ... Logged in! ==> SYST ... done. ==> PWD ... done. ==> TYPE I ... done. ==> CWD (1) /mirror/centos/6/os/x86_64/Packages ... done. ==> SIZE cpp-4.4.7-17.el6.x86_64.rpm ... 3908556 ==> PASV ... done. ==> RETR cpp-4.4.7-17.el6.x86_64.rpm ... done. Length: 3908556 (3.7M) (unauthoritative) 100%[=================================================================================================================>] 3,908,556 9.73K/s in 10m 33s 2017-03-26 14:44:26 (6.03 KB/s) - “cpp-4.4.7-17.el6.x86_64.rpm” saved [3908556] [root@localhost Downloads]# ls cloog-ppl-0.15.7-1.2.el6.x86_64.rpm gcc-4.5.1.tar.bz2 lftp-4.7.7.tar.xz ppl-0.10.2-11.el6.x86_64.rpm cloog-ppl-0.15.7-1.2.el6.x86_64.rpm.1 gcc-c++-4.4.7-17.el6.x86_64.rpm libgcc-4.4.7-17.el6.x86_64.rpm readline-5.2.tar.gz cpp-4.4.7-17.el6.x86_64.rpm gcc-c++-4.4.7-3.el6.x86_64.rpm libgomp-4.4.7-17.el6.x86_64.rpm gcc-4.4.7-17.el6.x86_64.rpm lftp-4.0.1.tar.bz2 mpfr-2.4.1-6.el6.x86_64.rpm [root@localhost Downloads]# rpm -ivh cpp-4.4.7-17.el6.x86_64.rpm warning: cpp-4.4.7-17.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY Preparing... ########################################### [100%] 1:cpp ########################################### [100%] [root@localhost Downloads]#
rpm包安裝問題2:安裝ncurses-devel
http://rpm.pbone.net/index.php3
逐一安裝依賴包
rpm包安裝問題3:error while loading shared libraries
[root@localhost ~]# lftp root@192.168.1.18:22 lftp: error while loading shared libraries: libreadline.so.5: cannot open shared object file: No such file or directory tmux: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory
原因一般有兩個, 一個是操作系統里確實沒有包含該共享庫(lib*.so.*文件)或者共享庫版本不對, 遇到這種情況那就去網上下載并安裝上即可.
另外一個原因就是已經安裝了該共享庫, 但執行需要調用該共享庫的程序的時候, 程序按照默認共享庫路徑找不到該共享庫文件.
所以安裝共享庫后要注意共享庫路徑設置問題, 如下:
1) 如果共享庫文件安裝到了/lib或/usr/lib目錄下, 那么需執行一下ldconfig命令
ldconfig命令的用途, 主要是在默認搜尋目錄(/lib和/usr/lib)以及動態庫配置文件/etc/ld.so.conf內所列的目錄下, 搜索出可共享的動態鏈接庫(格式如lib*.so*), 進而創建出動態裝入程序(ld.so)所需的連接和緩存文件. 緩存文件默認為/etc/ld.so.cache, 此文件保存已排好序的動態鏈接庫名字列表.
2) 如果共享庫文件安裝到了/usr/local/lib(很多開源的共享庫都會安裝到該目錄下)或其它"非/lib或/usr/lib"目錄下, 那么在執行ldconfig命令前, 還要把新共享庫目錄加入到共享庫配置文件/etc/ld.so.conf中, 如下:
# cat /etc/ld.so.conf include ld.so.conf.d/*.conf # echo "/usr/local/lib" >> /etc/ld.so.conf # ldconfig
3) 如果共享庫文件安裝到了其它"非/lib或/usr/lib" 目錄下, 但是又不想在/etc/ld.so.conf中加路徑(或者是沒有權限加路徑). 那可以export一個全局變量LD_LIBRARY_PATH, 然后運行程序的時候就會去這個目錄中找共享庫.
LD_LIBRARY_PATH的意思是告訴loader在哪些目錄中可以找到共享庫. 可以設置多個搜索目錄, 這些目錄之間用冒號分隔開. 比如安裝了一個mysql到/usr/local/mysql目錄下, 其中有一大堆庫文件在/usr/local/mysql/lib下面, 則可以在.bashrc或.bash_profile或shell里加入以下語句即可:
export LD_LIBRARY_PATH=/usr/local/mysql/lib:$LD_LIBRARY_PATH
一般來講這只是一種臨時的解決方案, 在沒有權限或臨時需要的時候使用.
4)如果程序需要的庫文件比系統目前存在的村文件版本低,可以做一個鏈接
比如:
error while loading shared libraries: libncurses.so.4: cannot open shared object file: No such file or directory ls /usr/lib/libncu* /usr/lib/libncurses.a /usr/lib/libncurses.so.5 /usr/lib/libncurses.so /usr/lib/libncurses.so.5.3
可見雖然沒有libncurses.so.4,但有libncurses.so.5,是可以向下兼容的
建一個鏈接就好了
ln -s /usr/lib/libncurses.so.5.3 /usr/lib/libncurses.so.4
HTML: HyperText Mark Language
XML: eXtended Mark Language
XML, JSON: 半結構化的數據
yum倉庫中的元數據文件:
primary.xml.gz
所有RPM包的列表;
依賴關系;
每個RPM安裝生成的文件列表;
filelists.xml.gz(全局視角)
當前倉庫中所有RPM包的所有文件列表;
other.xml.gz
額外信息,RPM包的修改日志;
repomd.xml
記錄的是上面三個文件的時間戳和校驗和;
comps*.xml: RPM包分組信息
[root@localhost ~]# cat /etc/yum.conf #(查看yum倉庫配置文件) [main] cachedir=/var/cache/yum/$basearch/$releasever keepcache=0 debuglevel=2 logfile=/var/log/yum.log exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 installonly_limit=3 # This is the default, if you make this bigger yum won't see if the metadata # is newer on the remote and so you'll "gain" the bandwidth of not having to # download the new metadata and "pay" for it by yum not having correct # information. # It is esp. important, to have correct metadata, for distributions like # Fedora which don't keep old packages around. If you don't like this checking # interupting your command line usage, it's much better to have something # manually check the metadata once an hour (yum-updatesd will do this). # metadata_expire=90m # PUT YOUR REPOS HERE OR IN separate files named file.repo # (自行定義repo在/etc/yum.repos.d目錄) # in /etc/yum.repos.d [root@localhost ~]# [root@localhost ~]# ll /etc/yum.repos.d/ total 12 -rw-r--r--. 1 root root 125 Feb 21 20:39 packagekit-media.repo -rw-r--r--. 1 root root 358 Jun 21 2015 redhat.repo -rw-r--r--. 1 root root 529 Sep 15 2014 rhel-source.repo [root@localhost ~]# #[root@localhost ~]# cat /etc/yum.repos.d/rhel-source.repo #(參考定義repo文件) [rhel-source] name=Red Hat Enterprise Linux $releasever - $basearch - Source baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/SRPMS/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release [rhel-source-beta] name=Red Hat Enterprise Linux $releasever Beta - $basearch - Source baseurl=ftp://ftp.redhat.com/pub/redhat/linux/beta/$releasever/en/os/SRPMS/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release [root@localhost ~]#
如何為yum定義repo文件
[Repo_ID]
name=Description (自定義yum倉庫名稱)
baseurl= (自定義yum倉庫路徑)
ftp:// (ftp服務器)
http:// (web服務器)
file:/// (本地文件路徑)
enabled={1|0} (確認當前倉庫是否使用)
gpgcheck={1|0} (校驗是否合法)
gpgkey= (校驗算法,如果gpgcheck開啟,需要填寫;)
[root@localhost yum.repos.d]# yum list | grep ree freetype.x86_64 2.3.11-14.el6_3.1 @anaconda-RedHatEnterpriseLinux-201409260744.x86_64/6.6 gnome-screensaver.x86_64 2.28.3-28.el6 @anaconda-RedHatEnterpriseLinux-201409260744.x86_64/6.6 gstreamer-plugins-bad-free.x86_64 0.10.19-3.el6_5 @anaconda-RedHatEnterpriseLinux-201409260744.x86_64/6.6 nss-softokn-freebl.x86_64 3.14.3-17.el6 @anaconda-RedHatEnterpriseLinux-201409260744.x86_64/6.6 paktype-tehreer-fonts.noarch 2.0-8.el6 @anaconda-RedHatEnterpriseLinux-201409260744.x86_64/6.6 sound-theme-freedesktop.noarch 0.7-3.el6 @anaconda-RedHatEnterpriseLinux-201409260744.x86_64/6.6 thai-scalable-waree-fonts.noarch 0.4.12-2.1.el6 @anaconda-RedHatEnterpriseLinux-201409260744.x86_64/6.6 z-push.noarch 2.2.9-1.el5.centos Free z-push-autodiscover.noarch 2.2.9-1.el5.centos Free z-push-combined.noarch 2.2.9-1.el5.centos Free z-push-imap.noarch 2.2.9-1.el5.centos Free z-push-maildir.noarch 2.2.9-1.el5.centos Free z-push-searchldap.noarch 2.2.9-1.el5.centos Free z-push-vcarddir.noarch 2.2.9-1.el5.centos Free z-push-zarafa.noarch 2.2.9-1.el5.centos Free
repolist: 顯示repo列表及其簡要信息
all
enabled: 默認
disabled
[root@localhost yum.repos.d]# yum repolist Loaded plugins: product-id, refresh-packagekit, security, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. repo id repo name status Free netrpm 8 Nofree netrpm 0 repolist: 8 [root@localhost yum.repos.d]# [root@localhost yum.repos.d]# yum repolist disable Loaded plugins: product-id, refresh-packagekit, security, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. repolist: 0 [root@localhost yum.repos.d]#
list: 列表
支持glob
all
available:可用的,倉庫中有但尚未安裝的
installed: 已經安裝的
updates: 可用的升級
provides| whatprovides: 查看指定的文件或特性是由哪個包安裝生成的;
[root@localhost yum.repos.d]# yum provides /etc/inittab Loaded plugins: product-id, refresh-packagekit, security, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. initscripts-9.03.46-1.el6.x86_64 : The inittab file and the /etc/init.d scripts Repo : installed Matched from: Other : Provides-match: /etc/inittab groupinfo [root@localhost yum.repos.d]# yum grouplist Loaded plugins: product-id, refresh-packagekit, security, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Setting up Group Process Free/group_gz | 1.4 kB 00:00 Nofree/group_gz | 1.4 kB 00:00 Available Groups: Base (RPM Fusion Free) GNOME Desktop Environment (RPM Fusion Free) Hardware Support (RPM Fusion Free) Internet (RPM Fusion Free) KDE (K Desktop Environment) (RPM Fusion Free) Miscellaneous command line tools (RPM Fusion Free) Sound and Video (RPM Fusion Free) Done [root@localhost yum.repos.d]# grouplist groupinstall groupremove groupupdate
如何創建yum倉庫:
createrepo /YYY (沒有組的定義)
comps-rhel5-vt.xml(組信息)
createrepo -g /xxx/comps-rhel5-vt.xml /YYY
安裝第三方yum倉庫源EPEL
[root@localhost Downloads]# ll total 24 -rw-r--r--. 1 root root 14540 Mar 1 22:56 epel-release-6-8.noarch.rpm -rw-r--r--. 1 root root 6068 Mar 1 22:18 rpmfusion-free-release-6.noarch.rpm [root@localhost Downloads]# rpm -ivh epel-release-6-8.noarch.rpm (EPEL) warning: epel-release-6-8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY Preparing... ########################################### [100%] 1:epel-release ########################################### [100%] [root@localhost Downloads]# rpm -ivh rpmfusion-free-release-6.noarch.rpm warning: rpmfusion-free-release-6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 849c449f: NOKEY Preparing... ########################################### [100%] 1:rpmfusion-free-release ########################################### [100%] [root@localhost etc]# cd yum.repos.d/ [root@localhost yum.repos.d]# ll total 32 -rw-r--r--. 1 root root 957 Nov 4 2012 epel.repo -rw-r--r--. 1 root root 1056 Nov 4 2012 epel-testing.repo -rw-r--r--. 1 root root 232 Feb 25 22:48 myrepo.repo -rw-r--r--. 1 root root 125 Mar 1 20:45 packagekit-media.repo -rw-r--r--. 1 root root 358 Jun 21 2015 redhat.repo -rw-r--r--. 1 root root 529 Sep 15 2014 rhel-source.repo -rw-r--r--. 1 root root 1002 May 14 2011 rpmfusion-free-updates.repo -rw-r--r--. 1 root root 1062 Jun 19 2012 rpmfusion-free-updates-testing.repo [root@localhost yum.repos.d]# cat epel.repo [epel] name=Extra Packages for Enterprise Linux 6 - $basearch #baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch failovermethod=priority enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 [epel-debuginfo] name=Extra Packages for Enterprise Linux 6 - $basearch - Debug #baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debug mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 gpgcheck=1 [epel-source] name=Extra Packages for Enterprise Linux 6 - $basearch - Source #baseurl=http://download.fedoraproject.org/pub/epel/6/SRPMS mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 gpgcheck=1 [root@localhost yum.repos.d]# ll /etc/pki/rpm-gpg/ total 28 -rw-r--r--. 1 root root 1649 Nov 4 2012 RPM-GPG-KEY-EPEL-6 -rw-r--r--. 1 root root 3375 Sep 15 2014 RPM-GPG-KEY-redhat-beta -rw-r--r--. 1 root root 1990 Sep 15 2014 RPM-GPG-KEY-redhat-legacy-former -rw-r--r--. 1 root root 1164 Sep 15 2014 RPM-GPG-KEY-redhat-legacy-release -rw-r--r--. 1 root root 885 Sep 15 2014 RPM-GPG-KEY-redhat-legacy-rhx -rw-r--r--. 1 root root 3211 Sep 15 2014 RPM-GPG-KEY-redhat-release -rw-r--r--. 1 root root 1710 May 14 2011 RPM-GPG-KEY-rpmfusion-free-el-6 [root@localhost yum.repos.d]# [root@localhost yum.repos.d]# yum repolist Loaded plugins: product-id, refresh-packagekit, security, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Free | 2.8 kB 00:00 Free/primary_db | 4.7 kB 00:00 Nofree | 2.8 kB 00:00 Nofree/primary_db | 1.1 kB 00:00 epel/metalink | 5.2 kB 00:00 epel | 4.3 kB 00:00 epel/primary_db | 5.9 MB 00:01 rpmfusion-free-updates | 3.0 kB 00:00 rpmfusion-free-updates/primary_db | 167 kB 00:00 repo id repo name status Free netrpm 8 Nofree netrpm 0 epel Extra Packages for Enterprise Linux 6 - x86_64 12,251 rpmfusion-free-updates RPM Fusion for EL 6 - Free - Updates 220 repolist: 12,479 [root@localhost yum.repos.d]# yum list | grep gimp gimp-dds-plugin.x86_64 2.2.1-3.el6 epel gimp-gap.x86_64 2.7.0-8.GITe75bd46.el6 epel gimp-layer-via-copy-cut.noarch 1.6-2.el6 epel gimp-paint-studio.noarch 2.0-8.el6 epel gimp-save-for-web.x86_64 0.29.3-1.el6 epel gimp-separate+.x86_64 0.5.8-16.el6 epel gimp-wavelet-denoise-plugin.x86_64 0.3.1-4.el6 epel
主要提供三種格式的mysql包:rpm格式、二進制格式、源碼格式:(tar打包,gz壓縮)
rpm格式: libjpeg-devel-6b-33.x86_64.rpm #rpm格式很好區分,
二進制包: mysql-3.23.58-pc-linux-i686.tar.gz #二進制格式的包名字很長,有版本號、適應平臺、適應的硬件類型等,格式:mysql-<版本>-<OS>-tar.gz
源碼包: php-5.2.14.tar.gz #而源碼格式僅僅就是一個版本號的tar包。#cj 安裝區別:解壓、./config、make、make install
source code 是程序員寫的碼,
binary code 是機器跑的碼。
source code 得經過 compile 才能成為 binary code 。
RPM 有分兩種:binary rpm 跟 source rpm 。
前者是編好的 binary ,安裝就可用。
後者是還沒編好的 source ,需 rebuild 之後才能安裝
源代碼方式和二進制包是軟件包的兩種形式。二進制包里面包括了已經經過編譯,可以馬上運行的程序。你只需要下載和解包(安裝)它們以后,就馬上可以使用。源代碼包里面包括了程序原始的程序代碼,需要在你的計算機上進行編譯以后才可以產生可以運行程序,所以從源代碼安裝的時間會比較長。
Linux下有個命令叫file,因為Linux并不是按照后綴名來判斷文件類型的。所以一般在不清楚文件到底是什么類型的時候,就用file這個命令去判斷。
file php-5.2.14.tar.gz
php-5.2.14.tar.gz: gzip compressed data, was "php-5.2.14.tar", from Unix, last modified: Wed Jul 21 22:32:34 2010, max compression
這個php-5.2.14.tar.gz 明顯是個gzip的壓縮包,這樣的文件一般都是用tar zxvf 命令去解包然后去配置編譯安裝的,通常情況把這種安裝方法叫做源碼編譯安裝。
file libjpeg-devel-6b-33.x86_64.rpm
libjpeg-devel-6b-33.x86_64.rpm: RPM v3 bin i386 libjpeg-devel-6b-33
這個libjpeg-devel-6b-33.x86_64.rpm 文件,就是個標準的redhat系列發行版本所用的RPM格式軟件包。一般在RHEL、CentOS、SUSE、OracleLinux下都可以安裝類似的RPM包。標準的安裝方法是rpm -ivh。
基本上紅帽系列Linux發行版本安裝軟件就這兩種方法了。還有經常被提起的yum,其實就是由yum自動判斷rpm包的依賴,然后一次性把所有需要安裝的N個rpm統一下載安裝,其實原理和一個個的安裝rpm沒有什么本質區別。
一般在官網上下載的源碼包都是以:tar.gz tar.bz2結尾的,經過編譯的一般是以.rpm來結尾的,linux下的文件擴展名沒有實際的意義,這樣做只是為了方便你去查看是什么類型的包然后采取什么樣的方式去安裝和配置,當然有時候并不能從文件的擴展名去查看什么類型的包,因為文件名可以隨意的去修改可以使用file這個命令去查看文件包的類型.
源碼的安裝一般由3個步驟組成:配置(configure)、編譯(make)、安裝(make install)。
Configure是一個可執行腳本,它有很多選項,在待安裝的源碼路徑下使用命令./configure –help輸出詳細的選項列表。
其中--prefix選項是配置安裝的路徑,如果不配置該選項,安裝后可執行文件默認放在/usr /local/bin,庫文件默認放在/usr/local/lib,配置文件默認放在/usr/local/etc,其它的資源文件放在/usr /local/share,比較凌亂。
如果配置--prefix,如:
./configure --prefix=/usr/local/test
可以把所有資源文件放在/usr/local/test的路徑中,不會雜亂。
用了—prefix選項的另一個好處是卸載軟件或移植軟件。當某個安裝的軟件不再需要時,只須簡單的刪除該安裝目錄,就可以把軟件卸載得干干凈凈;移植軟件只需拷貝整個目錄到另外一個機器即可(相同的操作系統)。
當然要卸載程序,也可以在原來的make目錄下用一次make uninstall,但前提是make文件指定過uninstall。
下載源碼包
wget http://mirrors.hust.edu.cn/apache/httpd/httpd-2.2.32.tar.gz
[root@localhost ~]# tar xf httpd-2.2.32.tar.gz [root@localhost ~]# cd httpd-2.2.32 [root@localhost httpd-2.2.32]# ll total 1172 -rw-r--r--. 1 1001 1001 14882 Nov 21 2004 ABOUT_APACHE -rw-r--r--. 1 1001 1001 18613 Jul 6 2012 acinclude.m4 -rw-r--r--. 1 1001 1001 56952 Oct 5 2010 Apache.dsw drwxr-xr-x. 6 1001 1001 4096 Jan 9 09:36 build -rw-r--r--. 1 1001 1001 2644 Aug 23 2007 BuildAll.dsp -rw-r--r--. 1 1001 1001 2692 Jul 29 2009 BuildBin.dsp -rwxr-xr-x. 1 1001 1001 5786 Sep 19 2012 buildconf -rw-r--r--. 1 1001 1001 146529 Jan 9 08:23 CHANGES -rw-r--r--. 1 1001 1001 11701 Feb 27 2012 config.layout -rwxr-xr-x. 1 1001 1001 574593 Jan 9 09:36 configure -rw-r--r--. 1 1001 1001 24720 May 25 2015 configure.in drwxr-xr-x. 9 1001 1001 4096 Jan 9 09:36 docs -rw-r--r--. 1 1001 1001 403 Nov 21 2004 emacs-style -rw-r--r--. 1 1001 1001 1248 May 6 2011 httpd.dep -rw-r--r--. 1 1001 1001 4124 Jun 11 2008 httpd.dsp -rw-r--r--. 1 1001 1001 8994 May 6 2011 httpd.mak -rw-r--r--. 1 1001 1001 12053 Jan 9 09:36 httpd.spec drwxr-xr-x. 2 1001 1001 4096 Jan 9 09:36 include -rw-r--r--. 1 1001 1001 5129 Jan 9 08:33 INSTALL -rw-r--r--. 1 1001 1001 2909 Dec 7 2006 InstallBin.dsp -rw-r--r--. 1 1001 1001 5145 Nov 29 2005 LAYOUT -rw-r--r--. 1 1001 1001 30119 May 6 2011 libhttpd.dep -rw-r--r--. 1 1001 1001 17039 Jan 12 2007 libhttpd.dsp -rw-r--r--. 1 1001 1001 28503 May 6 2011 libhttpd.mak -rw-r--r--. 1 1001 1001 28690 Jan 18 2008 LICENSE -rw-r--r--. 1 1001 1001 8739 Nov 25 2008 Makefile.in -rw-r--r--. 1 1001 1001 34759 Jan 19 2014 Makefile.win drwxr-xr-x. 20 1001 1001 4096 Jan 9 09:36 modules -rw-r--r--. 1 1001 1001 828 Jan 2 08:16 NOTICE -rw-r--r--. 1 1001 1001 12894 Mar 15 2012 NWGNUmakefile drwxr-xr-x. 9 1001 1001 4096 Jan 9 09:36 os -rw-r--r--. 1 1001 1001 5954 Jan 9 2007 README -rw-r--r--. 1 1001 1001 4178 Aug 27 2014 README.platforms -rw-r--r--. 1 1001 1001 2553 Dec 20 2010 README-win32.txt -rw-r--r--. 1 1001 1001 10183 Mar 13 2005 ROADMAP drwxr-xr-x. 3 1001 1001 4096 Jan 9 09:36 server drwxr-xr-x. 5 1001 1001 4096 Jan 9 09:36 srclib drwxr-xr-x. 4 1001 1001 4096 Jan 9 09:36 support drwxr-xr-x. 2 1001 1001 4096 Jan 9 09:36 test -rw-r--r--. 1 1001 1001 8183 Oct 17 2005 VERSIONING [root@localhost httpd-2.2.32]# [root@localhost httpd-2.2.32]# ./configure --help #(查看可以支持的選項) `configure' configures this package to adapt to many kinds of systems. Usage: ./configure [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print `checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for `--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or `..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX #(指定安裝路徑) [/usr/local/apache2] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, `make install' will install all the files in `/usr/local/apache2/bin', `/usr/local/apache2/lib' etc. You can specify an installation prefix other than `/usr/local/apache2' using `--prefix', for instance `--prefix=$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] #(配置路徑) --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] --target=TARGET configure for building compilers for TARGET [HOST] [root@localhost httpd-2.2.32]# ./configure --prefix=/usr/local/httpd checking for chosen layout... Apache checking for working mkdir -p... yes checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu [BEGIN] 2017/3/4 22:58:51 [root@localhost httpd-2.2.32]# make Making all in srclib [root@localhost httpd-2.2.32]# make install Making install in srclib [root@localhost bin]# vim /etc/profile #(環境變量路徑) [root@localhost ~]# echo $PATH /usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/httpd/bin:/root/bin [root@localhost ~]# netstat -tnlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1747/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1617/cupsd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1867/master tcp 0 0 :::22 :::* LISTEN 1747/sshd tcp 0 0 :::23 :::* LISTEN 1757/xinetd tcp 0 0 ::1:631 :::* LISTEN 1617/cupsd tcp 0 0 ::1:25 :::* LISTEN 1867/master tcp 0 0 :::80 :::* LISTEN 40411/httpd #(80端口,可以頁面直接訪問)
RPM安裝:
二進制格式:
源程序-->編譯-->二進制格式
有些特性是編譯選定的,如果編譯未選定此特性,將無法使用;
rpm包的版本會落后于源碼包,甚至落后很多;bind-9.8.7, bind-9.7.2
定制:手動編譯安裝
編譯環境,開發環境
開發庫,開發工具
Linux: C,
GNU: C
C,C++:
gcc: GNU C Complier, C
g++:
make: 項目管理工具,
makefile: 定義了make(gcc,g++)按何種次序去編譯這些源程序文件中的源程序
automake, --> makefile.in --> makefile
autoconf, --> configure
100個可選擇特性,
make install
編譯安裝的三步驟:
前提:準備開發環境(編譯環境)
安裝"Development Tools"和"Development Libraries"
# tar
# cd
# ./configure
--help
--prefix=/path/to/somewhere
--sysconfdir=/PATH/TO/CONFFILE_PATH
功能:1、讓用戶選定編譯特性;2、檢查編譯環境;
# make
# make install
# tar xf tengine-1.4.2.tar.gz
# cd tegnine-1.4.2
# ./configure --prefix=/usr/local/tengine --conf-path=/etc/tengine/tengine.conf
# make
# make install
# /usr/local/tengine/sbin/nginx
1、修改PATH環境變量,以能夠識別此程序的二進制文件路徑;
修改/etc/profile文件
在/etc/profile.d/目錄建立一個以.sh為名稱后綴的文件,在里面定義export PATH=$PATH:/path/to/somewhere
2、默認情況下,系統搜索庫文件的路徑/lib, /usr/lib; 要增添額外搜尋路徑:
在/etc/ld.so.conf.d/中創建以.conf為后綴名的文件,而后把要增添的路徑直接寫至此文件中;
# ldconfig 通知系統重新搜尋庫文件
-v: 顯示重新搜尋庫的過程
3、頭文件:輸出給系統
默認:/usr/include
增添頭文件搜尋路徑,使用鏈接進行:
/usr/local/tengine/include/ /usr/include/
兩種方式:
ln -s /usr/local/tengine/include/* /usr/include/ 或
ln -s /usr/local/tengine/include /usr/include/tengine
4、man文件路徑:安裝在--prefix指定的目錄下的man目錄;/usr/share/man
1、man -M /PATH/TO/MAN_DIR COMMAND
2、在/etc/man.config中添加一條MANPATH
netstat命令:
-r: 顯示路由表
-n: 以數字方式顯示
-t: 建立的tcp連接
-u: 顯示udp連接
-l: 顯示監聽狀態的連接
-p: 顯示監聽指定的套接字的進程的進程號及進程名
[root@localhost htdocs]# netstat -tul Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 *:ssh *:* LISTEN (允許任意外來主機) tcp 0 0 localhost:ipp *:* LISTEN tcp 0 0 localhost:smtp *:* LISTEN tcp 0 0 *:ssh *:* LISTEN tcp 0 0 *:telnet *:* LISTEN tcp 0 0 localhost:ipp *:* LISTEN tcp 0 0 localhost:smtp *:* LISTEN tcp 0 0 *:http *:* LISTEN udp 0 0 *:bootpc *:* udp 0 0 *:ipp *:* [root@localhost htdocs]# [root@localhost htdocs]# netstat -tulnp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1747/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1617/cupsd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1867/master tcp 0 0 :::22 :::* LISTEN 1747/sshd tcp 0 0 :::23 :::* LISTEN 1757/xinetd tcp 0 0 ::1:631 :::* LISTEN 1617/cupsd tcp 0 0 ::1:25 :::* LISTEN 1867/master tcp 0 0 :::80 :::* LISTEN 40411/httpd udp 0 0 0.0.0.0:68 0.0.0.0:* 1612/dhclient udp 0 0 0.0.0.0:631 0.0.0.0:* 1617/cupsd [root@localhost htdocs]#
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。