源代码转换
1.准备工作
清空防火墙,iptables -F
httpd-2.2.25.tar.gz(2.2.25的版本)
yum -y install gcc*
2.安装httpd服务
tar zxf httpd-2.2.25.tar.gz -C /usr/src/
cd /usr/src/httpd-
./configure --prefix=/usr/local/httpd --enable-so --enable-rewribe --enable-charset-lite --enable-sockets --enable-cgi && make && make install
注意:
cd /usr/src/httpd
安装不会的时候。
然后查看 INSTALL 大写的都是可阅读文件 READAM
cd /usr/local/httpd/bin/
cp -p apachectl /etc/init.d
mv apachectl httpd
chmod +x httpd
vim /etc/init.d/network
复制里边的两行
# chkconfig: 2345 10 90
# description: Activates/Deactivates all network interfaces configured to start at boot time.
vim /etc/init.d/httpd
修改:
# chkconfig: 2345 91 91
# description:This is my web——server
计算机的开机启动级别
cd /etc/rc0.d/
cd /etc/rc1.d/
cd /etc/rc2.d/
cd /etc/rc3.d/
cd /etc/rc4.d/
cd /etc/rc5.d/
k——kill
s——start
将系统服务软连接到开机自启动3和5级别里。
ln -s /etc/init.d/httpd /etc/rc3.d/K91httpd
ln -s /etc/init.d/httpd /etc/rc5.d/K91httpd
ln -s /etc/init.d/httpd /etc/rc3.d/S91httpd
ln -s /etc/init.d/httpd /etc/rc5.d/S91httpd
chkconfig --add httpd
chkconfig httpd on
chkconfig httpd --list
service httpd restart
2.root用户安装软件包管理器build
yum -y install rpm-build
rpm -qa | grep rpm-build
3.创建用户:
useradd li
passwd li
切换用户:
su - li
**********************************************
4.在root用户下查看未安装软件包的详细信息
cd /media/cdrom/PACKGES/
rpm -qpi httpd-2.2.25-1.el6.x86_64.rpm
Name : httpd Relocations: (not relocatable)
Version : 2.2.15 Vendor: CentOS
Release : 29.el6.centos Build Date: 2013年08月14日 星期三 01时30分33秒
Install Date: (not installed) Build Host: c6b8.bsys.dev.centos.org
Group : System Environment/Daemons Source RPM: httpd-2.2.15-29.el6.centos.src.rpm
Size : 3076447 License: ASL 2.0
Signature : RSA/SHA1, 2013年08月14日 星期三 01时32分39秒, Key ID 0946fca2c105b9de
Packager : CentOS BuildSystem <http://bugs.centos.org>
URL : http://httpd.apache.org/
Summary : Apache HTTP Server
Description :
The Apache HTTP Server is a powerful, efficient, and extensible
web server.
上边的参数解释:
名称:HTTPD重定位:(不可重新定位)
版本:2.2.15供应商:CITOS
发布日期:27.el6的建造日期:2013,08,14,01,30,33
安装日期:(未安装)构建主机:C6B8Bys.DEV.CENTSO.ORG
组:系统环境/守护进程源RPM:HTTPD-2.2.15-27.el6 CENT.SRC.RPM
尺寸:3076447许可证:ASL 2
签名:RSA/Sa1,2013,08,14,01,32,32,39,钥匙ID 0946FCA2C105B9DE
打包器:CENTOS构建系统
URL:HTTP:/HTTP.APACHE.Org/
Apache HTTP服务器概述
描述:
Apache HTTP服务器是一种强大的、高效的、可扩展的服务器。
Web服务器。
***************************************************
5.编辑源码转换rpm包的文件
vim httpd.spec
Name:httpd
Version:2.2.25
Release: 1%{?dist}
Summary:Apache HTTP Server
Group:System Environment/Daemons
License:GPL
URL:http://httpd.apache.org/
Source0:httpd-2.2.25.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildRequires:openssl-devel
Requires:vsftpd
%description
The Apache HTTP Server is a powerful, efficient, and extensible
web server.
%prep
%setup -q
%build
./configure --prefix=/usr/local/myhttpd --enable-so --enable-rewribe --enable-charset-lite --enable-sockets --enable-cgi
make %{?_smp_mflags}
%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
/usr/local/myhttpd/bin/*
/usr/local/myhttpd/cgi-bin/*
%config /usr/local/myhttpd/conf/*
/usr/local/myhttpd/build/*
/usr/local/myhttpd/error/*
/usr/local/myhttpd/htdocs/*
/usr/local/myhttpd/icons/*
/usr/local/myhttpd/include/*
/usr/local/myhttpd/lib/*
%dir /usr/local/myhttpd/logs
%doc /usr/local/myhttpd/man/*
%doc /usr/local/myhttpd/manual/*
/usr/local/myhttpd/modules/*
%post
ln -s /usr/local/myhttpd/bin/* /usr/local/bin/
cp -p /usr/local/myhttpd/bin/apachectl /etc/init.d/myhttpd
chmod +x /etc/init.d/myhttpd
sed -i '1a #chkconfig: 2345 91 91' /etc/init.d/myhttpd
sed -i '2a # description: haha' /etc/init.d/myhttpd
ln -s /etc/init.d/myhttpd /etc/rc3.d/K92myhttpd
ln -s /etc/init.d/myhttpd /etc/rc5.d/K92myhttpd
ln -s /etc/init.d/myhttpd /etc/rc3.d/S92myhttpd
ln -s /etc/init.d/myhttpd /etc/rc5.d/S92myhttpd
chkconfig --add myhttpd
%preun
/etc/init.d/myhttp stop
chkconfig --del myhttpd
rm -rf /etc/rc3.d/K92myhttpd
rm -rf /etc/rc5.d/K92myhttpd
rm -rf /etc/rc3.d/S92myhttpd
rm -rf /etc/rc5.d/S92myhttpd
rm -rf /etc/init.d/myhttpd
rm -rf /usr/local/myhttpd
%changelog
* Wed May 9 2018 lisir <lisir@redhat.com> 2.2.25-1 //注意:必须和自己系统时间相同
- first rpm from httpd-2.2.25
"httpd.spec" 78L, 1881C
********************************************
5.httpd.spec文件参数解释:
build requires
生成源码包的依赖包,必须存在,
编译是的依赖包 openssl-devel
安装时候的依赖包 vsftpd
要执行哪个语句安装:
&buil
./configure --prefix=/usr/local/myhttpd --enable-so --enable-rewribe --enable-charset-lite --enable-sockets --enable-cgi
%files安装后生成的文件
cd /usr/local/httpd ls
/usr/local/myhttpd/bin/*
/usr/local/myhttpd/cgi-bin/*
%config /usr/local/myhttpd/conf/*
/usr/local/myhttpd/build/*
/usr/local/myhttpd/error/*
/usr/local/myhttpd/htdocs/*
/usr/local/myhttpd/icons/*
/usr/local/myhttpd/include/*
/usr/local/myhttpd/lib/*
%dir /usr/local/myhttpd/logs
%doc /usr/local/myhttpd/man/*
%doc /usr/local/myhttpd/manual/*
/usr/local/myhttpd/modules/*
安装完成执行的操作
%post
ln -s /usr/local/myhttpd/bin/* /usr/local/bin/
cp -p /usr/local/myhttpd/bin/apachectl /etc/init.d/myhttpd
chmod +x /etc/init.d/myhttpd
sed -i '1a #chkconfig: 2345 91 91' /etc/init.d/myhttpd
sed -i '2a # description: haha' /etc/init.d/myhttpd
ln -s /etc/init.d/myhttpd /etc/rc3.d/K92myhttpd
ln -s /etc/init.d/myhttpd /etc/rc5.d/K92myhttpd
ln -s /etc/init.d/myhttpd /etc/rc3.d/S92myhttpd
ln -s /etc/init.d/myhttpd /etc/rc5.d/S92myhttpd
chkconfig --add myhttpd
卸载的时候需要的操作
%preun
/etc/init.d/myhttp stop
chkconfig --del myhttpd
rm -rf /etc/rc3.d/K92myhttpd
rm -rf /etc/rc5.d/K92myhttpd
rm -rf /etc/rc3.d/S92myhttpd
rm -rf /etc/rc5.d/S92myhttpd
rm -rf /etc/init.d/myhttpd
rm -rf /usr/local/myhttpd
交换日志信息时间和日期,必须和自己的系统时间一样
%changelog
* Wed May 9 2018 lisir <lisir@redhat.com> 2.2.25-1
- first rpm from httpd-2.2.25
"httpd.spec" 78L, 1881C
***************************************************
6.查看交换日志信息,包含时间日期等,将这个写到httpd.spec文件里最后。
cd /media/Packages
rpm -qp -changelog httpd-2.2.15-29.el6.centos.x86_64.rpm
7.安装依赖关系包
yum -y install openssl vsftpd
8.执行配置文件,报错生成路径,用来复制httpd要修改的源码包。
[li@localhost ~]$ rpmbuild httpd.spec
error: File /home/li/rpmbuild/SOURCES/httpd-2.2.25.tar.gz: 没有那个文件或目录
[li@localhost ~]$ ls
httpd.spec rpmbuild
9.在root用户下执行:
cp /root/httpd-2.2.25.tar.gz /home/li/rpmbuild/SOURCES
10.执行转换文件
rpmbuild -ba httpd.spec
参数解释:
-ba 生成源码包和二进制包
-bb 只生成二进制包
11.查看生成的rpm包
cd rpmbuild/RPMS/x86_64/
ls /home/li/rpmbuild/SRPMS
httpd-2.2.25-1.el6.src.rpm
cd rpmbuild/SRPMS/
ls /home/li/rpmbuild/RPMS/x86_64
httpd-2.2.25-1.el6.x86_64.rpm httpd-debuginfo-2.2.25-1.el6.x86_64.rpm
12.将li用户生成的rpm转换包复制到/tmp/目录下,然后用root用户执行
cp httpd-2.2.25-1.el6.x86_64.rpm /tmp
13.yum安装通过编译转换的rpm包。
root用户:
rpm -ivh /root/桌面/httpd-2.2.25-1.el6.x86_64.rpm
service myhttpd restart
firefox 192.168.117.145
看到it work!
*************************************
nginx源码包转换为rpm包,其他安装步骤如同apache
yum -y install rpm-build
yum -y install pcre-devel zlib-devel
vim nginx.spec
编辑修改:
Name:nginx
Version:1.8.1
Release: 1%{?dist}
Summary:nginx service
Group:System Environment/Daemons
License:GPL
URL:www.nginx.com
Source0:nginx-1.8.1.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildRequires:pcre-devel
Requires:vim
%description
this is nginx service
%prep
%setup -q
%build
./configure --prefix=/usr/local/nginx
make %{?_smp_mflags}
%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,0755)
/usr/local/nginx/
%config(noreplace) /usr/local/nginx/conf/nginx.conf
%config(noreplace) /usr/local/nginx/conf/fastcgi_params
%post
echo '#!/bin/bash' > /etc/init.d/nginx
echo '#### welcome to nginx ####' >> /etc/init.d/nginx
echo '# chkconfig: - 99 20' >> /etc/init.d/nginx
echo '# description: this is nginx server' >> /etc/init.d/nginx
echo 'PROG="/usr/local/nginx/sbin/nginx"' >> /etc/init.d/nginx
echo 'PIDF="/usr/local/nginx/logs/nginx.pid"' >> /etc/init.d/nginx
echo 'case "$1" in' >> /etc/init.d/nginx
echo ' start)' >> /etc/init.d/nginx
echo ' $PROG' >> /etc/init.d/nginx
echo ' ;;' >> /etc/init.d/nginx
echo ' stop)' >> /etc/init.d/nginx
echo ' kill -s QUIT $(cat $PIDF)' >> /etc/init.d/nginx
echo ' ;;' >> /etc/init.d/nginx
echo ' restart)' >> /etc/init.d/nginx
echo ' $0 stop' >> /etc/init.d/nginx
echo ' $0 start' >> /etc/init.d/nginx
echo ' ;;' >> /etc/init.d/nginx
echo ' reload)' >> /etc/init.d/nginx
echo ' kill -s HUP $(cat $PIDF)' >> /etc/init.d/nginx
echo ' ;;' >> /etc/init.d/nginx
echo ' *)' >> /etc/init.d/nginx
echo ' echo "Usage: $0 {start|stop|restart|status}"' >> /etc/init.d/nginx
echo ' exit' >> /etc/init.d/nginx
echo ' ;;' >> /etc/init.d/nginx
echo ' esac' >> /etc/init.d/nginx
echo ' exit 0' >> /etc/init.d/nginx
chmod +x /etc/init.d/nginx
service nginx start
chkconfig --add nginx
chkconfig nginx on
%preun
/etc/init.d/nginx stop
chkconfig --del nginx
rm -rf /etc/init.d/httpd
rm -rf /usr/local/httpd
%changelog
* Wed May 9 2018 lipengcheng <930777521@qq.com> 1.8.1
- first rpm from nginx-1.8.1
执行转换配置文件:
rpmbuild nginx.spec
cp nginx-1.8.1.tar.gz /root/rpmbuild/SOURCES/
rpmbuild -ba nginx.spec
cd rpmbuild/SRPMS/
ls
cd rpmbuild/RPMS/x86_64/
ls
rpm -ivh nginx-1.8.1-1.el6.x86_64.rpm
service nginx restart
netstat -anpt | grep nginx
firefox 192.168.117.145