Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sudo apt update
- sudo apt install -y mariadb-server mariadb-client curl
- sudo systemctl status mariadb
- sudo apt update && sudo apt -y full-upgrade
- [ -f /var/run/reboot-required ] && sudo reboot -f
- sudo apt -y install lsb-release apt-transport-https ca-certificates
- sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
- echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
- sudo apt update
- sudo apt install php7.4
- sudo apt-get install php7.4-{bcmath,bz2,intl,gd,mbstring,mysql,zip}
- sudo apt-get install nginx php7.4-fpm
- systemctl status php7.4-fpm nginx
- '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- /etc/php/7.4/fpm/pool.d/www.conf Запустить от имени nginx www-data
- sudo sed -i 's/listen.owner \= www-data/listen.owner \= www-data/g' /etc/php/7.4/fpm/pool.d/www.conf
- sudo sed -i 's/listen.group \= www-data/listen.group \= www-data/g' /etc/php/7.4/fpm/pool.d/www.conf
- mkdir -p /var/www/html/load.sytes.net/public
- mkdir -p /var/log/nginx/load.sytes.net
- chmod -R 755 /var/log/nginx/load.sytes.net
- chown -R www-data:www-data /var/log/nginx/load.sytes.net
- chmod -R 755 /var/www/html/load.sytes.net
- chown -R www-data:www-data /var/www/html/load.sytes.net
- chmod -R 755 /var/www/html/load.sytes.net
- chown -R www-data:www-data /var/www/html/load.sytes.net/public/wp-content/uploads/2023/03/
- mcedit /etc/nginx/sites-available/load.sytes.net.conf
- server {
- server_name load.sytes.net www.load.sytes.net;
- root /var/www/html/load.sytes.net/public;
- location / {
- index index.html index.htm index.php;
- }
- location ~ \.php$ {
- include /etc/nginx/fastcgi_params;
- fastcgi_pass unix:/run/php/php7.4-fpm.sock;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- }
- }
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/load.sytes.net/public/index.php
- sudo systemctl restart nginx php7.4-fpm
- **********************************************************************************
- sudo sed -i 's/^max_execution_time \= .*/max_execution_time \= 300/g' /etc/php/7.4/fpm/php.ini
- sudo sed -i 's/^upload_max_filesize \= .*/upload_max_filesize \= 64M/g' /etc/php/7.4/fpm/php.ini
- sudo sed -i 's/^post_max_size \= .*/post_max_size \= 64M/g' /etc/php/7.4/fpm/php.ini
- mcedit /etc/nginx/sites-available/load.sytes.net.conf
- server {
- server_name load.sytes.net www.load.sytes.net;
- root /var/www/html/load.sytes.net/public;
- index index.php index.html;
- access_log /var/log/nginx/load.sytes.net.access.log;
- error_log /var/log/nginx/load.sytes.net.error.log;
- # Prevent access to hidden files
- location ~* /\.(?!well-known\/) {
- deny all;
- }
- # Prevent access to certain file extensions
- location ~\.(ini|log|conf)$ {
- deny all;
- }
- # Enable WordPress Permananent Links
- location / {
- try_files $uri $uri/ /index.php?$args;
- }
- location ~ \.php$ {
- include fastcgi_params;
- fastcgi_intercept_errors on;
- fastcgi_pass unix:/run/php/php7.4-fpm.sock;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- }
- }
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- sudo nginx -t
- sudo systemctl reload nginx php7.4-fpm
- sudo apt update
- sudo apt-get install python3-certbot-nginx
- sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048
- sudo certbot certonly --agree-tos --email [email protected] --webroot -w /var/lib/letsencrypt/ -d load.sytes.net
- sudo certbot --nginx
- sudo mysql -u root -p
- CREATE DATABASE wpdatabase;
- CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'wppassword';
- GRANT ALL PRIVILEGES ON wpdatabase.* TO 'wpuser'@'localhost';
- EXIT
- cd /usr/src
- curl -O https://wordpress.org/latest.tar.gz
- tar -xvzf latest.tar.gz
- sudo mv wordpress/* /var/www/html/load.sytes.net/public
- sudo chown -R www-data:www-data /var/www/html/load.sytes.net/public
- sudo htpasswd /var/www/html/load.sytes.net/public/wp-admin/.htpasswd um
- 022530
- 022530
- Получится так
- mcedit /etc/nginx/sites-available/load.sytes.net.conf
- server {
- server_name load.sytes.net www.load.sytes.net;
- root /var/www/html/load.sytes.net/public;
- index index.php index.html;
- access_log /var/log/nginx/load.sytes.net.access.log;
- error_log /var/log/nginx/load.sytes.net.error.log;
- # Prevent access to hidden files
- location ~* /\.(?!well-known\/) {
- deny all;
- }
- location /wp-admin {
- try_files $uri $uri/ =404;
- auth_basic "Administrator’s Area";
- auth_basic_user_file /etc/nginx/.htpasswd;
- }
- # Prevent access to certain file extensions
- location ~\.(ini|log|conf)$ {
- deny all;
- }
- # Enable WordPress Permananent Links
- location / {
- try_files $uri $uri/ /index.php?$args;
- }
- location /wp-admin {
- try_files $uri $uri/ =404;
- auth_basic "Administrator’s Area";
- auth_basic_user_file /etc/nginx/.htpasswd;.
- }
- location ~ \.php$ {
- include fastcgi_params;
- fastcgi_intercept_errors on;
- fastcgi_pass unix:/run/php/php7.4-fpm.sock;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- }
- listen 443 ssl; # managed by Certbot
- ssl_certificate /etc/letsencrypt/live/load.sytes.net/fullchain.pem; # managed by Certbot
- ssl_certificate_key /etc/letsencrypt/live/load.sytes.net/privkey.pem; # managed by Certbot
- include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
- ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
- }
- server {
- if ($host = load.sytes.net) {
- return 301 https://$host$request_uri;
- } # managed by Certbot
- server_name load.sytes.net www.load.sytes.net;
- listen 80;
- return 404; # managed by Certbot
- }
- ##################################################################
- sudo systemctl reload nginx php7.4-fpm
- sudo systemctl restart nginx php7.4-fpm
- ##################################################################
- #### mkdir /etc/nginx/nginx.conf
- user www-data;
- worker_processes auto;
- worker_cpu_affinity auto;
- worker_rlimit_nofile 30000;
- pid /var/run/nginx.pid;
- pcre_jit on;
- events {
- worker_connections 8192;
- multi_accept on;
- }
- http {
- # Basic #######################
- sendfile on;
- tcp_nopush on;
- tcp_nodelay on;
- reset_timedout_connection on;
- keepalive_timeout 120;
- keepalive_requests 1000;
- types_hash_max_size 2048;
- server_tokens off;
- send_timeout 30;
- client_body_timeout 30;
- client_header_timeout 30;
- server_names_hash_max_size 4096;
- # Limits ######################
- client_max_body_size 10m;
- client_body_buffer_size 128k;
- client_body_temp_path /var/cache/nginx/client_temp;
- proxy_connect_timeout 60;
- proxy_send_timeout 60;
- proxy_read_timeout 60;
- proxy_buffer_size 4k;
- proxy_buffers 8 16k;
- proxy_busy_buffers_size 64k;
- proxy_temp_file_write_size 64k;
- proxy_temp_path /var/cache/nginx/proxy_temp;
- include /etc/nginx/mime.types;
- default_type application/octet-stream;
- # Logs ########################
- log_format main '$remote_addr - $host [$time_local] "$request" '
- '$status $body_bytes_sent "$http_referer" '
- '"$http_user_agent" "$http_x_forwarded_for"'
- 'rt=$request_time ut=$upstream_response_time '
- 'cs=$upstream_cache_status';
- log_format full '$remote_addr - $host [$time_local] "$request" '
- 'request_length=$request_length '
- 'status=$status bytes_sent=$bytes_sent '
- 'body_bytes_sent=$body_bytes_sent '
- 'referer=$http_referer '
- 'user_agent="$http_user_agent" '
- 'upstream_status=$upstream_status '
- 'request_time=$request_time '
- 'upstream_response_time=$upstream_response_time '
- 'upstream_connect_time=$upstream_connect_time '
- 'upstream_header_time=$upstream_header_time';
- access_log /var/log/nginx/access.log main;
- error_log /var/log/nginx/error.log;
- # Gzip ########################
- gzip on;
- gzip_static on;
- gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/x-icon image/svg+xml application/x-font-ttf;
- gzip_comp_level 9;
- gzip_proxied any;
- gzip_min_length 1000;
- gzip_disable "msie6";
- gzip_vary on;
- etag off;
- # Cache #######################
- #proxy_cache_valid 1m;
- #proxy_cache_key $scheme$proxy_host$request_uri$cookie_US;
- #proxy_cache_path /web/sites/nginx_cache levels=1:2 keys_zone=main:1000m;
- # Zone limits ################
- limit_conn_zone $binary_remote_addr zone=perip:10m;
- limit_req_zone $binary_remote_addr zone=lim_5r:10m rate=5r/s; # lim for dynamic page
- limit_req_zone $binary_remote_addr zone=lim_1r:10m rate=1r/s; # lim for search page
- limit_req_zone $binary_remote_addr zone=lim_10r:10m rate=10r/s;
- # SSL #########################
- ssl_session_cache shared:SSL:50m;
- ssl_session_timeout 1d;
- ssl_session_tickets on;
- ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
- ssl_ciphers 'TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-256-GCM-SHA384:ECDHE:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
- ssl_prefer_server_ciphers on;
- ssl_dhparam /etc/ssl/certs/dhparam.pem;
- ssl_stapling on;
- ssl_stapling_verify on;
- add_header Strict-Transport-Security max-age=15768000;
- resolver 8.8.8.8;
- include /etc/nginx/conf.d/*.conf;
- include /etc/nginx/sites-enabled/*;
- # For monitoring ###########
- server {
- listen 127.0.0.1:80;
- server_name status.localhost;
- keepalive_timeout 0;
- allow 127.0.0.1;
- deny all;
- access_log off;
- location /server-status {
- stub_status on;
- }
- location /status {
- access_log off;
- allow 127.0.0.1;
- deny all;
- include fastcgi_params;
- fastcgi_pass unix:/run/php-fpm/www.sock;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- }
- }
- }
- ##################################################################
- ##################################################################
- mcedit /etc/nginx/sites-available/load.sytes.net.conf
- ##################################################################
- ##################################################################
- server {
- listen 443 ssl http2;
- server_name load.sytes.net;
- root /var/www/html/load.sytes.net/public;
- index index.php index.html index.htm;
- access_log /var/log/nginx/load.sytes.net.access.log;
- error_log /var/log/nginx/load.sytes.net.error.log;
- ssl_certificate /etc/letsencrypt/live/load.sytes.net/fullchain.pem; # managed by Certbot
- ssl_certificate_key /etc/letsencrypt/live/load.sytes.net/privkey.pem; # managed by Certbot
- location / {
- try_files $uri $uri/ /index.php?$args;
- }
- location ~* ^.+.(js|css|png|jpg|jpeg|gif|ico|woff)$ {
- access_log off;
- expires max;
- }
- location ~ \.php$ {
- try_files $uri =404;
- fastcgi_pass unix:/run/php/php7.4-fpm.sock;
- fastcgi_index index.php;
- fastcgi_param DOCUMENT_ROOT /var/www/html/load.sytes.net/public/;
- fastcgi_param SCRIPT_FILENAME /var/www/html/load.sytes.net/public$fastcgi_script_name;
- fastcgi_param PATH_TRANSLATED /var/www/html/load.sytes.net/public$fastcgi_script_name;
- include fastcgi_params;
- fastcgi_param QUERY_STRING $query_string;
- fastcgi_param REQUEST_METHOD $request_method;
- fastcgi_param CONTENT_TYPE $content_type;
- fastcgi_param CONTENT_LENGTH $content_length;
- fastcgi_param HTTPS on;
- fastcgi_intercept_errors on;
- fastcgi_ignore_client_abort off;
- fastcgi_connect_timeout 60;
- fastcgi_send_timeout 180;
- fastcgi_read_timeout 180;
- fastcgi_buffer_size 128k;
- fastcgi_buffers 4 256k;
- fastcgi_busy_buffers_size 256k;
- fastcgi_temp_file_write_size 256k;
- }
- location = /favicon.ico {
- log_not_found off;
- access_log off;
- }
- location = /robots.txt {
- allow all;
- log_not_found off;
- access_log off;
- }
- location ~ /\.ht {
- deny all;
- }
- }
- server {
- listen 443 ssl http2;
- server_name www.load.sytes.net;
- return 301 https://load.sytes.net$request_uri;
- }
- server {
- listen 80;
- server_name load.sytes.net;
- root /var/www/html/load.sytes.net/public;
- index index.php index.html index.htm;
- access_log /var/log/nginx/load.sytes.net.access.log;
- error_log /var/log/nginx/load.sytes.net.error.log;
- location / {
- return 301 https://load.sytes.net$request_uri;
- }
- }
- server {
- listen 80;
- server_name www.load.sytes.net;
- return 301 http://load.sytes.net$request_uri;
- }
- ##################################################################
- ##################################################################
- ##################################################################
- ##################################################################
- Snuffleupagus
- https://zinglau.com/projects/ObfuscatedOpenSSHPatches.html
- https://github.com/dev-sec/ansible-collection-hardening
- https://www.sherbers.de/running-nginx-without-root/
- https://www.upguard.com/blog/top-11-ways-to-improve-mysql-security
- logrotate
- ####################################################################################
- mcedit /etc/logrotate.d/nginx
- /var/log/nginx/*.log {
- size = 10M
- dateext
- daily
- dateformat -%Y-%m-%d_%H-%s
- missingok
- rotate 14
- compress
- delaycompress
- notifempty
- create 0640 www-data adm
- sharedscripts
- prerotate
- if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
- run-parts /etc/logrotate.d/httpd-prerotate; \
- fi \
- endscript
- postrotate
- invoke-rc.d nginx rotate >/dev/null 2>&1
- endscript
- }
- ######################
- mcedit /etc/logrotate.conf
- ]
- # see "man logrotate" for details
- # global options do not affect preceding include directives
- # rotate log files weekly
- weekly
- # keep 4 weeks worth of backlogs
- rotate 4
- # create new (empty) log files after rotating old ones
- create
- # use date as a suffix of the rotated file
- dateext
- # uncomment this if you want your log files compressed
- #compress
- # packages drop log rotation information into this directory
- include /etc/logrotate.d
- # system-specific logs may also be configured here.
- #############################
- mcedit /etc/crontab
- # /etc/crontab: system-wide crontab
- # Unlike any other crontab you don't have to run the `crontab'
- # command to install the new version when you edit this file
- # and files in /etc/cron.d. These files also have username fields,
- # that none of the other crontabs do.
- SHELL=/bin/sh
- PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
- # Example of job definition:
- # .---------------- minute (0 - 59)
- # | .------------- hour (0 - 23)
- # | | .---------- day of month (1 - 31)
- # | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
- # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
- # | | | | |
- # * * * * * user-name command to be executed
- 17 *<-->* * *<->root cd / && run-parts --report /etc/cron.hourly
- 25 6<-->* * *<->root<-->test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
- 47 6<-->* * 7<->root<-->test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
- 52 6<-->1 * *<->root<-->test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
- #
- */5 * * * * /etc/cron.daily/logrotate
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement