conf_server/install_nginx_service.sh

59 lines
1.7 KiB
Bash
Raw Normal View History

2023-01-11 01:03:34 +01:00
#!/bin/sh
. ./myserver.conf
. ./utils.sh
install_nginx_package()
{
pkg_add nginx-1.22.0p0 nginx-headers-more-1.22.0 nginx-stream-1.22.0
}
gen_nginx_configuration()
{
2023-05-15 23:16:25 +02:00
cp -v default_configuration/nginx/nginx.conf.example my_configuration/nginx/nginx.conf
openssl dhparam -out my_configuration/nginx/dhparam.pem 2048
2023-01-11 01:03:34 +01:00
}
make_default_homepage()
{
2023-05-15 23:16:25 +02:00
cp -v default_configuration/nginx/site-avalaible/example \
my_configuration/nginx/site-available/$DOMAIN
sed -i "s/__DOMAIN__/$DOMAIN/g" my_configuration/nginx/site-available/$DOMAIN
2023-01-11 01:03:34 +01:00
}
install_nginx_configuration(){
2023-05-15 23:16:25 +02:00
mkdir -v /etc/nginx/sites-enabled/
mkdir -v /etc/nginx/sites-available/
mkdir -v /etc/nginx/snippets/
cp -v my_configuration/nginx/nginx.conf /etc/nginx/nginx.conf
cp -v my_configuration/nginx/dhparam.pem /etc/nginx/dhparam.pem
cp -v my_configuration/nginx/snippets/* /etc/nginx/snippets/
2023-01-11 01:03:34 +01:00
}
install_chroot_env()
{
mkdir /var/www/etc/ssl/
install -m 444 -o root -g bin /etc/resolv.conf /var/www/etc/
install -m 444 -o root -g bin /etc/ssl/cert.pem /etc/ssl/openssl.cnf /var/www/etc/ssl/
}
add_logs_to_newssyslog(){
cp -v /etc/newsyslog.conf /etc/newsyslog.conf.old
2023-05-15 23:16:25 +02:00
egrep -v "nginx|httpd" /etc/newsyslog.conf > /tmp/newsyslog.conf
2023-01-11 01:03:34 +01:00
cat >> /tmp/newsyslog.conf <<EOF
/var/www/logs/access.log 644 2 * \$W0 Z /var/www/run/nginx.pid SIGUSR1
/var/www/logs/error.log 644 2 250 * Z /var/www/run/nginx.pid SIGUSR1
EOF
mv /tmp/newsyslog.conf /etc/newsyslog.conf
}
mkdir my_configuration/nginx/
2023-05-15 23:16:25 +02:00
#install_nginx_package
2023-01-11 01:03:34 +01:00
gen_nginx_configuration
2023-05-15 23:16:25 +02:00
#install_chroot_env
#install_nginx_configuration
#restart_webserver_service