搭建yum倉庫及定製rpm包

在管理機m01-61php


cd /home/oldboy/toolshtml

rz nginx    rz  fpm  而且 rpm -ivh fpm-1.6.3-1.x86_64.rpmmysql

tar -xf nginxlinux

修改配置(開啓yum 緩存)nginx

sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.confsql

清空緩存vim

find /var/cache/ -type f -name '*rpm'|xargs rm -fcentos

######作快照!#######緩存

安裝依賴包bash

yum install pcre-devel openssl-devel -y

.........

find /var/cache/ -type f -name '*rpm'|xargs cp -t /tmp/

cd /tmp/ && tar zcf nginx_yum.tar.gz *.rpm

sz nginx_yum.tar.gz


cd /home/oldboy/tools/

[root@m01-61 tools]# useradd -M -s /sbin/nologin nginx

[root@m01-61 tools]# cd nginx-1.8.1

./configure --prefix=/application/nginx-1.8.1 --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module

make && make install

ln -s /application/nginx-1.8.1/ /application/nginx


root@oldboyedu ~]# mkdir -p /server/scripts/

[root@oldboyedu ~]# cd /server/scripts/

[root@oldboyedu scripts]# vim nginx_rpm.sh  # 這是安裝完rpm包要執行的腳本

#!/bin/bash

useradd nginx -M -s /sbin/nologin

ln -s /application/nginx-1.8.1/ /application/nginx





fpm -s dir -t rpm -n nginx -v 1.8.1 -d 'pcre-devel,openssl-devel' --post-install /server/scripts/nginx_rpm.sh -f /application/nginx-1.8.1/


sz這個包到剛纔的目錄



rpm -qp --scripts  nginx-1.8.1-1.x86_64.rpm

# 查看rpm幫助

man rpm

# 查看rpm包信息

rpm -qpi nginx-1.8.1-1.x86_64.rpm

# 查看rpm包內容

rpm -qpl nginx-1.8.1-1.x86_64.rpm

# 查看rpm包的依賴

rpm -qpR nginx-1.8.1-1.x86_64.rpm

# 查看rpm包帶的執行腳本,執行腳本不是以文件形式存在rpm包中

rpm -qp --scripts nginx-1.8.1-1.x86_64.rpm

# 查看文件是屬於哪一個軟件包的

rpm -qf /etc/my.cnf

# 安裝rpm包

rpm -ivh nginx-1.8.1-1.x86_64.rpm



虛擬機 ##還原到定製前!

rz 兩個包

解壓一個







=====nginx=====

fpm -s dir -t rpm -n nginx -v 1.8.1 -d 'pcre-devel,openssl-devel' --post-install /server/scripts/nginx_rpm.sh -f /application/nginx-1.8.1/




=====mysql======

fpm -s dir -t rpm -n mysql -v 5.5.32 -d 'ncurses-devel' --post-install /server/scripts/mysql_rpm.sh -f /application/mysql/



=====php======

fpm -s dir -t rpm -n php -v 5.5.32 -d 'libxslt-devel,libmcrypt-devel,mhash,mhash-devel,mcrypt' --post-install /server/scripts/php_rpm.sh -f /application/php-5.5.32 /usr/local/libiconv-1/ 



############################################yum      倉       庫############################################################

mkdir -p /application/yum/centos6/x86_64

cd /application/yum/centos6/x86_64

