install_httpd: pkg.installed: - name: httpd httpd_running: service.running: - name: httpd - enable: True - require: - pkg: install_httpd
- reload: True #配置改变就重启 - watch: - file: httpd_conf httpd_conf: file.managed: - name: /etc/httpd/conf/httpd.conf - source: salt://httpd.conf - user: root - group: root - mode: 600 install_php: pkg.installed: - name: php_all - pkgs: - php - php-mysql - php-common - php-devel - php-mbstring - php-mcrypt - php-xml - require: - pkg: install_httpd install_mysql: pkg.installed: - name: mariadb - pkgs: - mariadb - mariadb-server - mariadb-devel mysql-running: service.running: - name: mariadb - enable: True - require: - pkg: install_mysql mysqld_conf: file.managed: - name: /etc/my.cnf - source: salt://my.cnf - user: root - group: root - mode: 664 discuz_handle: file.managed: - name: /var/www/html/Discuz_X3.3_SC_UTF8.zip - source: salt://Discuz_X3.3_SC_UTF8.zip - user: root - group: root - mode: 644 create_backup_directory: file.directory: - name: /var/www/html/discuz - user: root - group: root - mode: 755 unzip_discuz: cmd.run: - name: cd /var/www/html && mv Discuz_X3.3_SC_UTF8.zip ./discuz && cd /var/www/html/discuz && unzip Discuz_X3.3_SC_UTF8.zip && rm -f Discuz_X3.3_SC_UTF8.zip && chmod -R 777 * && mv /var/www/html/discuz/upload/* /var/www/html/discuz httpd-restart: cmd.run: - name: systemctl restart httpd.service mysql_authorization: cmd.run: - name: mysql -uroot -p123456 -e "create database discuz;grant all privileges on discuz.* to discuz@'%' identified by '123456';"
这个sls最后有点bug,最后访问discuz的网址显示php的代码,不显示页面,但访问php的测试页面又能访问。蛋疼。