在ubuntu当中,安装应用程序我所知道的有三种方法,分别是apt-get,dpkg安装deb和make install安装源码包三种。下面针对每一种方法各举例来说明。
一、apt-get方法
使用apt-get install来安装应用程序算是最常见的一种安装方法了,比如我要安装build-essential这个软件,使用以下,他会帮我把所有的依赖包都一起安装了。
sudo apt-get install build-essential
执行上述命令以后,我们可以看到一下信息,The following extra packages will be installed:表示所有需要再安装的依赖包。
下面给出apt-get的的各种参数:
apt-get install xxx 安装xxx 。如果带有参数,那么-d 表示仅下载 ,-f 表示强制安装
apt-get remove xxx 卸载xxx apt-get update 更新软件信息数据库 apt-get upgrade 进行系统升级 apt-cache search 搜索软件包 Tips:建议您经常使用“apt-get update”命令来更新您的软件信息数据库apt-get理论上是要求能够联网,但是如果制作了本地源,就不需要联网,制作本地源可以参考:
二、dpkg安装deb包
Ubuntu软件包格式为deb,安装方法如下:
sudo dpkg -i package.deb
dpkg的详细使用方法,网上有很多,下面简单列了几个:
dpkg -i package.deb | 安装包 |
dpkg -r package | 删除包 |
dpkg -P package | 删除包(包括配置文件) |
dpkg -L package | 列出与该包关联的文件 |
dpkg -l package | 显示该包的版本 |
dpkg –unpack package.deb | 解开 deb 包的内容 |
dpkg -S keyword | 搜索所属的包内容 |
dpkg -l | 列出当前已安装的包 |
dpkg -c package.deb | 列出 deb 包的内容 |
dpkg –configure package | 配置包 |
根据Ubuntu中文论坛上介绍,使用apt-get方法安装的软件,所有下载的deb包都缓存到了/var/cache/apt/archives目录下了,所以可以把常用的deb包备份出来,甚至做成ISO工具包、刻盘,以后安装Ubuntu时就可以在没有网络环境的情况下进行了。下面的命令是拷贝archives这个目录到/var/cache/apt/目录下,替换原有的archives
enadmin@ubuntu-server:~/ftp$ sudo cp -r archives/ /var/cache/apt/
三、make install源代码安装
- 配置:这是编译源代码的第一步,通过
./configure
命令完成。执行此步以便为编译源代码作准备。常用的选项有--
prefix=PREFIX,用以指定程序的安装位置。更多的选项可通过--
help 查询。也有某些程序无需执行此步。 - 编译:一旦配置通过,可即刻使用
make
指令来执行源代码的编译过程。视软件的具体情况而定,编译所需的时间也各有差异,我们所要做的就是耐心等候和静观其变。此步虽然仅下简单的指令,但有时候所遇到的问题却十分复杂。较常碰到的情形是程序编译到中途却无法圆满结束。此时,需要根据出错提示分析以便找到应对之策。 - 安装:如果编译没有问题,那么执行
sudo make install
就可以将程序安装到系统中了。
//1.解压缩tar -zxf nagios-4.0.2.tar.gz //2.进入目录 cd nagios-4.0.2 //3.配置 ./configure --prefix=/usr/local/nagios //4.编译 make all //5.安装 make install && make install-init && make install-commandmode && make install-config
四、通过现成的install.sh 安装文件 直接安装
发现下载到源码很多都没有 configure文件,按照方式三步骤,当执行 ./configure 命令时,提示如下:
此时,查看解压后到安装包目录,发现直接已经有了 安装文件 install.sh 文件:
执行安装命令: sudo ./install*.sh
发生报错:
Linux – git: command not found 错误解决:
出错原因
服务器没有安装GIT,所以导致出错。
解决方法
Centos下使用:
1 | yuminstall-y |
或者
1 | yuminstall-y |
两个代码都是一样的,随意的使用一个即可。
Ubuntu/Debian下使用
1 | apt-getinstall-y |
即可解决问题。
执行 sudo apt-get install git -y 命令后,
git安装成功,
再次运行 sudo ./install_libxx.sh 命令,进行meta安装,运行记录如下,没有报错,应该是安装成功了。
fanchang@fanchang-System-Product-Name:~/Downloads/meta-master$ sudo ./install_libcxx.sh [sudo] password for fanchang: --2016-11-18 14:14:16-- http://www.cmake.org/files/v3.5/cmake-3.5.0-Linux-x86_64.tar.gz Resolving www.cmake.org (www.cmake.org)... 66.194.253.19 Connecting to www.cmake.org (www.cmake.org)|66.194.253.19|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: http://cmake.org/files/v3.5/cmake-3.5.0-Linux-x86_64.tar.gz [following] --2016-11-18 14:14:17-- http://cmake.org/files/v3.5/cmake-3.5.0-Linux-x86_64.tar.gz Resolving cmake.org (cmake.org)... 66.194.253.19 Connecting to cmake.org (cmake.org)|66.194.253.19|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: https://cmake.org/files/v3.5/cmake-3.5.0-Linux-x86_64.tar.gz [following] --2016-11-18 14:14:18-- https://cmake.org/files/v3.5/cmake-3.5.0-Linux-x86_64.tar.gz Connecting to cmake.org (cmake.org)|66.194.253.19|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 28435347 (27M) [application/x-gzip] Saving to: ‘cmake-3.5.0-Linux-x86_64.tar.gz.1’ 100%[============================================================>] 28,435,347 183KB/s in 60s 2016-11-18 14:15:19 (462 KB/s) - ‘cmake-3.5.0-Linux-x86_64.tar.gz.1’ saved [28435347/28435347] mkdir: cannot create directory ‘cmake’: File exists Cloning into 'libcxx'... remote: Counting objects: 7240, done. remote: Compressing objects: 100% (5023/5023), done. remote: Total 7240 (delta 3469), reused 3588 (delta 1926), pack-reused 0 Receiving objects: 100% (7240/7240), 3.09 MiB | 919.00 KiB/s, done. Resolving deltas: 100% (3469/3469), done. Checking connectivity... done. -- The CXX compiler identification is GNU 4.8.4 -- The C compiler identification is GNU 4.8.4 -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Configuring for standalone build. CMake Warning at CMakeLists.txt:36 (message): UNSUPPORTED LIBCXX CONFIGURATION DETECTED: llvm-config not found and LLVM_PATH not defined. Reconfigure with -DLLVM_CONFIG_PATH=path/to/llvm-config or -DLLVM_PATH=path/to/llvm-source-root. -- Looking for fopen in c -- Looking for fopen in c - found -- Looking for __gcc_personality_v0 in gcc_s -- Looking for __gcc_personality_v0 in gcc_s - found -- Performing Test LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG -- Performing Test LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG - Success -- Performing Test LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB -- Performing Test LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB - Success -- Looking for __atomic_fetch_add_8 in atomic -- Looking for __atomic_fetch_add_8 in atomic - found -- Performing Test LIBCXX_HAS_WX_FLAG -- Performing Test LIBCXX_HAS_WX_FLAG - Failed -- Performing Test LIBCXX_HAS_NO_WX_FLAG -- Performing Test LIBCXX_HAS_NO_WX_FLAG - Failed -- Performing Test LIBCXX_HAS_EHSC_FLAG -- Performing Test LIBCXX_HAS_EHSC_FLAG - Failed -- Performing Test LIBCXX_HAS_NO_EHS_FLAG -- Performing Test LIBCXX_HAS_NO_EHS_FLAG - Failed -- Performing Test LIBCXX_HAS_NO_EHA_FLAG -- Performing Test LIBCXX_HAS_NO_EHA_FLAG - Failed -- Performing Test LIBCXX_HAS_NO_GR_FLAG -- Performing Test LIBCXX_HAS_NO_GR_FLAG - Failed -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Looking for ccos in m -- Looking for ccos in m - found -- Looking for clock_gettime in rt -- Looking for clock_gettime in rt - found CMake Warning at cmake/Modules/HandleLibCXXABI.cmake:57 (message): Failed to find cxxabi.h Call Stack (most recent call first): cmake/Modules/HandleLibCXXABI.cmake:79 (setup_abi_lib) CMakeLists.txt:338 (include) CMake Warning at cmake/Modules/HandleLibCXXABI.cmake:57 (message): Failed to find bits/c++config.h Call Stack (most recent call first): cmake/Modules/HandleLibCXXABI.cmake:79 (setup_abi_lib) CMakeLists.txt:338 (include) CMake Warning at cmake/Modules/HandleLibCXXABI.cmake:57 (message): Failed to find bits/os_defines.h Call Stack (most recent call first): cmake/Modules/HandleLibCXXABI.cmake:79 (setup_abi_lib) CMakeLists.txt:338 (include) CMake Warning at cmake/Modules/HandleLibCXXABI.cmake:57 (message): Failed to find bits/cpu_defines.h Call Stack (most recent call first): cmake/Modules/HandleLibCXXABI.cmake:79 (setup_abi_lib) CMakeLists.txt:338 (include) CMake Warning at cmake/Modules/HandleLibCXXABI.cmake:57 (message): Failed to find bits/cxxabi_tweaks.h Call Stack (most recent call first): cmake/Modules/HandleLibCXXABI.cmake:79 (setup_abi_lib) CMakeLists.txt:338 (include) CMake Warning at cmake/Modules/HandleLibCXXABI.cmake:57 (message): Failed to find bits/cxxabi_forced.h Call Stack (most recent call first): cmake/Modules/HandleLibCXXABI.cmake:79 (setup_abi_lib) CMakeLists.txt:338 (include) -- Performing Test LIBCXX_SUPPORTS_STD_EQ_CXX11_FLAG -- Performing Test LIBCXX_SUPPORTS_STD_EQ_CXX11_FLAG - Success -- Performing Test LIBCXX_SUPPORTS_NOSTDINCXX_FLAG -- Performing Test LIBCXX_SUPPORTS_NOSTDINCXX_FLAG - Success -- Performing Test LIBCXX_SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG -- Performing Test LIBCXX_SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG - Success -- Performing Test LIBCXX_SUPPORTS_WALL_FLAG -- Performing Test LIBCXX_SUPPORTS_WALL_FLAG - Success -- Performing Test LIBCXX_SUPPORTS_WEXTRA_FLAG -- Performing Test LIBCXX_SUPPORTS_WEXTRA_FLAG - Success -- Performing Test LIBCXX_SUPPORTS_W_FLAG -- Performing Test LIBCXX_SUPPORTS_W_FLAG - Success -- Performing Test LIBCXX_SUPPORTS_WWRITE_STRINGS_FLAG -- Performing Test LIBCXX_SUPPORTS_WWRITE_STRINGS_FLAG - Success -- Performing Test LIBCXX_SUPPORTS_WNO_UNUSED_PARAMETER_FLAG -- Performing Test LIBCXX_SUPPORTS_WNO_UNUSED_PARAMETER_FLAG - Success -- Performing Test LIBCXX_SUPPORTS_WNO_LONG_LONG_FLAG -- Performing Test LIBCXX_SUPPORTS_WNO_LONG_LONG_FLAG - Success -- Performing Test LIBCXX_SUPPORTS_WERROR_EQ_RETURN_TYPE_FLAG -- Performing Test LIBCXX_SUPPORTS_WERROR_EQ_RETURN_TYPE_FLAG - Success -- Performing Test LIBCXX_SUPPORTS_WNO_LITERAL_SUFFIX_FLAG -- Performing Test LIBCXX_SUPPORTS_WNO_LITERAL_SUFFIX_FLAG - Success -- Performing Test LIBCXX_SUPPORTS_WNO_CXX14_COMPAT_FLAG -- Performing Test LIBCXX_SUPPORTS_WNO_CXX14_COMPAT_FLAG - Success -- Performing Test LIBCXX_SUPPORTS_WNO_ERROR_FLAG -- Performing Test LIBCXX_SUPPORTS_WNO_ERROR_FLAG - Success -- Performing Test LIBCXX_SUPPORTS_EHSC_FLAG -- Performing Test LIBCXX_SUPPORTS_EHSC_FLAG - Failed -- Performing Test LIBCXX_SUPPORTS_FPIC_FLAG -- Performing Test LIBCXX_SUPPORTS_FPIC_FLAG - Success -- Performing Test LIBCXX_SUPPORTS_STD_EQ_CXX14_FLAG -- Performing Test LIBCXX_SUPPORTS_STD_EQ_CXX14_FLAG - Failed -- Adding Benchmark: filesystem.bench.cpp -- Adding Benchmark: vector_operations.bench.cpp -- Adding Benchmark: unordered_set_operations.bench.cpp -- Adding Benchmark: util_smartptr.bench.cpp -- Adding Benchmark: algorithms.bench.cpp -- Configuring done -- Generating done -- Build files have been written to: /home/fanchang/Downloads/meta-master/libcxx/build make: Entering directory `/home/fanchang/Downloads/meta-master/libcxx/build' make[1]: Entering directory `/home/fanchang/Downloads/meta-master/libcxx/build' make[2]: Entering directory `/home/fanchang/Downloads/meta-master/libcxx/build' make[3]: Entering directory `/home/fanchang/Downloads/meta-master/libcxx/build' Scanning dependencies of target cxx_objects make[3]: Leaving directory `/home/fanchang/Downloads/meta-master/libcxx/build' make[3]: Entering directory `/home/fanchang/Downloads/meta-master/libcxx/build' [ 3%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/new.cpp.o [ 6%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/system_error.cpp.o [ 10%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/any.cpp.o [ 13%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/valarray.cpp.o In file included from /home/fanchang/Downloads/meta-master/libcxx/include/cmath:305:0, from /home/fanchang/Downloads/meta-master/libcxx/include/valarray:344, from /home/fanchang/Downloads/meta-master/libcxx/src/valarray.cpp:10: /home/fanchang/Downloads/meta-master/libcxx/include/math.h: In function ‘float abs(float)’: /home/fanchang/Downloads/meta-master/libcxx/include/math.h:640:1: warning: ‘float abs(float)’: visibility attribute ignored because it [-Wattributes] abs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);} ^ <built-in>:0:0: warning: conflicts with previous declaration here [-Wattributes] [ 17%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/condition_variable.cpp.o At global scope: cc1plus: warning: unrecognized command line option "-Wno-c++14-compat" [enabled by default] [ 20%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/hash.cpp.o [ 24%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/exception.cpp.o [ 27%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/random.cpp.o In file included from /home/fanchang/Downloads/meta-master/libcxx/include/cmath:305:0, from /home/fanchang/Downloads/meta-master/libcxx/include/__hash_table:19, from /home/fanchang/Downloads/meta-master/libcxx/src/hash.cpp:10: /home/fanchang/Downloads/meta-master/libcxx/include/math.h: In function ‘float abs(float)’: /home/fanchang/Downloads/meta-master/libcxx/include/math.h:640:1: warning: ‘float abs(float)’: visibility attribute ignored because it [-Wattributes] abs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);} ^ <built-in>:0:0: warning: conflicts with previous declaration here [-Wattributes] At global scope: cc1plus: warning: unrecognized command line option "-Wno-c++14-compat" [enabled by default] [ 31%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/thread.cpp.o In file included from /home/fanchang/Downloads/meta-master/libcxx/include/cmath:305:0, from /home/fanchang/Downloads/meta-master/libcxx/include/random:1638, from /home/fanchang/Downloads/meta-master/libcxx/src/random.cpp:15: /home/fanchang/Downloads/meta-master/libcxx/include/math.h: In function ‘float abs(float)’: /home/fanchang/Downloads/meta-master/libcxx/include/math.h:640:1: warning: ‘float abs(float)’: visibility attribute ignored because it [-Wattributes] abs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);} ^ <built-in>:0:0: warning: conflicts with previous declaration here [-Wattributes] [ 34%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/stdexcept.cpp.o At global scope: cc1plus: warning: unrecognized command line option "-Wno-c++14-compat" [enabled by default] [ 37%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/regex.cpp.o [ 41%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/bind.cpp.o [ 44%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/optional.cpp.o [ 48%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/mutex.cpp.o [ 51%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/strstream.cpp.o [ 55%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/typeinfo.cpp.o [ 58%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/utility.cpp.o [ 62%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/algorithm.cpp.o In file included from /home/fanchang/Downloads/meta-master/libcxx/include/cmath:305:0, from /home/fanchang/Downloads/meta-master/libcxx/include/random:1638, from /home/fanchang/Downloads/meta-master/libcxx/src/algorithm.cpp:11: /home/fanchang/Downloads/meta-master/libcxx/include/math.h: In function ‘float abs(float)’: /home/fanchang/Downloads/meta-master/libcxx/include/math.h:640:1: warning: ‘float abs(float)’: visibility attribute ignored because it [-Wattributes] abs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);} ^ <built-in>:0:0: warning: conflicts with previous declaration here [-Wattributes] [ 65%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/shared_mutex.cpp.o [ 68%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/memory.cpp.o [ 72%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/debug.cpp.o [ 75%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/iostream.cpp.o At global scope: cc1plus: warning: unrecognized command line option "-Wno-c++14-compat" [enabled by default] [ 79%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/chrono.cpp.o [ 82%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/ios.cpp.o [ 86%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/future.cpp.o [ 89%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/string.cpp.o [ 93%] Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/locale.cpp.o make[3]: Leaving directory `/home/fanchang/Downloads/meta-master/libcxx/build' [ 93%] Built target cxx_objects make[3]: Entering directory `/home/fanchang/Downloads/meta-master/libcxx/build' make[3]: Entering directory `/home/fanchang/Downloads/meta-master/libcxx/build' Scanning dependencies of target cxx_static Scanning dependencies of target cxx_shared make[3]: Leaving directory `/home/fanchang/Downloads/meta-master/libcxx/build' make[3]: Leaving directory `/home/fanchang/Downloads/meta-master/libcxx/build' make[3]: Entering directory `/home/fanchang/Downloads/meta-master/libcxx/build' make[3]: Entering directory `/home/fanchang/Downloads/meta-master/libcxx/build' [ 96%] Linking CXX shared library libc++.so [100%] Linking CXX static library libc++.a make[3]: Leaving directory `/home/fanchang/Downloads/meta-master/libcxx/build' [100%] Built target cxx_static make[3]: Leaving directory `/home/fanchang/Downloads/meta-master/libcxx/build' [100%] Built target cxx_shared make[3]: Entering directory `/home/fanchang/Downloads/meta-master/libcxx/build' Scanning dependencies of target cxx make[3]: Leaving directory `/home/fanchang/Downloads/meta-master/libcxx/build' [100%] Built target cxx make[2]: Leaving directory `/home/fanchang/Downloads/meta-master/libcxx/build' make[1]: Leaving directory `/home/fanchang/Downloads/meta-master/libcxx/build' make: Leaving directory `/home/fanchang/Downloads/meta-master/libcxx/build'