Last active
January 4, 2026 21:04
-
-
Save sweetnight/9e8bbef54f8b7d9e3128e1c385394c17 to your computer and use it in GitHub Desktop.
Setting Nginx untuk Website WordPress + phpMyAdmin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| server { | |
| listen 18080; | |
| server_name example.com; | |
| root /var/www/example.com; | |
| index index.php index.html; | |
| client_max_body_size 256M; | |
| # include /etc/nginx/snippets/security-rules.conf; | |
| location / { | |
| try_files $uri $uri/ /index.php$is_args$args; | |
| # limit_req zone=one burst=20 nodelay; | |
| } | |
| # ---------------------------- | |
| # PHP MAIN HANDLER | |
| # ---------------------------- | |
| location ~ \.php$ { | |
| include snippets/fastcgi-php.conf; | |
| fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; | |
| } | |
| # ---------------------------- | |
| # BLOCK PHP IN UPLOADS (WORDPRESS) | |
| # ---------------------------- | |
| location ~* /wp-content/uploads/.*\.php$ { | |
| deny all; | |
| } | |
| # ---------------------------- | |
| # PHPMyAdmin - AMANKAN | |
| # ---------------------------- | |
| location ^~ /phpmyadmin { | |
| alias /usr/share/phpmyadmin/; | |
| allow 127.0.0.1; | |
| deny all; | |
| location ~ \.php$ { | |
| include fastcgi_params; | |
| fastcgi_param SCRIPT_FILENAME $request_filename; | |
| fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; | |
| } | |
| } | |
| # ---------------------------- | |
| # STATIC FILE OPTIMIZATION | |
| # ---------------------------- | |
| location = /favicon.ico { log_not_found off; access_log off; } | |
| location = /robots.txt { log_not_found off; access_log off; allow all; } | |
| location ~* \.(css|gif|ico|jpeg|jpg|js|png|woff|woff2|ttf|svg)$ { | |
| expires max; | |
| log_not_found off; | |
| } | |
| # ---------------------------- | |
| # DEBUG LOG (INTERNAL ONLY) | |
| # ---------------------------- | |
| location /wp-content/debug.log { | |
| internal; | |
| alias /var/www/example.com/wp-content/debug.log; | |
| } | |
| # ---------------------------- | |
| # ADMIN AJAX FIX | |
| # ---------------------------- | |
| location = /wp-admin/admin-ajax.php { | |
| include snippets/fastcgi-php.conf; | |
| fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment