saltstack源码编译安装lnmp
2017-10-16 19:32
441 查看
环境
master:server1(172.25.50.1/24)minion:server2(172.25.50.2/24)
selinux=disabled
iptables=off
master :/etc/salt/master
file_roots: base: - /srv/salt/
minion:/etc/salt/minion
master: server1
总体架构
/srv/salt/|-- mysql | |-- files | | |-- cmake-2.8.12.2-4.el6.x86_64.rpm | | |-- my.cnf | | |-- mysql-boost-5.7.17.tar.gz | | `-- mysql.init | |-- install.sls | `-- service.sls |-- nginx | |-- files | | |-- nginx-1.12.0.tar.gz | | |-- nginx.conf | | `-- nginx.init | |-- instal 4000 l.sls | `-- service.sls |-- php | |-- files | | |-- libmcrypt-2.5.8-9.el6.x86_64.rpm | | |-- libmcrypt-devel-2.5.8-9.el6.x86_64.rpm | | |-- php-5.6.20.tar.bz2 | | |-- php-fpm.conf | | |-- php-fpm.init | | `-- php.ini | |-- install.sls | `-- service.sls |-- pkgs | |-- make.sls | |-- mysqlmake.sls | `-- phpmake.sls |-- top.sls `-- users |-- mysql.sls `-- nginx.sls
pkgs依赖性包的配置
/srv/salt/pkgsnginx的依赖包
/srv/salt/pkgs/make.sls
make: pkg.installed: - pkgs: - gcc - openssl-devel - pcre-devel
mysql的依赖性包
/srv/salt/pkgs/mysqlmake.sls
mysqlmake: pkg.installed: - pkgs: - gcc - openssl-devel - pcre-devel
- gcc-c++
- ncurses-devel
php的依赖性包
/srv/salt/pkgs/phpmake.sls
phpmake: pkg.installed: - pkgs: - gcc - openssl-devel - pcre-devel
- libxml2-devel
- curl-devel
- libjpeg-turbo-devel
- freetype-devel
- gmp-devel
- net-snmp-devel
- bison
- libpng-devel
users用户的配置
mysql用户配置:/srv/users/mysql.sls
mysql: user.present: - uid: 27 - shell: /sbin/nologin - createhome: False - home: /usr/local/lnmp/mysql cmd.run: - name : sed -i 's/mysql:x:27:27::\/usr\/local\/lnmp\/mysql\/:\/sbin\/nologin/mysql:x:27:27::\/usr\/local\/lnmp\/mysql\/data:\/sbin\/nologin/g' /etc/passwd
nginx用户配置:
/srv/users/nginx.sls
nginx: user.present: - uid: 800 - shell: /sbin/nologin - createhome: False - home: /usr/local/nginx
nginx
##nginx的安装/srv/salt/nginx/install.sls
include: - pkgs.make - users.nginx /mnt/nginx-1.12.0.tar.gz: file.managed: - source: salt://nginx/files/nginx-1.12.0.tar.gz nginx-install: cmd.run: - name: cd /mnt && tar zxf nginx-1.12.0.tar.gz && cd nginx-1.12.0 && sed -i.bak 's/CFLAGS="$CFLAGS -g"/#CFLAGS="$CFLAGS -g/g' auto/cc/gcc && ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module && make && make install - creates: /usr/local/nginx - require: - pkg: make - user: nginx - file: /mnt/nginx-1.12.0.tar.gz
##nginx的服务配置
/srv/salt/nginx/service.sls
include: - nginx.install /etc/init.d/nginx: file.managed: - source: salt://nginx/files/nginx.init - mode: 755 /usr/local/nginx/conf/nginx.conf: file.managed: - source: salt://nginx/files/nginx.conf - mode: 644 - user: root nginx-service: service.running: - name: nginx - enable: True - reload: True - watch: - file: /usr/local/nginx/conf/nginx.conf - requires: - file: /etc/init.d/nginx - cmd: nginx-install
PHP
php配置安装结构##php的安装
/srv/salt/php/install.sls
include: - pkgs.phpmake /mnt/php-5.6.20.tar.bz2: file.managed: - source: salt://php/files/php-5.6.20.tar.bz2 /mnt/libmcrypt-2.5.8-9.el6.x86_64.rpm: file.managed: - source: salt://php/files/libmcrypt-2.5.8-9.el6.x86_64.rpm /mnt/libmcrypt-devel-2.5.8-9.el6.x86_64.rpm: file.managed: - source: salt://php/files/libmcrypt-devel-2.5.8-9.el6.x86_64.rpm lib-install: cmd.run: - name: cd /mnt && yum install libmcrypt-* php-install: cmd.run: - name: cd /mnt && tar jxf php-5.6.20.tar.bz2 && cd php-5.6.20 && ./configure --prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-snmp --with-zlib --with-gd --with-libxml-dir --with-curl --with-png-dir --with-jpeg-dir --with-freetype-dir --with-gmp --with-gettext --enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash && make && make install && echo "PATH=$PATH:/usr/local/lnmp/php" >> /root/.bash_profile && source /root/.bash_profile - creates: /usr/local/lnmp/php - require: - pkg: phpmake - file: /mnt/php-5.6.20.tar.bz2
##php服务设置
/srv/salt/php/service.sls
include: - php.install /etc/init.d/php-fpm: file.managed: - source: salt://php/files/php-fpm.init - mode: 755 - user: root /usr/local/lnmp/php/etc/php.ini: file.managed: - source: salt://php/files/php.ini - mode: 644 - user: root /usr/local/lnmp/php/etc/php-fpm.conf: file.managed: - source: salt://php/files/php-fpm.conf - mode: 644 - user: root php-service: cmd.run: - names: - /sbin/chkconfig --add php-fpm # - /sbin/chkconfig --level 36 php-fpm on - /etc/init.d/php-fpm restart
mysql
##mysql的安装/srv/salt/mysql/install.sls
include: - pkgs.mysqlmake - users.mysql /mnt/mysql-boost-5.7.17.tar.gz: file.managed: - source: salt://mysql/files/mysql-boost-5.7.17.tar.gz /mnt/cmake-2.8.12.2-4.el6.x86_64.rpm: file.managed: - source: salt://mysql/files/cmake-2.8.12.2-4.el6.x86_64.rpm cmake-install: cmd.run: - name: cd /mnt && yum install cmake-2.8.12.2-4.el6.x86_64.rpm -y nginx-install: cmd.run: - name: cd /mnt && tar zxf mysql-boost-5.7.17.tar.gz && cd mysql-5.7.17 && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BOOST=boost/boost_1_59_0 && make && make install && echo "PATH=$PATH:/usr/local/lnmp/mysql/bin" >> /root/.bash_profile && source /root/.bash_profile - creates: /usr/local/lnmp/mysql - require: - pkg: mysqlmake - user: mysql - file: /mnt/mysql-boost-5.7.17.tar.gz
/srv/salt/mysql/service.sls
include: - mysql.install /etc/init.d/mysqld: file.managed: - source: salt://mysql/files/mysql.init - mode: 755 /etc/my.cnf: file.managed: - source: salt://mysql/files/my.cnf - mode: 644 - user: root mysql-boot: cmd.run: - names: - mysqld --initialize --user=mysql > /mnt/pass - cat /mnt/pass | grep root@localhost | awk '{print $11}' > /mnt/password - chown mysql.root /usr/local/lnmp/mysql/data -R mysql-service: service.running: - name: mysql - enable: True - reload: True - watch: - file: /etc/my.cnf - requires: - file: /etc/init.d/mysqld - cmd: mysql-install
相关文章推荐
- 源码编译安装,搭建LNMP环境(Linux+Nginx+MySQL+PHP)
- lnmp 源码编译安装!
- LNMP源码编译安装
- CentOS 7源码编译安装PHP5.6和Nginx1.7.9及MySQL(搭建LNMP环境)
- 源码编译安装LNMP架构环境
- 脚本一键源码编译安装LNMP
- saltstack试用篇:一、源码安装与简单配置
- Lnmp 源码编译安装
- LNMP源码编译安装
- LNMP源码编译安装(centos7+nginx1.9+mysql5.6+php7)
- lnmp源码编译安装zabbix
- LNMP源码编译安装
- 源码编译安装lnmp架构
- lnmp环境安装(4)-php源码编译安装
- lnmp环境源码编译安装记录
- 源码安装LNMP+zabbix3时的编译
- 源码编译安装LNMP
- saltstack源码安装nginx
- 源码编译安装LNMP环境及配置基于域名访问的多虚拟主机
- Saltstack自动化源码编译安装PHP以及LNMP安装整合