简介源代码安装nginx/apache

2023年 7月 15日 21.1k 0

在编译安装时请注意需求!必要时查看官方文档!
[root@centos3 ~]# rpm -qi glibc
Name : glibc Relocations: (not relocatable)
Version : 2.12 Vendor: CentOS
Release : 1.149.el6 Build Date: Wed 15 Oct 2014 10:00:58 AM CST
Install Date: Mon 13 Apr 2015 02:22:42 PM CST Build Host: c6b9.bsys.dev.centos.org
Group : System Environment/Libraries Source RPM: glibc-2.12-1.149.el6.src.rpm
Size : 12959134 License: LGPLv2+ and LGPLv2+ with exceptions and GPLv2+
Signature : RSA/SHA1, Sat 18 Oct 2014 04:00:42 AM CST, Key ID 0946fca2c105b9de
Packager : CentOS BuildSystem <http://bugs.centos.org>
URL : http://sources.redhat.com/glibc/
Summary : The GNU libc libraries
Description :
The glibc package contains standard libraries which are used by
multiple programs on the system. In order to save disk space and
memory, as well as to make upgrading easier, common system code is
kept in one place and shared between programs. This particular package
contains the most important sets of shared libraries: the standard C
library and the standard math library. Without these two libraries, a
Linux system will not function.
[root@centos3 ~]#
手动编译源代码文件:
依赖环境:编译开发工具、以及各个被依赖到的程序包的开发组件
包组:
Development tools
server platform development
desktop platform development
[root@centos3 /]# yum -y groupinstall "Development tools" "server platform development"
这里省略一千字!
Installed:
autoconf.noarch 0:2.63-5.1.el6 automake.noarch 0:1.11.1-4.el6
bison.x86_64 0:2.4.1-5.el6 byacc.x86_64 0:1.9.20070509-7.el6
cscope.x86_64 0:15.6-6.el6 ctags.x86_64 0:5.8-2.el6
dbus-devel.x86_64 1:1.2.24-7.el6_3 diffstat.x86_64 0:1.51-2.el6
doxygen.x86_64 1:1.6.1-6.el6 flex.x86_64 0:2.5.35-9.el6
gcc.x86_64 0:4.4.7-11.el6 gcc-c++.x86_64 0:4.4.7-11.el6
gcc-gfortran.x86_64 0:4.4.7-11.el6 git.x86_64 0:1.7.1-3.el6_4.1
indent.x86_64 0:2.2.10-7.el6 intltool.noarch 0:0.41.0-1.1.el6
krb5-devel.x86_64 0:1.10.3-33.el6 libstdc++-devel.x86_64 0:4.4.7-11.el6
libtool.x86_64 0:2.2.6-15.5.el6 libvirt-devel.x86_64 0:0.10.2-46.el6
libvirt-java-devel.noarch 0:0.4.9-1.el6 ncurses-devel.x86_64 0:5.7-3.20090208.el6
nss-devel.x86_64 0:3.16.1-14.el6 openldap-devel.x86_64 0:2.4.39-8.el6
openssl-devel.x86_64 0:1.0.1e-30.el6 pam-devel.x86_64 0:1.1.1-20.el6
patchutils.x86_64 0:0.3.1-3.1.el6 rcs.x86_64 0:5.7-37.el6
redhat-rpm-config.noarch 0:9.0.3-42.el6.centos rpm-build.x86_64 0:4.8.0-37.el6
subversion.x86_64 0:1.6.11-10.el6_5 swig.x86_64 0:1.3.40-6.el6
systemtap.x86_64 0:2.5-5.el6 zlib-devel.x86_64 0:1.2.3-29.el6
Dependency Installed:
cloog-ppl.x86_64 0:0.15.7-1.2.el6 cpp.x86_64 0:4.4.7-11.el6
cyrus-sasl-devel.x86_64 0:2.1.23-15.el6 cyrus-sasl-md5.x86_64 0:2.1.23-15.el6
gdb.x86_64 0:7.2-75.el6 gettext-devel.x86_64 0:0.17-18.el6
gettext-libs.x86_64 0:0.17-18.el6 giflib.x86_64 0:4.1.6-3.1.el6
gnutls-utils.x86_64 0:2.8.5-14.el6_5 java-1.7.0-openjdk.x86_64 1:1.7.0.65-2.5.1.2.el6_5
jna.x86_64 0:3.2.4-2.el6 jpackage-utils.noarch 0:1.7.5-3.12.el6
kernel-devel.x86_64 0:2.6.32-504.el6 keyutils-libs-devel.x86_64 0:1.4-5.el6
libcom_err-devel.x86_64 0:1.41.12-21.el6 libgcj.x86_64 0:4.4.7-11.el6
libgfortran.x86_64 0:4.4.7-11.el6 libselinux-devel.x86_64 0:2.0.94-5.8.el6
libsepol-devel.x86_64 0:2.0.41-4.el6 libvirt-client.x86_64 0:0.10.2-46.el6
libvirt-java.noarch 0:0.4.9-1.el6 mpfr.x86_64 0:2.4.1-6.el6
nc.x86_64 0:1.84-22.el6 nspr-devel.x86_64 0:4.10.6-1.el6_5
nss-softokn-devel.x86_64 0:3.14.3-17.el6 nss-softokn-freebl-devel.x86_64 0:3.14.3-17.el6
nss-util-devel.x86_64 0:3.16.1-3.el6 perl-Error.noarch 1:0.17015-4.el6
perl-Git.noarch 0:1.7.1-3.el6_4.1 ppl.x86_64 0:0.10.2-11.el6
systemtap-client.x86_64 0:2.5-5.el6 systemtap-devel.x86_64 0:2.5-5.el6
tzdata-java.noarch 0:2014g-1.el6 yajl.x86_64 0:1.0.7-3.el6
Complete!
[root@centos3 /]#
[root@centos3 ~]# lftp 172.16.0.1
lftp 172.16.0.1:~> mget /pub/Sources/sources/nginx/nginx-1.6.2.tar.gz
804164 bytes transferred
lftp 172.16.0.1:/> bye
[root@centos3 ~]# ls
anaconda-ks.cfg install.log install.log.syslog nginx-1.6.2.tar.gz
[root@centos3 ~]# useradd -r nginx
[root@centos3 ~]# tar xf nginx-1.6.2.tar.gz
[root@centos3 ~]# cd nginx-1.6.2
[root@centos3 nginx-1.6.2]# ./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx.conf --user=nginx --group=nginx
这里省略一千字
checking for PCRE library in /usr/include/pcre/ ... not found
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found
已经报错
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
[root@centos3 nginx-1.6.2]# yum install pcre-devel -y
这里省略一千字
Install 1 Package(s)
Total download size: 318 k
Installed size: 954 k
Downloading Packages:
pcre-devel-7.8-6.el6.x86_64.rpm | 318 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : pcre-devel-7.8-6.el6.x86_64 1/1
Verifying : pcre-devel-7.8-6.el6.x86_64 1/1
Installed:
pcre-devel.x86_64 0:7.8-6.el6
Complete!
[root@centos3 nginx-1.6.2]# ./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx.conf --user=nginx --group=nginx
creating objs/Makefile
Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ md5: using system crypto library
+ sha1: using system crypto library
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/etc"
nginx configuration file: "/etc/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
[root@centos3 nginx-1.6.2]# make
[root@centos3 nginx-1.6.2]# make install
安装完成!
安装的路径和配置文件
[root@centos3 nginx-1.6.2]# cd /usr/local/nginx/
[root@centos3 nginx]# ls
html logs sbin
[root@centos3 nginx]# ls /usr/local/nginx/sbin/
nginx
[root@centos3 nginx]#
再来!
lftp 172.16.0.1:/pub/Sources/sources/httpd> mget httpd-2.2.29.tar.bz2
5625498 bytes transferred
lftp 172.16.0.1:/pub/Sources/sources/httpd> bye
[root@centos3 ~]# rpm -q httpd
httpd-2.2.15-39.el6.centos.x86_64
[root@centos3 ~]# rpm -e httpd
error: Failed dependencies:
httpd >= 2.2.0 is needed by (installed) gnome-user-share-2.28.2-3.el6.x86_64
[root@centos3 ~]# yum remove httpd
Running Transaction
Erasing : gnome-user-share-2.28.2-3.el6.x86_64 1/2
Erasing : httpd-2.2.15-39.el6.centos.x86_64 2/2
Verifying : httpd-2.2.15-39.el6.centos.x86_64 1/2
Verifying : gnome-user-share-2.28.2-3.el6.x86_64 2/2
Removed:
httpd.x86_64 0:2.2.15-39.el6.centos
Dependency Removed:
gnome-user-share.x86_64 0:2.28.2-3.el6
Complete!
[root@centos3 ~]#
[root@centos3 ~]# tar xf httpd-2.2.29.tar.bz2
[root@centos3 ~]# ls
anaconda-ks.cfg httpd-2.2.29.tar.bz2 install.log.syslog nginx-1.6.2.tar.gz
httpd-2.2.29 install.log nginx-1.6.2
[root@centos3 ~]# cd httpd-2.2.29
[root@centos3 httpd-2.2.29]# ls
ABOUT_APACHE CHANGES httpd.dsp libhttpd.dep NOTICE server
acinclude.m4 config.layout httpd.mak libhttpd.dsp NWGNUmakefile srclib
Apache.dsw configure httpd.spec libhttpd.mak os support
build configure.in include LICENSE README test
BuildAll.dsp docs INSTALL Makefile.in README.platforms VERSIONING
BuildBin.dsp emacs-style InstallBin.dsp Makefile.win README-win32.txt
buildconf httpd.dep LAYOUT modules ROADMAP
[root@centos3 httpd-2.2.29]#
在安装之前可以读读install文件
[root@centos3 httpd-2.2.29]# less INSTALL
--help查看选项
[root@centos3 httpd-2.2.29]# ./configure --help
[root@centos3 httpd-2.2.29]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd/ --enable-so
这里省略很多内容。
config.status: executing default commands
[root@centos3 httpd-2.2.29]# make
[root@centos3 httpd-2.2.29]# make install
Installing header files
Installing build system files
Installing man pages and online manual
mkdir /usr/local/apache/man
mkdir /usr/local/apache/man/man1
mkdir /usr/local/apache/man/man8
mkdir /usr/local/apache/manual
make[1]: Leaving directory `/root/httpd-2.2.29'
[root@centos3 httpd-2.2.29]# cd /usr/local/apache/
[root@centos3 apache]# ls
bin build cgi-bin error htdocs icons include lib logs man manual modules
[root@centos3 apache]#
[root@centos3 apache]# ls /usr/local/apache/bin/
ab apu-1-config dbmmanage htcacheclean htpasswd logresolve
apachectl apxs envvars htdbm httpd rotatelogs
apr-1-config checkgid envvars-std htdigest httxt2dbm
[root@centos3 apache]#
添加环境变量搜索路径
[root@centos3 apache]# echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@centos3 apache]#
加入坏境变量
[root@centos3 apache]# vim /etc/profile.d/httpd.sh
export PATH=/usr/local/apache/bin:$PATH
[root@centos3 apache]# . /etc/profile.d/httpd.sh
[root@centos3 apache]# echo $PATH
/usr/local/apache/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@centos3 apache]# apachectl
Usage: /usr/local/apache/bin/httpd [-D name] [-d directory] [-f file]
[-C "directive"] [-c "directive"]
[-k start|restart|graceful|graceful-stop|stop]
[-v] [-V] [-h] [-l] [-L] [-t] [-T] [-S]
Options:
-D name : define a name for use in <IfDefine name> directives
-d directory : specify an alternate initial ServerRoot
-f file : specify an alternate ServerConfigFile
-C "directive" : process directive before reading config files
-c "directive" : process directive after reading config files
-e level : show startup errors of level (see LogLevel)
-E file : log startup errors to file
-v : show version number
-V : show compile settings
-h : list available command line options (this page)
-l : list compiled in modules
-L : list available configuration directives
-t -D DUMP_VHOSTS : show parsed settings (currently only vhost settings)
-S : a synonym for -t -D DUMP_VHOSTS
-t -D DUMP_MODULES : show all loaded modules
-M : a synonym for -t -D DUMP_MODULES
-t : run syntax check for config files
-T : start without DocumentRoot(s) check
[root@centos3 apache]#
库文件:
Last login: Mon Apr 13 21:54:06 2015 from 172.16.250.167
[root@centos3 ~]# man httpd
No manual entry for httpd
[root@centos3 ~]#
下面的库文件没有被系统找到
[root@centos3 apache]# ls /usr/local/apache/lib/
apr.exp libapr-1.so.0 libaprutil-1.so.0 libexpat.so.0
aprutil.exp libapr-1.so.0.5.1 libaprutil-1.so.0.5.3 libexpat.so.0.5.0
libapr-1.a libaprutil-1.a libexpat.a pkgconfig
libapr-1.la libaprutil-1.la libexpat.la
libapr-1.so libaprutil-1.so libexpat.so
[root@centos3 apache]#
[root@centos3 apache]# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
[root@centos3 apache]# ldconfig -p | grep /usr/local/apache/lib/
[root@centos3 apache]# vim /etc/ld.so.conf.d/httpd.conf
/usr/local/apapche/lib
[root@centos3 apache]# ldconfig
[root@centos3 apache]# ldconfig -p | grep /usr/local/apache/lib/
libexpat.so.0 (libc6,x86-64) => /usr/local/apache/lib/libexpat.so.0
libexpat.so (libc6,x86-64) => /usr/local/apache/lib/libexpat.so
libaprutil-1.so.0 (libc6,x86-64) => /usr/local/apache/lib/libaprutil-1.so.0
libaprutil-1.so (libc6,x86-64) => /usr/local/apache/lib/libaprutil-1.so
libapr-1.so.0 (libc6,x86-64) => /usr/local/apache/lib/libapr-1.so.0
libapr-1.so (libc6,x86-64) => /usr/local/apache/lib/libapr-1.so
[root@centos3 apache]#
头文件导出方案:
头文件存放路径/usr/include/,输出httpd给系统头文件
[root@centos3 apache]# ln -sv /usr/local/apache/include /usr/include/httpd
`/usr/include/httpd' -> `/usr/local/apache/include'
[root@centos3 apache]# ls -l /usr/include/httpd
lrwxrwxrwx 1 root root 25 Apr 13 22:54 /usr/include/httpd -> /usr/local/apache/include
[root@centos3 apache]# ls /usr/include/httpd/
ap_compat.h apr_file_info.h apr_pools.h apr_user.h mod_dbd.h
ap_config_auto.h apr_file_io.h apr_portable.h apr_uuid.h mod_include.h
ap_config.h apr_fnmatch.h apr_proc_mutex.h apr_version.h mod_log_config.h
ap_config_layout.h apr_general.h apr_queue.h apr_want.h mod_proxy.h
ap_listen.h apr_getopt.h apr_random.h apr_xlate.h mod_rewrite.h
ap_mmn.h apr_global_mutex.h apr_reslist.h apr_xml.h mod_ssl.h
ap_mpm.h apr.h apr_ring.h apu_errno.h mod_status.h
ap_provider.h apr_hash.h apr_rmm.h apu.h mpm_common.h
apr_allocator.h apr_hooks.h apr_sdbm.h apu_version.h mpm_default.h
apr_anylock.h apr_inherit.h apr_sha1.h apu_want.h mpm.h
apr_atomic.h apr_ldap.h apr_shm.h expat.h os.h
apr_base64.h apr_ldap_init.h apr_signal.h http_config.h scoreboard.h
apr_buckets.h apr_ldap_option.h apr_skiplist.h http_connection.h unixd.h
apr_crypto.h apr_ldap_rebind.h apr_strings.h http_core.h util_cfgtree.h
apr_date.h apr_ldap_url.h apr_strmatch.h httpd.h util_charset.h
apr_dbd.h apr_lib.h apr_support.h http_log.h util_ebcdic.h
apr_dbm.h apr_md4.h apr_tables.h http_main.h util_filter.h
apr_dso.h apr_md5.h apr_thread_cond.h http_protocol.h util_ldap.h
ap_regex.h apr_memcache.h apr_thread_mutex.h http_request.h util_md5.h
ap_regkey.h apr_mmap.h apr_thread_pool.h http_vhost.h util_script.h
ap_release.h apr_network_io.h apr_thread_proc.h mod_auth.h util_time.h
apr_env.h apr_optional.h apr_thread_rwlock.h mod_cgi.h util_xml.h
apr_errno.h apr_optional_hooks.h apr_time.h mod_core.h
apr_escape.h apr_poll.h apr_uri.h mod_dav.h
[root@centos3 apache]#
man手册文件
1,[root@centos3 apache]# vim /etc/man.config
MANPATH /usr/local/apache/man
,2,[root@centos3 apache]# man -M /usr/local/apache/man

相关文章

LeaferJS 1.0 重磅发布:强悍的前端 Canvas 渲染引擎
10分钟搞定支持通配符的永久有效免费HTTPS证书
300 多个 Microsoft Excel 快捷方式
一步步配置基于kubeadmin的kubevip高可用
istio全链路传递cookie和header灰度
REST Web 服务版本控制

发布评论