1. 目录结构
[root@master ~]
[root@master prod]
lnmp modules
[root@master prod]
.
├── lnmp
│ ├── files
│ │ ├── index.php
│ │ ├── my.cnf
│ │ ├── mysql.conf
│ │ └── nginx.conf
│ ├── install.sls
│ ├── main.sls
│ └── mysql.sls
└── modules
├── application
│ └── php7
│ ├── files
│ │ ├── install.sh
│ │ ├── oniguruma-devel-6.8.2-2.el8.x86_64.rpm
│ │ ├── php-7.4.24.tar.gz
│ │ ├── php-fpm
│ │ ├── php-fpm.conf
│ │ ├── php-fpm.service
│ │ └── www.conf
│ └── install.sls
├── database
│ └── mysql
│ ├── files
│ │ ├── install.sh
│ │ ├── mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
│ │ ├── mysqld.service
│ │ └── mysql.server
│ └── install.sls
└── web
├── apache
│ ├── files
│ │ ├── apr-1.7.0.tar.gz
│ │ ├── apr-util-1.6.1.tar.gz
│ │ ├── httpd-2.4.49.tar.gz
│ │ ├── httpd.conf
│ │ ├── httpd.service
│ │ └── install.sh
│ └── install.sls
└── nginx
├── files
│ ├── install.sh
│ ├── nginx-1.20.1.tar.gz
│ └── nginx.service
└── install.sls
14 directories, 31 files
[root@master prod]
2. 安装nginx
[root@master lnmp]
[root@master prod]
lnmp modules
[root@master prod]
[root@master nginx]
files install.sls
[root@master nginx]
'Development Tools':
pkg.group_installed
nginx-dep-packages:
pkg.installed:
- pkgs:
- pcre-devel
- pcre
- gcc
- gcc-c++
- openssl-devel
- zlib
- zlib-devel
- openssl
- openssl-devel
- gd-devel
create-nginx-user:
user.present:
- name: nginx
- system: true
- createhome: false
- shell: /sbin/nologin
create-nginxdir:
file.directory:
- name: /var/log/nginx
- user: mysql
- group: mysql
- mode: '0755'
- makedirs: true
tarxf-nginx:
archive.extracted:
- names:
- /usr/src:
- source: salt://modules/web/nginx/files/nginx-1.20.1.tar.gz
nginx-install:
cmd.script:
- name: salt://modules/web/nginx/files/install.sh
- unless: test -d /usr/local/nginx
nginx-service:
file.managed:
- names:
- /usr/lib/systemd/system/nginx.service:
- source: salt://modules/web/nginx/files/nginx.service
- require:
- cmd: nginx-install
[root@master nginx]
[root@master files]
install.sh nginx-1.20.1.tar.gz nginx.service
[root@master files]
cd /usr/src/nginx-1.20.1
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-debug --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub