安装gcc
解压gcc并进入安装包的根目录
- tar -xzvf gcc-5.4.0.tar.gz
- cd gcc-5.4.0
在 gcc-5.4.0/contrib/download_prerequisites 文件中我们知道,需要下载四个依赖包
下载地址:Index of /sites/sourceware.org/pub/gcc/releases
上传第3步中的四个依赖包到 gcc-5.4.0目录下面,分别执行下面命令
tar xjf mpfr-2.4.2.tar.bz2
ln -sf mpfr-2.4.2 mpfr
tar xjf gmp-4.3.2.tar.bz2
ln -sf gmp-4.3.2 gmp
tar xzf mpc-0.8.1.tar.gz
ln -sf mpc-0.8.1 mpc
tar xjf isl-0.14.tar.bz2
ln -sf isl-0.14 isl
5,配置
./configure --disable-multilib --prefix=/data2/upchen/MyPackages/gcc/gcc-5.4.0 --enable-add-ones
注:如果出现 LD_LIBRARY_PATH 错误
hecking LD_LIBRARY_PATH variable... contains current directory
configure: error:
*** LD_LIBRARY_PATH shouldn't contain the current directory when
*** building glibc. Please change the environment variable
*** and run configure again.
则是因为LD_LIBRARY_PATH出现在了当前目录,参考解决办法,添加下面一行代码
export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/
在我机器上,是添加下面的代码,亲测有效
expport export LIBRARY_PATH=/usr/lib/x86_64-redhat-linux6E/
6,安装
Make
make install
导入路径
export PATH=/data2/upchen/MyPackages/gcc/gcc-5.4.0/bin:$PATH
查看版本
gcc -v 显示正确的版本
2. 上传到你的服务器目录,如:/home/tnuser/installers
解压:tar -zxvf httpd-2.4.3.tar.gz (我们下载的是源代码,所以这一步只是把源代码解压)
移动解压后的目录到目标地址:mv /home/tnuser/installers/httpd-2.4.3 /home/tnuser/ (这一步只是把解压后的目录放在合适的位置方便管理,可以不做)
3. 接下来我们需要编译刚才解压的源文件,这是重点
配置编译时的一些参数:
[plain] view plain copy print?
cd /home/tnuser/installers/httpd-2.4.3 (切换到apache源代码目录下)
./configure --prefix=/home/tnuser/apache/ (设置apache安装目录,这里的 /home/tnuser/apache/ 才是apache真正的安装目录)
二. 到这里时,回车运行命令,报错:
(如果你能正常执行,说明你以前安装过apache环境,请直接make & make install 并请跳过下面一段)
checking for APR... no
configure: error: APR not found. Please read the documentation.
解决方案:
Apache在安装时需要一些准备环境,这里需要安装另外一个东西 APR(Apache Portable Runtime)。
下载地址: http://archive.apache.org/dist/apr/ 同样找最新版本
得到文件:apr-1.4.6.tar.gz
解压:tar -zxvf apr-1.4.6.tar.gz
编译
[plain] view plain copy print?
cd /home/tnuser/installers/apr-1.4.6
./configure --prefix=/home/tnuser/apr/ (一堆日志信息)
make (一堆日志信息)
make install (一堆日志信息)
完成后在指定地址生成目录和文件
接着装apache,切换到源代码目录设置编译参数: ./configure --prefix=/home/tnuser/apache/
还是报上面的错,这是因为上面自定义了apr的安装目录,所以得把这个信息告诉apache。
正确的运行命令为:
[plain] view plain copy print?
./configure --prefix=/home/tnuser/apache/ --with-apr=/home/tnuser/apr/
三. 执行后继续报错
不过这次错误信息变成了:(不要紧,这说明你的apr安装好了,只是又发现少了另外一个环境,慢慢来)
checking for APR-util... no
configure: error: APR-util not found. Please read the documentation.
解决方案: 下载 APR-util
下载地址:http://archive.apache.org/dist/apr/ 找最新版本
得到文件:apr-util-1.5.1.tar.gz
解压: tar -zxvf apr-util-1.5.1.tar.gz
编译:
[plain] view plain copy print?
cd /home/tnuser/installers/apr-util-1.5.1
./configure --prefix=/home/tnuser/apr-util/
这次运行会报错:
checking for APR... no
configure: error: APR could not be located. Please use the --with-apr option.
看到提示你就懂了,不多说:
[plain] view plain copy print?
./configure --prefix=/home/tnuser/apr-util/ --with-apr=/home/tnuser/apr/
make
make install
在你指定的安装地址生成目录就说明安装成功了
四. 再转回去继续安装apache
有了上回的经验,这次就知道运行什么命令了。切到apache源代码目录下运行:
[plain] view plain copy print?
./configure --prefix=/home/tnuser/apache/ --with-apr=/home/tnuser/apr/ --with-apr-util=/home/tnuser/apr-util/
照旧报错:
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
解决方案:发现还是少环境,不多说,下载 PCRE
下载地址: http://jaist.dl.sourceforge.net/project/pcre/pcre/ 找最新版下
得到文件: pcre-8.32.tar.gz
解压:tar -zxvf pcre-8.32.tar.gz
编译:
[plain] view plain copy print?
cd /home/tnuser/hunter/installers/pcre-8.32
./configure --prefix=/home/tnuser/pcre/
这次错误信息如下:
checking for windows.h... no
configure: error: You need a C++ compiler for C++ support.
原来pcre需要用C++编译(我只想说:Why I need C++ while I'm a java programmer? Eggache! Holy Shit!)
解决方案:
首先,区分你的系统是Debian还是Fedora。
我的系统是Fedora,所以配置步骤如下:(Debian系统使用命令apt-get,对应工具包为build-essential,命令使用方法:apt-get install build-essential)
sudo yum groupinstall "Development Tools"
会花费很长时间安装东西,中间会选择是否安装,输入 y 就ok。
继续安装PCRE啊
[plain] view plain copy print?
./configure --prefix=/home/tnuser/pcre/
make
make install
安装成功
五. 继续apache的安装,一定要在参数中带上以上3种环境配置:
[plain] view plain copy print?
./configure --prefix=/home/tnuser/apache/ --with-apr=/home/tnuser/apr/ --with-apr-util=/home/tnuser/apr-util/ --with-pcre=/home/tnuser/pcre/
make
make install
六. 最后测试apache:
cd /home/tnuser/apache/bin
apachectl -k start
如果不能启动,查下端口冲突之类的问题(一般会与系统自带的httpd服务端口冲突)。
启动好后,访问你的apache,看到经典
It works!
关闭时用:apachectl -k stop
这文章我也不太清楚是摘抄的哪些大佬们的了,是自己当时安装的血泪史,所以共享一下,让下一位小伙伴能轻松些,如有侵权,联系删除