源码编译安装

author author     2022-07-31     603

关键词:

        在日常管理工作中,大部分软件都是通过源码安装的。安装一个源码包,是需要我们自己把源代码编译成二进制的可执行文件。使用源代码的好处有可以自定义修改源代码,还可以定制相关的功能,因为源代码在编译时是可以附加额外的选项的。

       源码包的编译用到了linux系统的编译器,常见的源码包一般都是用C语音开发的,这也是因为C语音是linux上最标准的程序语言。Linux上的C语音编译器叫做gcc,利用它就可以把C语音变成可执行的二进制文件。可以使用 yum install -y gcc 来安装。

       安装一个源码包,通常需要三个步骤:

      (1) ./configure

       在这一步,可以定制功能,加上相应的选项即可,具体有什么选项可以通过 ./configure --help命令来查看。在这一步会自动检测系统与相关的套件是否有编译该源码包所需要的库,只有检测通过才会生成一个 Makefile 文件。

      (2) make

       使用这个命令会根据 Makefile 文件中预设的参数进行编译,这一步其实就是 gcc 在工作了。

      (3) make install

       安装步骤,生成相关的软件存放目录和配置文件的过程。

       源码包的安装并非具有一定的标准安装步骤,这就需要在拿到源码包解压后,然后进入到目录找相关的帮助文档。通常会以INSTALL或README为文件名。

       下载一个源码包

        下载源码包最好到官方站点去下载,因为随便下载的源码包很有可能是被人修改过的。

[[email protected] ~]# cd /usr/local/src/
[[email protected] src]# ls
[[email protected] src]# wget http://mirrors.aliyun.com/apache/httpd/httpd-2.2.31.tar.bz2

        上面的地址是阿里云的镜像网站地址,国内下载速度比较快。在下载之前进入到了”/usr/local/src“目录,这是因为方便自己和其他管理员维护。所以,下载的源码包统一放到这个目录下吧。

         解压源码包

[[email protected] src]# tar jxvf httpd-2.2.31.tar.bz2

         配置相关的选项,并生成 Makefile

[[email protected] src]# cd httpd-2.2.31
[[email protected] httpd-2.2.31]# ./configure --help |less
`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]
:


        后面的内容未显示,使用 ./configure --help 命令查看可以使用的选项。一般常用的有 --prefix=PREFIX 这个选项的意思是定义软件包安装到哪里。通常源码包都是安装到 /usr/local 目录下的。比如,这个 apache 安装在 /usr/local/apache2 下。

[[email protected] httpd-2.2.31]# ./configure --prefix=/usr/local/apache2
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
Configuring Apache Portable Runtime library ...
checking for APR... reconfig
configuring package in srclib/apr now
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
Configuring APR library
Platform: x86_64-unknown-linux-gnu
checking for working mkdir -p... yes
APR Version: 1.5.2
checking for chosen layout... apr
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/usr/local/src/httpd-2.2.31/srclib/apr‘:
configure: error: no acceptable C compiler found in $PATH
See `config.log‘ for more details
configure failed for srclib/apr

       很不幸,报错了,根据提示可知没有gcc编译器,安装一下。

[[email protected] httpd-2.2.31]# yum install -y gcc

       安装完成后继续

[[email protected] httpd-2.2.31]# ./configure --prefix=/usr/local/apache2

       验证这一步是否成功的命令是:

[[email protected] httpd-2.2.31]# echo $?
0

       返回值如果是”0“则执行成功,否则就是没有成功。此时就生成了Makefile了。

[[email protected] httpd-2.2.31]# ls -l Makefile
-rw-r--r-- 1 root root 8954 5月  15 09:25 Makefile

       进行编译

[[email protected] httpd-2.2.31]# make

        这一步有可能提示没有发现 make 命令,需要安装一下,yum install -y make 。继续 make 后,会有很多类似乱七八糟的信息,编译的时间比较长,CPU使用率会很高,这是因为CPU高速计算。编译完后,再使用 echo $? 验证是否正常安装。

[[email protected] httpd-2.2.31]# echo $?
0
[[email protected] httpd-2.2.31]# make install
[[email protected] httpd-2.2.31]# echo $?
0
[[email protected] httpd-2.2.31]# ls /usr/local/apache2/
bin    cgi-bin  error   icons    lib   man     modules
build  conf     htdocs  include  logs  manual

        ”/usr/local/apache2“下增加了好多目录。到此,apache的源码包安装就完成了,在日常的源码安装工作中,遇到错误不能完成安装的情况很多,通常都是缺少某一个库文件所致。这时需要仔细查看报错信息或者查找当前目录下的"config.log"去得到相关的信息。或者。。搜索引擎


本文出自 “散宜生的学习笔记” 博客,请务必保留此出处http://sanyisheng.blog.51cto.com/11154168/1795708

源码编译安装lnmp环境

一、源码编译安装步骤首先说明源码安装的好处  速度快,可自定义路径主要有三步:1.配置进入源码安装包 ./configure--prefix=/uer/local/nginx 可指定参数--prefix为安装路径2.编译相当于rpm包 make3.安装makeinstall如果安... 查看详情

源码编译安装

