zoukankan      html  css  js  c++  java
  • Linux软件包管理之3——源码包管理

    Linux软件包管理

    1. rpm命令管理 https://blog.csdn.net/jiduochou963/article/details/86619233
    2. yum在线命令 https://blog.csdn.net/jiduochou963/article/details/86653645
    3. 源码包管理 https://blog.csdn.net/jiduochou963/article/details/86653703
    4. 脚本安装包 https://blog.csdn.net/jiduochou963/article/details/86655625

    三、 源码包管理

    源码包和RPM包的区别

    1. 安装之前的区别:概念上的区别
    2. 安装之后的区别:安装位置不同

    RPM包安装位置

    • 是安装在默认位置中(由包编写者决定)
    RPM包默认安装路径(这个只是推荐的位置)
    /etc/ 配置文件安装目录
    /usr/bin/ 可执行的命令安装目录
    /usr/lib/ 程序所使用的函数库保存位置
    /usr/share/doc/ 基本的软件使用手册保存位置
    /usr/share/man/ 帮助文件保存位置
    [root@localhost ~]# rpm -ql httpd
    /etc/httpd
    /etc/httpd/conf
    /etc/httpd/conf.d
    /etc/httpd/conf.d/README
    /etc/httpd/conf.d/autoindex.conf
    /etc/httpd/conf.d/userdir.conf
    /etc/httpd/conf.d/welcome.conf
    /etc/httpd/conf.modules.d
    /etc/httpd/conf.modules.d/00-base.conf
    /etc/httpd/conf.modules.d/00-dav.conf
    /etc/httpd/conf.modules.d/00-lua.conf
    /etc/httpd/conf.modules.d/00-mpm.conf
    /etc/httpd/conf.modules.d/00-proxy.conf
    /etc/httpd/conf.modules.d/00-systemd.conf
    /etc/httpd/conf.modules.d/01-cgi.conf
    /etc/httpd/conf/httpd.conf
    /etc/httpd/conf/magic
    /etc/httpd/logs
    /etc/httpd/modules
    /etc/httpd/run
    /etc/logrotate.d/httpd
    /etc/sysconfig/htcacheclean
    /etc/sysconfig/httpd
    /run/httpd
    /run/httpd/htcacheclean
    /usr/lib/systemd/system/htcacheclean.service
    /usr/lib/systemd/system/httpd.service
    /usr/lib/tmpfiles.d/httpd.conf
    /usr/lib64/httpd
    /usr/lib64/httpd/modules
    /usr/lib64/httpd/modules/mod_access_compat.so
    ...
    /usr/libexec/initscripts/legacy-actions/httpd
    /usr/libexec/initscripts/legacy-actions/httpd/configtest
    /usr/libexec/initscripts/legacy-actions/httpd/graceful
    /usr/sbin/apachectl
    ...
    /var/cache/httpd
    /var/cache/httpd/proxy
    /var/lib/dav
    /var/log/httpd
    /var/www
    /var/www/cgi-bin
    /var/www/html
    [root@localhost ~]# 
    
    rpm安装可以指定安装位置
    [root@localhost ~]# rpm --help | grep prefix
      --prefix=<dir>                   如果可重定位,便把软件包重定位到 <dir>
    [root@localhost ~]# 
    

    rpm包安装过程中,建议不要指定安装位置,以防系统找不到。
    但不指定安装位置又会导致包安装得到处都是,所以rpm提供了rpm -e 包名来方便卸载,就免除去找一个个目录去删除的麻烦。

    安装位置不同带来的影响

    RPM包安装的服务可以使用系统服务管理命令(service)来管理,例如RPM包安装的apache的启动方法是:

    • /etc/rc.d/init.d/httpd start这里有问题
    • service httpd start这里有问题

    我执行的时候出现了错误(原因在后面安装源码包的时候会解释)

    [root@localhost ~]# /etc/rc.d/init.d/httpd start
    -bash: /etc/rc.d/init.d/httpd: 没有那个文件或目录
    [root@localhost ~]# ls -al /etc/rc.d/init.d/
    总用量 40
    drwxr-xr-x.  2 root root    70 1月  23 17:35 .
    drwxr-xr-x. 10 root root   127 1月  23 17:35 ..
    -rw-r--r--.  1 root root 18104 1月   3 2018 functions
    -rwxr-xr-x.  1 root root  4334 1月   3 2018 netconsole
    -rwxr-xr-x.  1 root root  7293 1月   3 2018 network
    -rw-r--r--.  1 root root  1160 4月  11 2018 README
    [root@localhost ~]#  #...这个不行,试一试第二个
    [root@localhost /]# cat /etc/redhat-release
    CentOS Linux release 7.5.1804 (Core)
    [root@localhost ~]# httpd -v
    Server version: Apache/2.4.6 (CentOS)
    Server built:   Apr 20 2018 18:10:38
    [root@localhost ~]# find / -name 'httpd'
    /run/httpd
    /etc/logrotate.d/httpd
    /etc/sysconfig/httpd
    /etc/httpd     # 由此确定Apache被安装的地方是/etc/httpd
    /var/log/httpd
    /var/cache/httpd
    /usr/sbin/httpd
    /usr/lib64/httpd
    /usr/share/httpd
    /usr/libexec/initscripts/legacy-actions/httpd
    [root@localhost ~]# ls -al /etc/httpd/
    总用量 12
    drwxr-xr-x.   5 root root   92 1月  25 20:04 .
    drwxr-xr-x. 141 root root 8192 1月  25 20:04 ..
    drwxr-xr-x.   2 root root   37 1月  25 20:04 conf
    drwxr-xr-x.   2 root root   82 1月  25 20:04 conf.d
    drwxr-xr-x.   2 root root  166 1月  25 20:04 conf.modules.d
    lrwxrwxrwx.   1 root root   19 1月  25 20:04 logs -> ../../var/log/httpd
    lrwxrwxrwx.   1 root root   29 1月  25 20:04 modules -> ../../usr/lib64/httpd/modules
    lrwxrwxrwx.   1 root root   10 1月  25 20:04 run -> /run/httpd
    #...开启
    [root@localhost ~]# service httpd start
    Redirecting to /bin/systemctl start httpd.service
    Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
    #...按着它的说法来
    [root@localhost ~]#  /bin/systemctl start httpd.service
    Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
    [root@localhost ~]# ...^C
    #...还是报错,那我先停止服务,然后重启httpd?
    [root@localhost ~]# service httpd stop
    Redirecting to /bin/systemctl stop httpd.service
    [root@localhost ~]#  /bin/systemctl stop httpd.service
    [root@localhost ~]# /bin/systemctl start httpd.service
    Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
    [root@localhost ~]# 
    

    还是不行。。。cao

    还没解决,但发现一个思路:https://www.cnblogs.com/xiandedanteng/p/5229658.html

    别纠结,后面会讲到原因。

    注:service命令实际上搜索的是/etc/rc.d/init.d/目录,源码包是自定义安装位置,而不会安装在此目录里,使用源码包是不能通过service命令来启动的。

    源码包安装位置

    安装在指定位置当中,一般是/usr/local/软件名/

    源码包为啥要指定安装位置?

    源码包没有卸载命令(不同于RPM包)

    源码包安装的服务不能被服务管理命令管理,因为没有安装到默认路径中。所以只能用绝对路径进行服务的管理,如:/usr/local/apache2/bin/apachectl start

    源码包安装过程

    1. 安装准备

    发现gcc已经安装:

    [root@localhost ~]# rpm -qa | grep gcc
    libgcc-4.8.5-28.el7.x86_64
    gcc-4.8.5-28.el7.x86_64
    [root@localhost ~]# 
    

    安装httpd-2.2.10.tar.gz,此版本相对比较成熟,也是比较稳定的Apache。 2.4以上的版本(比如Apache/2.4.6 (CentOS))在现在的环境(CentOS Linux release 7.5.1804)安装时候就会一定有一个报错,所以先装一个低版本。

    我已经安装了一个Apache2.4.6,由于此服务要占用80端口,所以虽然RPM包和源码包能够同时安装,只要安装位置不同,但是只能够启动一个,否则会端口冲突(尽管可以通过修改端口的方式同时开启,但是一般不这样做),所以只选择启动一个。实际的生产环境中,不可能同时安装源码包和RPM包的Apache,因为同一时间只能使用一个,避免硬盘空间浪费。

    [root@localhost ~]# rpm -qa | grep httpd
    httpd-tools-2.4.6-80.el7.centos.x86_64
    httpd-2.4.6-80.el7.centos.x86_64
    [root@localhost ~]# httpd -v
    Server version: Apache/2.4.6 (CentOS)
    Server built:   Apr 20 2018 18:10:38
    [root@localhost ~]# netstat -tlun
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State      
    tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN     
    tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN     
    tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
    tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN     
    tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN     
    tcp6       0      0 :::111                  :::*                    LISTEN     
    tcp6       0      0 :::80                   :::*                    LISTEN     
    tcp6       0      0 :::22                   :::*                    LISTEN     
    tcp6       0      0 ::1:631                 :::*                    LISTEN     
    tcp6       0      0 ::1:25                  :::*                    LISTEN     
    udp        0      0 0.0.0.0:5353            0.0.0.0:*                          
    udp        0      0 0.0.0.0:997             0.0.0.0:*                          
    udp        0      0 192.168.122.1:53        0.0.0.0:*                          
    udp        0      0 0.0.0.0:67              0.0.0.0:*                          
    udp        0      0 0.0.0.0:68              0.0.0.0:*                          
    udp        0      0 0.0.0.0:111             0.0.0.0:*                          
    udp        0      0 0.0.0.0:42195           0.0.0.0:*                          
    udp6       0      0 :::997                  :::*                               
    udp6       0      0 :::111                  :::*                               
    [root@localhost ~]# 
    

    由于源码包的优点,所以Apache建议安装源码包——本机编译,运行效率会更高。

    卸载RPM包的Apache——实验环境(实际生产环境中可不要使用remove这样干)

    一定要先关闭服务再卸载,不然即使已经卸载端口仍会被原来的程序一直占用

    [root@localhost ~]#  /bin/systemctl stop httpd.service
    [root@localhost ~]# yum -y remove httpd
    已加载插件:fastestmirror, langpacks
    正在解决依赖关系
    --> 正在检查事务
    ---> 软件包 httpd.x86_64.0.2.4.6-80.el7.centos 将被 删除
    --> 正在处理依赖关系 httpd-mmn = 20120211x8664,它被软件包 mod_wsgi-3.4-12.el7_0.x86_64 需要
    --> 正在检查事务
    ---> 软件包 mod_wsgi.x86_64.0.3.4-12.el7_0 将被 删除
    --> 解决依赖关系完成
    
    依赖关系解决
    
    ==================================================================================================================================================================
     Package                             架构                              版本                                            源                                    大小
    ==================================================================================================================================================================
    正在删除:
     httpd                               x86_64                            2.4.6-80.el7.centos                             @c7-media                            9.4 M
    为依赖而移除:
     mod_wsgi                            x86_64                            3.4-12.el7_0                                    @c7-media                            197 k
    
    事务概要
    ==================================================================================================================================================================
    移除  1 软件包 (+1 依赖软件包)
    
    安装大小:9.6 M
    Downloading packages:
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      正在删除    : mod_wsgi-3.4-12.el7_0.x86_64                                                                                                                  1/2 
      正在删除    : httpd-2.4.6-80.el7.centos.x86_64                                                                                                              2/2 
      验证中      : mod_wsgi-3.4-12.el7_0.x86_64                                                                                                                  1/2 
      验证中      : httpd-2.4.6-80.el7.centos.x86_64                                                                                                              2/2 
    
    删除:
      httpd.x86_64 0:2.4.6-80.el7.centos                                                                                                                              
    
    作为依赖被删除:
      mod_wsgi.x86_64 0:3.4-12.el7_0                                                                                                                                  
    
    完毕!
    [root@localhost ~]# 
    

    2. 安装注意事项

    • 源代码保存位置:/usr/local/src/
      • usr:系统资源目录
      • local:本地
      • src:源代码
    • 软件安装位置:/usr/local/
    • 如何确定安装过程报错:
      • 安装过程停止
      • 并出现errorwarningno的提示
    [root@localhost ~]# pwd
    /root
    [root@localhost ~]# ls -al /root/桌面/
    总用量 6432
    drwxr-xr-x.  3 root root      48 1月  25 21:27 .
    dr-xr-x---. 15 root root    4096 1月  25 19:22 ..
    -rwxrw-rw-.  1 root root 6580772 1月  25 21:26 httpd-2.2.10.tar.gz
    drwxr-xr-x.  2 root root       6 1月  23 18:00 onefine
    [root@localhost ~]# mv /root/桌面/httpd-2.2.10.tar.gz /usr/local/src/
    [root@localhost ~]# ls -al /usr/local/src/
    总用量 6428
    drwxr-xr-x.  2 root root      33 1月  25 22:23 .
    drwxr-xr-x. 12 root root     131 1月  23 17:34 ..
    -rwxrw-rw-.  1 root root 6580772 1月  25 21:26 httpd-2.2.10.tar.gz
    [root@localhost ~]# cd /usr/local/src/
    [root@localhost src]# tar -zxvf httpd-2.2.10.tar.gz
    ...  # 省略
    [root@localhost src]# ls -al
    总用量 6432
    drwxr-xr-x.  3 root root       53 1月  25 22:25 .
    drwxr-xr-x. 12 root root      131 1月  23 17:34 ..
    drwxr-xr-x. 11  501 games    4096 10月  7 2008 httpd-2.2.10
    -rwxrw-rw-.  1 root root  6580772 1月  25 21:26 httpd-2.2.10.tar.gz
    [root@localhost src]# 
    

    3. 源码包安装过程

    1. 下载源码包
    2. 解压缩下载的源码包
    3. 进入解压缩目录
    #...接着上面
    [root@localhost src]# cd httpd-2.2.10/
    #...上面这条命令一定要执行,避免入坑
    [root@localhost httpd-2.2.10]# 
    

    ./configure软件配置与检查

    • 定义需要的功能选项
    • 检测系统环境是否符合安装要求
    • 把定义好的功能选项和检测系统环境的信息都写入Makefile文件,用于后续的编辑。

    注:/当前位置,./configure执行的是当前目录下的configure命令

    #...接着上面
    [root@localhost httpd-2.2.10]# ./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]
    
    Optional Features:
      --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
      --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
      --enable-layout=LAYOUT
      --enable-v4-mapped      Allow IPv6 sockets to handle IPv4 connections
      --enable-exception-hook Enable fatal exception hook
      --enable-maintainer-mode
                              Turn on debugging and compile time warnings
      --enable-pie            Build httpd as a Position Independent Executable
      --enable-modules=MODULE-LIST
                              Space-separated list of modules to enable | "all" |
                              "most"
      --enable-mods-shared=MODULE-LIST
                              Space-separated list of shared modules to enable |
                              "all" | "most"
      --disable-authn-file    file-based authentication control
      --enable-authn-dbm      DBM-based authentication control
      --enable-authn-anon     anonymous user authentication control
      --enable-authn-dbd      SQL-based authentication control
      --disable-authn-default authentication backstopper
      --enable-authn-alias    auth provider alias
      --disable-authz-host    host-based authorization control
      --disable-authz-groupfile
                              'require group' authorization control
      --disable-authz-user    'require user' authorization control
      --enable-authz-dbm      DBM-based authorization control
      --enable-authz-owner    'require file-owner' authorization control
      --enable-authnz-ldap    LDAP based authentication
      --disable-authz-default authorization control backstopper
      --disable-auth-basic    basic authentication
      --enable-auth-digest    RFC2617 Digest authentication
      --enable-isapi          isapi extension support
      --enable-file-cache     File cache
      --enable-cache          dynamic file caching
      --enable-disk-cache     disk caching module
      --enable-mem-cache      memory caching module
      --enable-dbd            Apache DBD Framework
      --enable-bucketeer      buckets manipulation filter
      --enable-dumpio         I/O dump filter
      --enable-echo           ECHO server
      --enable-example        example and demo module
      --enable-case-filter    example uppercase conversion filter
      --enable-case-filter-in example uppercase conversion input filter
      --enable-ext-filter     external filter module
      --disable-include       Server Side Includes
      --disable-filter        Smart Filtering
      --enable-substitute     response content rewrite-like filtering
      --disable-charset-lite  character set translation
      --enable-charset-lite   character set translation
      --enable-deflate        Deflate transfer encoding support
      --enable-ldap           LDAP caching and connection pooling services
      --disable-log-config    logging configuration
      --enable-log-forensic   forensic logging
      --enable-logio          input and output logging
      --disable-env           clearing/setting of ENV vars
      --enable-mime-magic     automagically determining MIME type
      --enable-cern-meta      CERN-type meta files
      --enable-expires        Expires header control
      --enable-headers        HTTP header control
      --enable-ident          RFC 1413 identity check
      --enable-usertrack      user-session tracking
      --enable-unique-id      per-request unique ids
      --disable-setenvif      basing ENV vars on headers
      --enable-version        determining httpd version in config files
      --enable-proxy          Apache proxy module
      --enable-proxy-connect  Apache proxy CONNECT module
      --enable-proxy-ftp      Apache proxy FTP module
      --enable-proxy-http     Apache proxy HTTP module
      --enable-proxy-ajp      Apache proxy AJP module
      --enable-proxy-balancer Apache proxy BALANCER module
      --enable-ssl            SSL/TLS support (mod_ssl)
      --enable-distcache      Select distcache support in mod_ssl
      --enable-optional-hook-export
                              example optional hook exporter
      --enable-optional-hook-import
                              example optional hook importer
      --enable-optional-fn-import
                              example optional function importer
      --enable-optional-fn-export
                              example optional function exporter
      --enable-static-support Build a statically linked version of the support
                              binaries
      --enable-static-htpasswd
                              Build a statically linked version of htpasswd
      --enable-static-htdigest
                              Build a statically linked version of htdigest
      --enable-static-rotatelogs
                              Build a statically linked version of rotatelogs
      --enable-static-logresolve
                              Build a statically linked version of logresolve
      --enable-static-htdbm   Build a statically linked version of htdbm
      --enable-static-ab      Build a statically linked version of ab
      --enable-static-checkgid
                              Build a statically linked version of checkgid
      --enable-static-htcacheclean
                              Build a statically linked version of htcacheclean
      --enable-static-httxt2dbm
                              Build a statically linked version of httxt2dbm
      --enable-http           HTTP protocol handling
      --disable-mime          mapping of file-extension to MIME
      --enable-dav            WebDAV protocol handling
      --disable-status        process/thread monitoring
      --disable-autoindex     directory listing
      --disable-asis          as-is filetypes
      --enable-info           server information
      --enable-suexec         set uid and gid for spawned processes
      --disable-cgid          CGI scripts
      --enable-cgi            CGI scripts
      --disable-cgi           CGI scripts
      --enable-cgid           CGI scripts
      --enable-dav-fs         DAV provider for the filesystem
      --enable-dav-lock       DAV provider for generic locking
      --enable-vhost-alias    mass virtual hosting module
      --disable-negotiation   content negotiation
      --disable-dir           directory request handling
      --enable-imagemap       server-side imagemaps
      --disable-actions       Action triggering on requests
      --enable-speling        correct common URL misspellings
      --disable-userdir       mapping of requests to user-specific directories
      --disable-alias         mapping of requests to different filesystem parts
      --enable-rewrite        rule based URL manipulation
      --enable-so             DSO capability
    
    Optional Packages:
      --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
      --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
      --with-included-apr     Use bundled copies of APR/APR-Util
      --with-apr=PATH         prefix for installed APR or the full path to
                                 apr-config
      --with-apr-util=PATH    prefix for installed APU or the full path to
                                 apu-config
      --with-pcre=PATH        Use external PCRE library
      --with-port=PORT        Port on which to listen (default is 80)
      --with-sslport=SSLPORT  Port on which to securelisten (default is 443)
      --with-z=DIR            use a specific zlib library
      --with-sslc=DIR         RSA SSL-C SSL/TLS toolkit
      --with-ssl=DIR          OpenSSL SSL/TLS toolkit
      --with-mpm=MPM          Choose the process model for Apache to use.
                              MPM={beos|event|worker|prefork|mpmt_os2}
      --with-module=module-type:module-file
                              Enable module-file in the modules/<module-type>
                              directory.
      --with-program-name     alternate executable name
      --with-suexec-bin       Path to suexec binary
      --with-suexec-caller    User allowed to call SuExec
      --with-suexec-userdir   User subdirectory
      --with-suexec-docroot   SuExec root directory
      --with-suexec-uidmin    Minimal allowed UID
      --with-suexec-gidmin    Minimal allowed GID
      --with-suexec-logfile   Set the logfile
      --with-suexec-safepath  Set the safepath
      --with-suexec-umask     umask for suexec'd process
    
    Some influential environment variables:
      CC          C compiler command
      CFLAGS      C compiler flags
      LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
                  nonstandard directory <lib dir>
      LIBS        libraries to pass to the linker, e.g. -l<library>
      CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
                  you have headers in a nonstandard directory <include dir>
      CPP         C preprocessor
    
    Use these variables to override the choices made by `configure' or to help
    it to find libraries and programs with nonstandard names/locations.
    
    [root@localhost httpd-2.2.10]# 
    

    先只指定安装位置

    [root@localhost httpd-2.2.10]# ls -al
    总用量 1292
    drwxr-xr-x. 11  501 games   4096 10月  7 2008 .
    drwxr-xr-x.  3 root root      53 1月  25 22:48 ..
    -rw-r--r--.  1  501 games  14882 11月 22 2004 ABOUT_APACHE
    -rw-r--r--.  1  501 games  18571 6月  20 2008 acinclude.m4
    -rw-r--r--.  1  501 games  54614 6月   7 2008 Apache.dsw
    -rw-r--r--.  1  501 games 189152 11月 22 2004 apachenw.mcp.zip
    drwxr-xr-x.  5  501 games   4096 10月  7 2008 build
    -rw-r--r--.  1  501 games   2644 8月  24 2007 BuildAll.dsp
    -rw-r--r--.  1  501 games   2694 6月   7 2008 BuildBin.dsp
    -rwxr-xr-x.  1  501 games   5771 7月  12 2006 buildconf
    -rw-r--r--.  1  501 games  88633 10月  7 2008 CHANGES
    -rw-r--r--.  1  501 games  10943 11月 22 2004 config.layout
    -rwxr-xr-x.  1  501 games 648839 10月  7 2008 configure
    -rw-r--r--.  1  501 games  23370 6月  21 2008 configure.in
    -rw-r--r--.  1  501 games      0 10月  7 2008 .deps
    drwxr-xr-x.  9  501 games    124 10月  7 2008 docs
    -rw-r--r--.  1  501 games    403 11月 22 2004 emacs-style
    -rw-r--r--.  1  501 games   7214 1月  24 2005 .gdbinit
    -rw-r--r--.  1  501 games   4124 6月  12 2008 httpd.dsp
    -rw-r--r--.  1  501 games  19128 10月  7 2008 httpd.spec
    drwxr-xr-x.  2  501 games   4096 10月  7 2008 include
    -rw-r--r--.  1  501 games   4729 9月  19 2008 INSTALL
    -rw-r--r--.  1  501 games   2909 12月  8 2006 InstallBin.dsp
    -rw-r--r--.  1  501 games   5145 11月 29 2005 LAYOUT
    -rw-r--r--.  1  501 games  17039 1月  12 2007 libhttpd.dsp
    -rw-r--r--.  1  501 games  28690 1月  19 2008 LICENSE
    -rw-r--r--.  1  501 games   8696 2月   5 2008 Makefile.in
    -rw-r--r--.  1  501 games  33817 6月  13 2008 Makefile.win
    drwxr-xr-x. 20  501 games   4096 10月  7 2008 modules
    -rw-r--r--.  1  501 games    828 1月  11 2008 NOTICE
    -rw-r--r--.  1  501 games  10559 8月   7 2007 NWGNUmakefile
    drwxr-xr-x.  9  501 games    149 10月  7 2008 os
    -rw-r--r--.  1  501 games   5954 1月  10 2007 README
    -rw-r--r--.  1  501 games   4992 2月  18 2008 README.platforms
    -rw-r--r--.  1  501 games  10183 3月  14 2005 ROADMAP
    drwxr-xr-x.  3  501 games   4096 10月  7 2008 server
    drwxr-xr-x.  5  501 games     64 10月  7 2008 srclib
    drwxr-xr-x.  4  501 games   4096 10月  7 2008 support
    drwxr-xr-x.  2  501 games    248 10月  7 2008 test
    -rw-r--r--.  1  501 games   8183 10月 18 2005 VERSIONING
    [root@localhost httpd-2.2.10]# ./configure --prefix=/usr/local/apache2
    ...  # 省略
    config.status: creating build/config_vars.sh
    config.status: creating include/ap_config_auto.h
    config.status: include/ap_config_auto.h is unchanged
    config.status: executing default commands
    [root@localhost httpd-2.2.10]# 
    

    注意到这一过程中并没有报错.

    [root@localhost httpd-2.2.10]# ls -al
    总用量 1404
    drwxr-xr-x. 11  501 games   4096 1月  25 22:51 .
    drwxr-xr-x.  3 root root      53 1月  25 22:48 ..
    -rw-r--r--.  1  501 games  14882 11月 22 2004 ABOUT_APACHE
    -rw-r--r--.  1  501 games  18571 6月  20 2008 acinclude.m4
    -rw-r--r--.  1  501 games  54614 6月   7 2008 Apache.dsw
    -rw-r--r--.  1  501 games 189152 11月 22 2004 apachenw.mcp.zip
    drwxr-xr-x.  5  501 games   4096 1月  25 22:51 build
    -rw-r--r--.  1  501 games   2644 8月  24 2007 BuildAll.dsp
    -rw-r--r--.  1  501 games   2694 6月   7 2008 BuildBin.dsp
    -rwxr-xr-x.  1  501 games   5771 7月  12 2006 buildconf
    -rw-r--r--.  1  501 games  88633 10月  7 2008 CHANGES
    -rw-r--r--.  1  501 games  10943 11月 22 2004 config.layout
    -rw-r--r--.  1 root root   51107 1月  25 22:51 config.log
    -rwxr-xr-x.  1 root root      90 1月  25 22:51 config.nice
    -rwxr-xr-x.  1 root root   40057 1月  25 22:51 config.status
    -rwxr-xr-x.  1  501 games 648839 10月  7 2008 configure
    -rw-r--r--.  1  501 games  23370 6月  21 2008 configure.in
    -rw-r--r--.  1  501 games      0 1月  25 22:51 .deps
    drwxr-xr-x.  9  501 games    124 10月  7 2008 docs
    -rw-r--r--.  1  501 games    403 11月 22 2004 emacs-style
    -rw-r--r--.  1  501 games   7214 1月  24 2005 .gdbinit
    -rw-r--r--.  1  501 games   4124 6月  12 2008 httpd.dsp
    -rw-r--r--.  1  501 games  19128 10月  7 2008 httpd.spec
    drwxr-xr-x.  2  501 games   4096 1月  25 22:51 include
    -rw-r--r--.  1  501 games   4729 9月  19 2008 INSTALL
    -rw-r--r--.  1  501 games   2909 12月  8 2006 InstallBin.dsp
    -rw-r--r--.  1  501 games   5145 11月 29 2005 LAYOUT
    -rw-r--r--.  1  501 games  17039 1月  12 2007 libhttpd.dsp
    -rw-r--r--.  1  501 games  28690 1月  19 2008 LICENSE
    -rw-r--r--.  1 root root    8911 1月  25 22:51 Makefile
    -rw-r--r--.  1  501 games   8696 2月   5 2008 Makefile.in
    -rw-r--r--.  1  501 games  33817 6月  13 2008 Makefile.win
    drwxr-xr-x. 20  501 games   4096 1月  25 22:51 modules
    -rw-r--r--.  1 root root    3718 1月  25 22:51 modules.c
    -rw-r--r--.  1  501 games    828 1月  11 2008 NOTICE
    -rw-r--r--.  1  501 games  10559 8月   7 2007 NWGNUmakefile
    drwxr-xr-x.  9  501 games    178 1月  25 22:51 os
    -rw-r--r--.  1  501 games   5954 1月  10 2007 README
    -rw-r--r--.  1  501 games   4992 2月  18 2008 README.platforms
    -rw-r--r--.  1  501 games  10183 3月  14 2005 ROADMAP
    drwxr-xr-x.  3  501 games   4096 1月  25 22:51 server
    drwxr-xr-x.  5  501 games     93 1月  25 22:51 srclib
    drwxr-xr-x.  4  501 games   4096 1月  25 22:51 support
    drwxr-xr-x.  2  501 games    277 1月  25 22:51 test
    -rw-r--r--.  1  501 games   8183 10月 18 2005 VERSIONING
    [root@localhost httpd-2.2.10]# 
    

    make 编译

    • make clean # 万一编译过程报错,结束时清除编译之后的缓存文件
    [root@localhost httpd-2.2.10]# make
    ...
    make[1]: 离开目录“/usr/local/src/httpd-2.2.10”
    [root@localhost httpd-2.2.10]# ls -al
    总用量 2220
    drwxr-xr-x. 12  501 games   4096 1月  25 22:56 .
    drwxr-xr-x.  3 root root      53 1月  25 22:48 ..
    -rw-r--r--.  1  501 games  14882 11月 22 2004 ABOUT_APACHE
    -rw-r--r--.  1  501 games  18571 6月  20 2008 acinclude.m4
    -rw-r--r--.  1  501 games  54614 6月   7 2008 Apache.dsw
    -rw-r--r--.  1  501 games 189152 11月 22 2004 apachenw.mcp.zip
    drwxr-xr-x.  5  501 games   4096 1月  25 22:51 build
    -rw-r--r--.  1  501 games   2644 8月  24 2007 BuildAll.dsp
    -rw-r--r--.  1  501 games   2694 6月   7 2008 BuildBin.dsp
    -rwxr-xr-x.  1  501 games   5771 7月  12 2006 buildconf
    -rw-r--r--.  1 root root    1496 1月  25 22:56 buildmark.o
    -rw-r--r--.  1  501 games  88633 10月  7 2008 CHANGES
    -rw-r--r--.  1  501 games  10943 11月 22 2004 config.layout
    -rw-r--r--.  1 root root   51107 1月  25 22:51 config.log
    -rwxr-xr-x.  1 root root      90 1月  25 22:51 config.nice
    -rwxr-xr-x.  1 root root   40057 1月  25 22:51 config.status
    -rwxr-xr-x.  1  501 games 648839 10月  7 2008 configure
    -rw-r--r--.  1  501 games  23370 6月  21 2008 configure.in
    -rw-r--r--.  1  501 games      0 1月  25 22:51 .deps
    drwxr-xr-x.  9  501 games    124 10月  7 2008 docs
    -rw-r--r--.  1  501 games    403 11月 22 2004 emacs-style
    -rw-r--r--.  1  501 games   7214 1月  24 2005 .gdbinit
    -rwxr-xr-x.  1 root root  814640 1月  25 22:56 httpd
    -rw-r--r--.  1  501 games   4124 6月  12 2008 httpd.dsp
    -rw-r--r--.  1  501 games  19128 10月  7 2008 httpd.spec
    drwxr-xr-x.  2  501 games   4096 1月  25 22:51 include
    -rw-r--r--.  1  501 games   4729 9月  19 2008 INSTALL
    -rw-r--r--.  1  501 games   2909 12月  8 2006 InstallBin.dsp
    -rw-r--r--.  1  501 games   5145 11月 29 2005 LAYOUT
    -rw-r--r--.  1  501 games  17039 1月  12 2007 libhttpd.dsp
    drwxr-xr-x.  2 root root      23 1月  25 22:56 .libs
    -rw-r--r--.  1  501 games  28690 1月  19 2008 LICENSE
    -rw-r--r--.  1 root root    8911 1月  25 22:51 Makefile
    -rw-r--r--.  1  501 games   8696 2月   5 2008 Makefile.in
    -rw-r--r--.  1  501 games  33817 6月  13 2008 Makefile.win
    drwxr-xr-x. 20  501 games   4096 1月  25 22:51 modules
    -rw-r--r--.  1 root root    3718 1月  25 22:51 modules.c
    -rw-r--r--.  1 root root     273 1月  25 22:56 modules.lo
    -rw-r--r--.  1 root root    6064 1月  25 22:56 modules.o
    -rw-r--r--.  1  501 games    828 1月  11 2008 NOTICE
    -rw-r--r--.  1  501 games  10559 8月   7 2007 NWGNUmakefile
    drwxr-xr-x.  9  501 games    178 1月  25 22:51 os
    -rw-r--r--.  1  501 games   5954 1月  10 2007 README
    -rw-r--r--.  1  501 games   4992 2月  18 2008 README.platforms
    -rw-r--r--.  1  501 games  10183 3月  14 2005 ROADMAP
    drwxr-xr-x.  4  501 games   4096 1月  25 22:56 server
    drwxr-xr-x.  5  501 games     93 1月  25 22:51 srclib
    drwxr-xr-x.  5  501 games   4096 1月  25 22:56 support
    drwxr-xr-x.  2  501 games    277 1月  25 22:51 test
    -rw-r--r--.  1  501 games   8183 10月 18 2005 VERSIONING
    [root@localhost httpd-2.2.10]# 
    

    make install 编译安装

    [root@localhost httpd-2.2.10]# make install
    ...
    mkdir /usr/local/apache2/man/man8
    mkdir /usr/local/apache2/manual
    make[1]: 离开目录“/usr/local/src/httpd-2.2.10”
    [root@localhost httpd-2.2.10]# 
    

    查看安装位置:

    [root@localhost httpd-2.2.10]# ls -al /usr/local/apache2/
    总用量 32
    drwxr-xr-x. 14 root root  164 1月  25 22:57 .
    drwxr-xr-x. 13 root root  146 1月  25 22:57 ..
    drwxr-xr-x.  2 root root  243 1月  25 22:57 bin
    drwxr-xr-x.  2 root root  167 1月  25 22:57 build
    drwxr-xr-x.  2 root root   38 1月  25 22:57 cgi-bin
    drwxr-xr-x.  4 root root   84 1月  25 22:57 conf
    drwxr-xr-x.  3 root root 4096 1月  25 22:57 error
    drwxr-xr-x.  2 root root  139 10月  7 2008 htdocs
    drwxr-xr-x.  3 root root 8192 1月  25 22:57 icons
    drwxr-xr-x.  2 root root 4096 1月  25 22:57 include
    drwxr-xr-x.  2 root root    6 1月  25 22:57 logs
    drwxr-xr-x.  4 root root   30 1月  25 22:57 man
    drwxr-xr-x. 14 root root 8192 10月  7 2008 manual
    drwxr-xr-x.  2 root root   23 1月  25 22:57 modules
    [root@localhost httpd-2.2.10]# 
    

    启动:

    [root@localhost httpd-2.2.10]# /usr/local/apache2/bin/apachectl start
    httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
    (98)Address already in use: make_sock: could not bind to address [::]:80
    (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
    no listening sockets available, shutting down
    Unable to open logs
    [root@localhost httpd-2.2.10]# 
    

    端口冲突,先停掉端口

    [root@localhost httpd-2.2.10]# netstat -lnp|grep 80
    tcp6       0      0 :::80                   :::*                    LISTEN      126958/httpd        
    unix  2      [ ACC ]     STREAM     LISTENING     29380    1636/master          public/showq
    unix  2      [ ACC ]     STREAM     LISTENING     36801    2533/pulseaudio      /run/user/0/pulse/native
    [root@localhost httpd-2.2.10]# kill -9 126958
    [root@localhost httpd-2.2.10]# netstat -lnp|grep 80
    unix  2      [ ACC ]     STREAM     LISTENING     29380    1636/master          public/showq
    unix  2      [ ACC ]     STREAM     LISTENING     36801    2533/pulseaudio      /run/user/0/pulse/native
    [root@localhost httpd-2.2.10]# /usr/local/apache2/bin/apachectl start
    httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
    [root@localhost httpd-2.2.10]# netstat -lnp|grep 80                  
    tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      50998/httpd         
    unix  2      [ ACC ]     STREAM     LISTENING     29380    1636/master          public/showq
    unix  2      [ ACC ]     STREAM     LISTENING     36801    2533/pulseaudio      /run/user/0/pulse/native
    [root@localhost httpd-2.2.10]# 
    

    问题:我怎么知道Apache的启动命令是/usr/local/apache2/bin/apachectl start呢?

    [root@localhost httpd-2.2.10]# cd 
    [root@localhost ~]# pwd
    /root
    [root@localhost ~]# cd /usr/local/src/
    [root@localhost src]# cd httpd-2.2.10/
    [root@localhost httpd-2.2.10]# cat INSTALL 
    
      APACHE INSTALLATION OVERVIEW
    
      Quick Start - Unix
      ------------------
    
      For complete installation documentation, see [ht]docs/manual/install.html or
      http://httpd.apache.org/docs/2.2/install.html
       #...安装步骤
         $ ./configure --prefix=PREFIX  #...编译前准备,指定安装目录PREFIX
         $ make  # 编译
         $ make install  # 安装
         $ PREFIX/bin/apachectl start  # 启动方法: PREFIX由于第一步指定
    ...
    [root@localhost httpd-2.2.10]# 
    

    测试:
    先关闭防火墙:

    [root@localhost httpd-2.2.10]# systemctl status firewalld
    ● firewalld.service - firewalld - dynamic firewall daemon
       Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
       Active: active (running) since 三 2019-01-23 17:54:20 CST; 2 days ago
         Docs: man:firewalld(1)
     Main PID: 908 (firewalld)
        Tasks: 2
       CGroup: /system.slice/firewalld.service
               └─908 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
    
    1月 23 17:54:19 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
    1月 23 17:54:20 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
    [root@localhost httpd-2.2.10]# systemctl stop firewalld
    [root@localhost httpd-2.2.10]# systemctl status firewalld 
    ● firewalld.service - firewalld - dynamic firewall daemon
       Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
       Active: inactive (dead) since 六 2019-01-26 00:41:01 CST; 9s ago
         Docs: man:firewalld(1)
      Process: 908 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
     Main PID: 908 (code=exited, status=0/SUCCESS)
    
    1月 23 17:54:19 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
    1月 23 17:54:20 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
    1月 26 00:40:57 localhost.localdomain systemd[1]: Stopping firewalld - dynamic firewall daemon...
    1月 26 00:41:01 localhost.localdomain systemd[1]: Stopped firewalld - dynamic firewall daemon.
    [root@localhost httpd-2.2.10]# 
    

    说明:

    firewalld的基本使用
    启动: systemctl start firewalld
    关闭: systemctl stop firewalld
    查看状态: systemctl status firewalld
    开机禁用 : systemctl disable firewalld
    开机启用 : systemctl enable firewalld

    在这里插入图片描述
    修改:

    [root@localhost httpd-2.2.10]# vi /usr/local/apache2/htdocs/index.html
    <html><body><h1>It works!</h1><hr/><h2>Hello onefine</h2></body></html>
    ~                                                                                                                                                                                                                                                                                                                            
    :wq
    [root@localhost httpd-2.2.10]# cat /usr/local/apache2/htdocs/index.html
    <html><body><h1>It works!</h1><hr/><h2>Hello onefine</h2></body></html>
    [root@localhost httpd-2.2.10]# 
    

    在这里插入图片描述

    关闭:/usr/local/apache2/bin/apachectl stop

    ok,成功

    4. 源码包的卸载

    不需要卸载命令,直接删除安装目录即可,不会遗留任何垃圾文件。


    1. 脚本安装包 https://blog.csdn.net/jiduochou963/article/details/86655625
  • 相关阅读:
    ef左联三张表案例
    sql常用语句汇总
    最初的ajax案例
    asp.net mvc请求响应模型原理回顾
    viewstate cookie和session原理回顾
    一般处理程序装配数据到html页的原理
    asp.net页面生命周期回顾
    rocketMQ 消息的 tag
    rocketMQ 订阅关系
    rocketMQ retry 消息的实现
  • 原文地址:https://www.cnblogs.com/onefine/p/10499372.html
Copyright © 2011-2022 走看看