cp /home/oldboy/tools/*.rpm .

安裝軟件

yum -y install createrepo

初始化

createrepo -pdo /application/yum/centos6/x86_64/ /application/yum/centos6/x86_64/

更新使用的(分清環境)

初始化之後若是每加入一個rpm包就要更新一下,看清楚update前面是2個橫線

createrepo --update /application/yum/centos6/x86_64/ 

精簡配置文件

egrep -v "^$|#" nginx.conf.default >nginx.conf

修改配置文件

[root@m01-61 conf]# cat >/application/nginx/conf/nginx.conf<<EOF

worker_processes  1;

events {

    worker_connections  1024;

}

http {

    include       mime.types;

    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;


    server {

        listen       80;

        server_name  yum.etiantian.org;

        location / {

            root   /application/yum/centos6/x86_64;

            autoindex on;

            index  index.html index.htm;

        }

    }

}

EOF



############################################客    戶    端    配    置#########################################

、客戶端配置

cd /etc/yum.repos.d

mkdir yum_bak && mv *repo yum_bak


[root@oldboyedu yum.repos.d]# vim oldboyedu.repo

[oldboyedu]

name=Server

baseurl=http://10.0.0.61

enabled=1

gpgcheck=0


yum clean all # 清空本機已有yum緩存

yum list  # 列表顯示yum倉庫

yum install nginx







#########################mysql  定製包###############

cd /home/oldboy/tools

rz mysql

 tar xf  mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

 sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.conf

 yum install ncurses-devel -y

 find /var/cache/ -type f -name "*.rpm"|xargs cp -t /tmp/

 cd /tmp/

 tar zcf mysql_yum.tar.gz ncurses-devel-5.7-4.20090207.el6.x86_64.rpm

 sz mysql_yum.tar.gz

 cd /home/oldboy/tools/

 useradd -M -s /sbin/nologin  mysql


mv mysql-5.6.35-linux-glibc2.5-x86_64 /application/mysql-5.6.35

[root@m01-61 tools]# ln -s /application/mysql-5.6.35/ /application/mysql



[root@m01-61 tools]# chown -R mysql.mysql /application/mysql/

cd /application/mysql


/application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data --user=mysql

7.複製mysql安裝目錄下的腳本去linux系統服務

cp /application/mysql/support-files/mysql.server  /etc/init.d/mysqld

8.給腳本x執行權限

chmod +x /etc/init.d/mysqld 

9.替換配置文件

sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld

10.覆蓋原來的配置文件。

\cp /application/mysql/support-files/my-default.cnf /etc/my.cnf

11.啓動mysql服務:

/etc/init.d/mysqld start

12.給mysql植入命令路徑

echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile

source /etc/profile

which mysql

13.加入開機自啓動

chkconfig --add mysqld 

chkconfig mysqld on

14.給mysql root設置用戶密碼

/application/mysql/bin/mysqladmin -u root password 'oldboy123'

密碼爲123

寫腳本vim mysql_rpm.sh

#!/bin/bash

useradd -M -s /sbin/nologin  mysql

ln -s /application/mysql-5.6.35/ /application/mysql

chown -R mysql.mysql /application/mysql/

cp /application/mysql/support-files/mysql.server  /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld

\cp /application/mysql/support-files/my-default.cnf /etc/my.cnf

/etc/init.d/mysqld start

echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile####需在客戶端在執行一次

source /etc/profile#######需在客戶端在執行一次

which mysql#####需在客戶端在執行一次

chkconfig --add mysqld

chkconfig mysqld on

/application/mysql/bin/mysqladmin -u root password 'oldboy123'

fpm -s dir -t rpm -n mysql -v 5.6.35 -d 'ncurses-devel' --post-install /server/scripts/mysql_rpm.sh -f /application/mysql/

sz mysql-5.6.35-1.x86_64.rpm



 

 

##############################php##############################


安裝依賴包:

sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.conf

yum install zlib-devel libxm12-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel -y

yum install freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel -y

安裝libmcrypt

配置epel第三方yum源

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

安裝php相關包libmcrypt對應的包

yum  install libmcrypt-devel

yum install libxslt-devel

安裝mhash加密拓展庫

安裝epel源

yum install mhash  -y 

yum install mcrypt -y 

yum install mhash-devel -y


find /var/cache/ -type f -name "*.rpm"|xargs cp -t /tmp/

 cd /tmp/

  tar zcf php的依賴包

  依賴包有:libmcrypt-2.5.8-9.el6.x86_64.rpm

libmcrypt-devel-2.5.8-9.el6.x86_64.rpm

libxslt-devel-1.1.26-2.el6_3.1.x86_64.rpm

mcrypt-2.6.8-10.el6.x86_64.rpm

mhash-0.9.9.9-3.el6.x86_64.rpm

mhash-devel-0.9.9.9-3.el6.x86_64.rpm

查看好依賴包再打包!!!!!

 sz php_yum.tar.gz

 cd /home/oldboy/tools/

 useradd -M -s /sbin/nologin  www

2.安裝yum沒法安裝的libconv庫

進入軟件包的存放地

cd /home/oldboy/tools

上傳libconv庫

rz -E libiconv-1.14.tar

解壓libiconv庫

tar zxf libiconv-1.14.tar.gz

進入安裝目錄

cd libiconv-1.14

啓動編譯腳本

./configure --prefix=/usr/local/libiconv

執行編譯

make

開始編譯安裝

make install





cd /home/oldboy/tools

rz php

tar xf php


進入php.5.5.32目錄

./configure \

--prefix=/application/php-5.5.32 \

--with-mysql=mysqlnd \

--with-iconv-dir=/usr/local/libiconv \

--with-freetype-dir \

--with-jpeg-dir \

--with-png-dir \

--with-zlib \

--with-libxml-dir=/usr \

--enable-xml \

--disable-rpath \

--enable-bcmath \

--enable-shmop \

--enable-sysvsem \

--enable-inline-optimization \

--with-curl \

--enable-mbregex \

--enable-fpm \

--enable-mbstring \

--with-mcrypt \

--with-gd \

--enable-gd-native-ttf \

--with-openssl \

--with-mhash \

--enable-pcntl \

--enable-sockets \

--with-xmlrpc \

--enable-zip \

--enable-soap \

--enable-short-tags \

--enable-static \

--with-xsl \

--with-fpm-user=www \

--with-fpm-group=www \

--enable-opcache=no  \

--enable-ftp

編譯php

ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/

touch ext/phar/phar.phar

make

安裝php生成文件到系統

make install

設置軟鏈

ln -s /application/php-5.5.32/ /application/php


查看php配置默認模板文件  

ls php.ini*

拷貝php配置文件到php默認目錄,並更改文件名稱爲php.ini 

  cd php-5.5.32

  cp php.ini-production /application/php/lib/php.ini

 配置php服務

  cd /application/php/etc/

 cp php-fpm.conf.default php-fpm.conf 

 啓動php服務


[root@m01-61 etc]# chown www.www /application/php

[root@m01-61 etc]# /application/php/sbin/php-fpm 


vim php_rpm.sh

#!/bin/bash

cd /home/oldboy/tools/php-5.5.32 &&\

ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/

touch ext/phar/phar.phar

ln -s /application/php-5.5.32/ /application/php

cp php.ini-production /application/php/lib/php.ini

cp php-fpm.conf.default php-fpm.conf

useradd -M -s /sbin/nologin www

chown www.www /application/php

/application/php/sbin/php-fpm




fpm -s dir -t rpm -n php -v 5.5.32 -d 'libxslt-devel,libmcrypt-devel,mhash,mhash-devel,mcrypt' --post-install /server/scripts/php_rpm.sh -f /application/php-5.5.32 /usr/local/libiconv/ 

cd /application/yum/centos6/x86_64/

   rz php 1包

   rz php 2包

   rz 兩個包

解壓一個



   createrepo --update /application/yum/centos6/x86_64/ 


   客戶端配置:

   cd /etc/yum.repos.d

mkdir yum_bak && mv *repo yum_bak

vim oldboyedu.repo

[oldboyedu]

name=Server

baseurl=http://10.0.0.61

enable=1

gpgcheck=0


yum clean all #清空緩存

yum list 

相關文章
相關標籤/搜索