前期環境準備:linux
關閉SELINUX : setenforce 0 nginx
關閉SELINUX : sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/configshell
中止防火牆 : /etc/init.d/iptables stop json
中止防火牆開機啓動: chkconfig --level 3 offruby
更改成保存安裝包 keepcache=1服務器
調試命令:curl 10.0.0.3app
啓動命令:/application/nginx/sbin/nginx curl
可選安裝: yum -y iinstall lrzsz
ide
mkdir -p /application/tools #建立目錄工具
cd /application/tools #進入目錄
1. [root@localhost ~]# yum -y install ruby rubygems ruby-devel ## 這裏面貌似要安裝1.8.7的ruby 2. [root@localhost ~]# yum install lrzsz //----若是系統沒有安裝這個軟件就須要安裝一下 3 gem install fpm -v 1.3.3 ## 安裝 fpm工具 4. gem install json -v 1.8.3 ## 安裝json 5. gem install ffi -v 1.9.18 安裝 ffi 6. find /var/cache/ -type f -name '*rpm' |xargs cp -t /tmp/ ## 臨時包拷貝到 tmp 7. cd /tmp/ && tar zcf nginx_yum.tar.gz *.rpm ### 打包位rpm包 8. sz nginx_yum.tar.gz ## 下載到本地 |
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo ## 下載源 gem source -a http://mirrors.aliyun.com/rubygems/ ## 添加新yum源 (https中 http應該改爲https) gem source --remove http://rubygems.org/ ## 移除老yum源 gem source --list //查看源地址 gem命令沒法使用請安裝下面的ruby |
3.建立用戶
useradd nginx -M -s /sbin/nologin cd /application/tools/ tar xf nginx-1.6.3.tar.gz |
4. 編譯安裝nginx
1. ./configure --prefix=/application/nginx-1.6.3 --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module 2. make && make install |
5. 建立軟鏈接
ln -s /application/nginx-1.6.3/ /application/nginx mkdir -p /server/scripts/ |
6.編寫腳本,建立相關用戶
cd /server/scripts/ ##腳本寫學 該目錄 vi nginx_rpm.sh 內容: useradd nginx -M -s /sbin/nologin ln -s /application/nginx-1.6.3/ /application/nginx |
7. fpm 安裝打包
fpm -s dir -t rpm -n nginx -v 1.6.3 -d 'pcre-devel,openssl-devel' --post-install /server/scripts/nginx_rpm.sh -f /application/nginx-1.6.3/ |
8. 下載到其餘服務器安裝後效果:
完成!!:
出現如下瑕疵待解決:
里程碑1: 可以一鍵執行後 建立用戶和 軟鏈接
yum -y localinstall nginx-1.6.2-1.x86_64.rpm ## 必須 使用 yum -y localinstall nginx-1.6.2-1.x86_64.rpm
里程碑2: 配置 chkconfig 和 安裝完成後當即啓動
待完成!
###里程碑1的思路
初步是想在建立用戶的那個腳本里直接添加 建立用戶領命和 軟鏈接操做
以及完成yum安裝這兩個rpm包的操做
###l里程碑2的 chkconfig 思路
在/etc/init.d/rc3.d/ 建立一個名爲 nginx 的文件 文件中寫入:
# chkconfig: 2345 100 200 # description: SSH is a protocol for secure remote shell access. . /application/nginx |
而後使用chkconfig --add nginx 添加入系統服務中
那麼他開機就會啓動了
里程碑1和2 會在近期進行測試.完成後會在這個帖子中進行更新.
2018年4月16日 2:06:46