在管理机m01-61
cd /home/oldboy/tools
rz nginx rz fpm 并且 rpm -ivh fpm-1.6.3-1.x86_64.rpm
tar -xf nginx
修改配置(开启yum 缓存)
sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.conf
清空缓存
find /var/cache/ -type f -name '*rpm'|xargs rm -f
######做快照!#######
安装依赖包
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< 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