在linux下面安装一个源码包是最常用的,在日常的管理工作中,大部分软件都是通过源码安装的。安装一个源码包,是需要我们自己把源代码编译成二进制的可执行文件。如果你读得懂这些源代码,那么你就可以去修改这些源代... 查看详情

lamp源码编译安装

查看详情

源码编译安装

...sp;   在日常管理工作中,大部分软件都是通过源码安装的。安装一个源码包,是需要我们自己把源代码编译成二进制的可执行文件。使用源代码的好处有可以自定义修改源代码,还可以定制相关的功能,因为源代码在... 查看详情

lamp架构nginxphpmysql源码编译安装(代码片段)

目录一、nginx源码编译及使用1.源码编译2.nginx配置及部署软连接瘦身nginx清除缓存不显示nginx版本nginx开机自启二、php源码编译及使用1.源码编译2.nginx结合php-fpm安装phpmyadmin三、mysql源码编译phpmyadmin连接mysql源码编译安装三部曲࿱... 查看详情

lamp架构nginxphpmysql源码编译安装(代码片段)

目录一、nginx源码编译及使用1.源码编译2.nginx配置及部署软连接瘦身nginx清除缓存不显示nginx版本nginx开机自启二、php源码编译及使用1.源码编译2.nginx结合php-fpm安装phpmyadmin三、mysql源码编译phpmyadmin连接mysql源码编译安装三部曲࿱... 查看详情

源码编译安装

除了用rpm、yum安装包外,还可以用源码编译安装源码包:代码可见的,要想在系统里运行,要翻译成机器语言,编译就是翻译的过程。源码包下载最好去官方网站以httpd为例下载地址650)this.width=650;"src="http://note.youdao.com/yws/res/1887/... 查看详情

源码编译安装lnmp架构环境

源码编译安装LNMP架构环境OS版本:2.6.32-431.el6.x86_64Nginx版本:nginx-1.6.1mariadb版本:mariadb-10.0.13php版本:php-5.4.261、安装编译安装所需系统环境~]#yumgroupinstall"DevelopmentTools""ServerPlatformDevelopment"-y2、编译安装nginx-1.6.1#yum 查看详情

源码编译安装httpd(代码片段)

源码编译安装MAKE项目???管理器???管理C、C++项目configure脚本通过配置此脚本,管理安装信息,例如定制安装路径,指定启用哪些功能,最终生成Makefile。由于格式复杂,需要借助模板Makefile.in。安装三大步骤一、下载源码包,并建... 查看详情

源码编译安装zabbix安装

先安装好LNMP环境mysql-uroot-p123456mysql>createdatabasezabbix;mysql>grantallonzabbix.*to[email protected]identifiedby‘123456‘;mysql>flushprivileges;安装zabbix:yuminstall-ynet-snmp-develtarxvfzab 查看详情

mairadb-源码编译安装(代码片段)

源码编译安装Mairadb1.先安装环境所需要的依赖组件[[email protected]~]#yum-yinstallbisonbison-develzlib-devellibcurl-devellibarchive-develboost-develgccgcc-c++cmakencurses-develgnutlsevellibxml2-developenssl-devellibe 查看详情

编译安装c源码程序程序

...;编译安装1安装GCC编译器:yum-yinstall"DevelopmentTools";2解压源码包:tar-xvfxxx.tar-C/usr/local/;3切换目录:cd/usr/local/xxx;4执行configure文件;./ 查看详情

mysql源码编译安装(代码片段)

目录:一、源码编译安装1.参考MySQL源码安装官方文档:2.MySQL的源码编译安装:①.安装MySQL编译需要用到的依赖库:②.上传软件到服务器端并解压③.配置(基于cmake进行配置)④.编译安装:编译报错常... 查看详情

源码编译安装httpd-2.4.39(代码片段)

环境centos7.6需要下载的源码编译安装包:官网http://www.apache.org/index.html#projects-listhttpd-2.4.39.tar.bz2(最小化安装系统需安装bzip2)apr-1.7.0.tar.gzapr-util-1.6.1.tar.gz基于最小化安装的centos系统,生产实践,源码编译需要安装下面组件yuminstall... 查看详情

源码编译安装libtool工具

1.获取源码  wget http://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.gz  tarxvf libtool-2.4.6.tar.gz-C~/  cd~/libtool-2.4.62.配置  ./configure--prefix=/home/jello/libtool3.编译  make-j44.安装  makeinstall 查看详情

源码安装步骤

把源码编译成二进制的可执行文件(自定义修改源代码,定制相关功能,附加额外选项)编译器(gcc):安装yuminstall-ygcc echo$?验证是否安装成功成功输出为0源码安装步骤1)./configure可定制相关功能(./configure-help)如果缺少相... 查看详情

tensorflow源码编译安装

##Installprerequisites(rhel)yuminstallnumpypython-develpython-wheelpython-mock##InstallBazelwgethttps://github.com/bazelbuild/bazel/releases/download/0.4.5/bazel-0.4.5-dist.zipunzipbazel-0.4.5-dist.zi 查看详情

源码编译安装httpd

1丶解包和配置。2丶编译安装。下图为安装编译和过程中的状态,这里将会等待几分钟,请耐心等待...3丶确认安装结果,如果出现下图所示,表示安装成功了。4丶优化执行路径。5丶添加httpd系统服务(添加好了之后就可以使用se... 查看详情