#cloud-config
yum_repos:
epel:
name: Extra Packages for Enterprise Linux
baseurl: https://yum$ociregion.$ocidomain/repo/OracleLinux/OL9/developer/EPEL/$basearch/
enabled: true
gpgcheck: true
timezone: America/Sao_Paulo
package_update: true
package_upgrade: true
write_files:
- path: /tmp/robots.txt
owner: 'root:root'
permissions: '0644'
defer: true
content: |
User-agent: *
Disallow: /
- path: /tmp/sei.conf
owner: 'root:root'
permissions: '0644'
defer: true
content: |
Alias "/infra_css" "/opt/infra/infra_css"
Alias "/infra_js" "/opt/infra/infra_js"
AllowOverride None
Require all denied
AllowOverride None
Options None
Require all granted
runcmd:
- localectl set-locale LANG=pt_BR.ISO-8859-1
- systemctl disable firewalld.service --now
- setenforce 0
- sed -i '$a\set number' /etc/vimrc
- mkdir -p /run/php-fpm
- mkdir -p /sei-nfs/dados
- mkdir -p /opt/infra/infra_php
- mkdir -p /opt/sei/web
- mkdir -p /sei-nfs/dados
- sed -i '22c\SELINUX=disabled' /etc/selinux/config
- dnf install httpd mod_ssl @php:8.2 php-bcmath.x86_64 php-gd.x86_64 php-soap.x86_64 php-pecl-zip.x86_64 php-pear gcc curl-devel php-devel zlib-devel pcre-devel php-intl.x86_64 jdk1.8 php-opcache.x86_64 glibc-langpack-pt langpacks-pt php-mysqlnd.x86_64 libsodium-devel.x86_64 libsodium.x86_64 nc -y
- pecl channel-update pecl.php.net
- pecl install igbinary memcache uploadprogress
- pecl install -f libsodium
- echo "extension=memcache" | tee -a /etc/php.d/20-memcache.ini
- echo "extension=igbinary" | tee -a /etc/php.d/20-igbinary.ini
- echo "extension=sodium" | tee -a /etc/php.d/20-sodium.ini
- echo "extension=uploadprogress" | tee -a /etc/php.d/20-uploadprogress.ini
- sed -i '124c\DocumentRoot "/opt/sei/web"' /etc/httpd/conf/httpd.conf
- sed -i '136c\' /etc/httpd/conf/httpd.conf
- sed -i '47c\Listen 0.0.0.0:80' /etc/httpd/conf/httpd.conf
- dnf install -y https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox-0.12.6.1-3.almalinux9.x86_64.rpm
- ln -sf /usr/local/bin/wkhtmltopdf /usr/bin/
- sed -i '1342c\session.gc_maxlifetime = 28800' /etc/php.ini
- sed -i '198c\short_open_tag = On' /etc/php.ini
- sed -i '426c\max_input_vars = 1000' /etc/php.ini
- sed -i '561c\html_errors = off' /etc/php.ini
- sed -i '703c\post_max_size = 201M' /etc/php.ini
- sed -i '855c\upload_max_filesize = 200M' /etc/php.ini
- sed -i '1276c\session.cookie_secure = 1' /etc/php.ini
- sed -i '722c\default_charset = "ISO-8859-1"' /etc/php.ini
- sed -i '115c\pm.max_children = 92' /etc/php-fpm.d/www.conf
- sed -i '120c\pm.start_servers = 8' /etc/php-fpm.d/www.conf
- sed -i '125c\pm.min_spare_servers = 4' /etc/php-fpm.d/www.conf
- sed -i '130c\pm.max_spare_servers = 35' /etc/php-fpm.d/www.conf
- sed -i '141c\pm.max_requests = 500' /etc/php-fpm.d/www.conf
- sed -i '745c\include_path = "/opt/infra/infra_php"' /etc/php.ini
- sed -i "11c\opcache.opcache.memory_consumption=256" /etc/php.d/10-opcache.ini
- sed -i "14c\opcache.opcache.interned_strings_buffer=16" /etc/php.d/10-opcache.ini
- sed -i "18c\opcache.opcache.max_accelerated_files=50000" /etc/php.d/10-opcache.ini
- sed -i "31c\opcache.validate_timestamps=0" /etc/php.d/10-opcache.ini
- sed -i "36c\opcache.revalidate_freq=0" /etc/php.d/10-opcache.ini
- echo "opcache.jit = 1254" | tee -a /etc/php.d/10-opcache.ini
- echo "opcache.jit_buffer_size = 256M" | tee -a /etc/php.d/10-opcache.ini
- echo -e "#Desabilitar output buffer e alterar timeout\n\n ProxySet enablereuse=off flushpackets=auto timeout=610 keepalive=on\n\n#forcar envio de Content-Length quando nao informado\nSetEnv proxy-sendcl 1" >> /etc/httpd/conf/httpd.conf
- cp /tmp/robots.txt /opt/sei/robots.txt
- cp /tmp/sei.conf /etc/httpd/conf.d/sei.conf
- chown -R root:apache /opt/infra
- chown -R root:apache /opt/sei
- chown -R root:apache /var/www
- openssl req -x509 -nodes -newkey rsa:4096 -keyout /etc/pki/tls/private/localhost.key -out /etc/pki/tls/certs/localhost.crt -days 3650 -subj '/CN=localhost'
- rm -f /etc/httpd/conf.d/{userdir.conf,welcome.conf}
- echo "00 01 * * * rm -rf /opt/sei/temp/*" | crontab
- echo "* * * * * /usr/bin/php -c /etc/php.ini /opt/sei/scripts/AgendamentoTarefaSEI.php 2>&1 >> /root/infra_agendamento_sei.log" | crontab
- systemctl reload crond.service
- systemctl enable php-fpm.service --now
- systemctl enable httpd.service --now
- systemctl restart php-fpm.service
- systemctl restart httpd.service
final_message: "SEI Instance ready after $UPTIME seconds"