اذهب إلى المحتوى

تشغيل موقع ووردبريس عبر خادم Nginx


Ali Qassem

رغم أنَّ حزمة LAMP، المكونة من لينكس Linux وأباتشي Apache وMySQL وPHP، تحظى بشعبية كبيرة في تشغيل ووردبريس، لكن يمكن استخدام Nginx -تلفظ إنجن إكس- أيضًا إذ يدعمه ووردبريس، وهو يُشغَّل بعض مواقع ووردبريس الكبيرة، مثل WordPress.com.

من المهم عند الحديث عن Nginx معرفة أنه توجد طرق متعددة لتطبيقه، ويمكن إعداده مثل وكيل عكسي أمام Apache، وهو إعداد قوي للغاية يسمح لك باستخدام جميع ميزات وقوة Apache مع الاستفادة من سرعة Nginx، ومعظم مواقع الويب التي تستخدم Nginx خادمًا -بناءًا على الإحصائيات التي جُمعت من ترويسات استجابة HTTP- هي في الواقع تعمل على Apache مع Nginx وكيلًا عكسيًا، حيث تعرض ترويسات استجابة HTTP إحصائيات استخدام Nginx وكيلًا عكسيًا وليس خادمًا.

يشير هذا الدليل إلى إعداد Nginx مستقل، حيث يُستخدم خادمًا أساسيًا بدلاً من أباتشي، ويجب الإشارة إلى أنَّ Nginx ليس بديلاً تمامًا عن Apache، حيث توجد بعض الاختلافات الرئيسية التي تؤثر على تطبيق ووردبريس، والتي يجب أن تكون على دراية بها قبل المتابعة:

  • عند استخدام Nginx لا يوجد ملف تهيئة على مستوى الدليل، مثل الملف htaccess. الخاص بخادم Apache، أو ملفات web.config الخاصة بالخادم IIS، ويجب إجراء كامل التهيئة على مستوى الخادم من قبل المدير، ولا يمكن تعديل الإعدادات في ووردبريس كما هو الحال مع Apache أو IIS.
  • تختلف الروابط الثابتة قليلاً عند تشغيل Nginx.
  • لا يحتوي Nginx على صلاحيات من نوع htaccess.، ولا يمكن تعديل إعدادات الخادم تلقائيًا عبر ووردبريس، لذا لا يمكنه إنشاء قواعد إعادة الكتابة.
  • سيضاف "index.php" إلى روابطك الثابتة دون تعديلات على تثبيتك الخاص، وتوجد طرق لتجاوز هذا باستخدام بعض الإضافات، أو إضافة شيفرة مخصصة إلى function.php لقالبك، أو بالطريقتين معًا.
  • إذا أردت الحصول على بعض الإمكانيات المحدودة للملف htaccess.، فمن الممكن تقنيًا الإضافة عن طريق تثبيت ملحق htscanner PECL لـ PHP، إلا أن هذا ليس حلًا مثاليًا لذا تأكد من ذلك واختبره تمامًا قبل استخدامه المباشر على الموقع.

لن يغطي هذا الدليل كيفية تثبيت Nginx وإعداداته، لذلك يفترض أنك ثبّتت Nginx، وتعلم كيفية التعامل معه وتصحيح أخطائه.

الدعم العام ومتعدد المواقع

يجب ضبط الواجهة الخلفية php-cgi حتى يعمل ووردبريس مع Nginx، والخيارات المتاحة هي fastcgi أو php-fpm، ويُستخدَم php-fpm لأنه مضمَّن في إصدار PHP 5.3 وما بعده، لذا فتثبيته مباشر.

قُسمت إعدادت Nginx إلى خمسة ملفات مميزة، مع التعليق عليها لتسهيل فهمها، كما بذل المؤلف كل جهده في محاولة اتباع "أفضل الممارسات" لإعدادات nginx.

ملف بدء التشغيل الرئيسي (العام)

يكافئ هذا /etc/nginx/nginx.conf أو /etc/nginx/conf/nginx.conf عند استخدام لينكس Arch.

# Generic startup file.
user {user} {group};

#usually equal to number of CPUs you have. run command "grep processor /proc/cpuinfo | wc -l" to find it
worker_processes  auto;
worker_cpu_affinity auto;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

# Keeps the logs free of messages about not being able to bind().
#daemon     off;

events {
    worker_connections  1024;
}

http {
#   rewrite_log on;

    include mime.types;
    default_type       application/octet-stream;
    access_log         /var/log/nginx/access.log;
    sendfile           on;
#   tcp_nopush         on;
    keepalive_timeout  3;
#   tcp_nodelay        on;
#   gzip               on;
        #php max upload limit cannot be larger than this       
    client_max_body_size 13m;
    index              index.php index.html index.htm;

    # Upstream to abstract backend connection(s) for PHP.
    upstream php {
                #this should match value of "listen" directive in php-fpm pool
        server unix:/tmp/php-fpm.sock;
#       server 127.0.0.1:9000;
    }

    include sites-enabled/*;
}

يختلف هذا قليلًا عن ملفات nginx.conf القياسية، ويتبع هذا الإعداد طريقة Ubuntu/Debian لجعل المواقع المفعلة بأقصى درجة مرونة، باستخدام "sites-available" لتخزين الإعدادات، ثم الربط بملف الإعدادات من "sites-enabled".

حسب إعدادات الموقع

# Redirect everything to the main site. We use a separate server statement and NOT an if statement - see http://wiki.nginx.org/IfIsEvil

server {
        server_name  _;
        return 302 $scheme://example.com$request_uri;
}

server {
    server_name example.com;
    root /var/www/example.com;

    index index.php;

    include global/restrictions.conf;

    # Additional rules go here.

    # Only include one of the files below.
    include global/wordpress.conf;
#    include global/wordpress-ms-subdir.conf;
#    include global/wordpress-ms-subdomain.conf;
}

يسمح فصل أقسام الإعدادات إلى ملفات متعددة بإعادة استخدام نفس المنطق مرارًا وتكرارًا، ويُستخدم الدليل الفرعي "global" لإضافة صلاحيات إضافية للاستخدام للأغراض العامة، /etc/nginx/conf/global/ أو /etc/nginx/global/، بناءً على كيفية إعداد تثبيت nginx.

ملف القيود الشامل

# Global restrictions configuration file.
# Designed to be included in any server {} block.
location = /favicon.ico {
    log_not_found off;
    access_log off;
}

location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}

# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
# Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
location ~ /\. {
    deny all;
}

# Deny access to any files with a .php extension in the uploads directory
# Works in sub-directory installs and also in multisite network
# Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
location ~* /(?:uploads|files)/.*\.php$ {
    deny all;
}

مبادئ ووردبريس العامة

للتثبيت في موقع مفرد إليك ملف global/wordpress.conf:

# WordPress single site rules.
# Designed to be included in any server {} block.
# Upstream to abstract backend connection(s) for php
upstream php {
        server unix:/tmp/php-cgi.socket;
        server 127.0.0.1:9000;
}

server {
        ## Your website name goes here.
        server_name domain.tld;
        ## Your only path reference.
        root /var/www/wordpress;
        ## This should be in your http block and if it is, it's not needed here.
        index index.php;

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

        location / {
                # This is cool because no php is touched for static content.
                # include the "?$args" part so non-default permalinks doesn't break when using query string
                try_files $uri $uri/ /index.php?$args;
        }

        location ~ \.php$ {
                #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                include fastcgi.conf;
                fastcgi_intercept_errors on;
                fastcgi_pass php;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }
}

إليك مثالًا حديثًا عن Nginx

مبادئ الدليل الفرعي لووردبريس متعدد المواقع

لتثبيت الدليل الفرعي متعدد المواقع إليك ملف global/wordpress.conf:

# WordPress multisite subdirectory rules.
# Designed to be included in any server {} block.

map $uri $blogname{
    ~^(?P/[^/]+/)files/(.*)       $blogpath ;
}

map $blogname $blogid{
    default -999;

    #Ref: https://wordpress.org/extend/plugins/nginx-helper/
    #include /var/www/wordpress/wp-content/plugins/nginx-helper/map.conf ;
}

server {
    server_name example.com ;

    root /var/www/example.com/htdocs;
    index index.php;

    location ~ ^(/[^/]+/)?files/(.+) {
        try_files /wp-content/blogs.dir/$blogid/files/$2 /wp-includes/ms-files.php?file=$2 ;
        access_log off;     log_not_found off; expires max;
    }

    #avoid php readfile()
    location ^~ /blogs.dir {
        internal;
        alias /var/www/example.com/htdocs/wp-content/blogs.dir ;
        access_log off;     log_not_found off; expires max;
    }

    if (!-e $request_filename) {
        rewrite /wp-admin$ $scheme://$host$request_uri/ permanent;
        rewrite ^(/[^/]+)?(/wp-.*) $2 last;
        rewrite ^(/[^/]+)?(/.*\.php) $2 last;
    }

    location / {
        try_files $uri $uri/ /index.php?$args ;
    }

    location ~ \.php$ {
        try_files $uri =404;
        include fastcgi_params;
        fastcgi_pass php;
    }

    #add some rules for static content expiry-headers here
}

يوفر NGINX توجيهين خاصين هما X-Accel-Redirect و map، ويمكن للمستخدم باستخدامهما إلغاء أداء خدمة الملفات الثابتة على شبكة ووردبريس متعددة المواقع.

مبادئ النطاق الفرعي لووردبريس متعدد المواقع

map $http_host $blogid {
    default       -999;

    #Ref: https://wordpress.org/extend/plugins/nginx-helper/
    #include /var/www/wordpress/wp-content/plugins/nginx-helper/map.conf ;

}

server {
    server_name example.com *.example.com ;

    root /var/www/example.com/htdocs;
    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$args ;
    }

    location ~ \.php$ {
        try_files $uri =404;
        include fastcgi_params;
        fastcgi_pass php;
    }

    #WPMU Files
        location ~ ^/files/(.*)$ {
                try_files /wp-content/blogs.dir/$blogid/$uri /wp-includes/ms-files.php?file=$1 ;
                access_log off; log_not_found off;      expires max;
        }

    #WPMU x-sendfile to avoid php readfile()
    location ^~ /blogs.dir {
        internal;
        alias /var/www/example.com/htdocs/wp-content/blogs.dir;
        access_log off;     log_not_found off;      expires max;
    }

    #add some rules for static content expiry-headers here
}

HTTPS في Nginx

يعد تفعيل HTTPS في Nginx أمرًا بسيطًا نسبيًا.

server {
    # listens both on IPv4 and IPv6 on 443 and enables HTTPS and HTTP/2 support.
    # HTTP/2 is available in nginx 1.9.5 and above.
    listen *:443 ssl http2;
    listen [::]:443 ssl http2;

    # indicate locations of SSL key files.
    ssl_certificate /srv/www/ssl/ssl.crt;
    ssl_certificate_key /srv/www/ssl/ssl.key;
    ssl_dhparam /srv/www/master/ssl/dhparam.pem;

    # indicate the server name
    server_name example.com *.example.com;

    # Enable HSTS. This forces SSL on clients that respect it, most modern browsers. The includeSubDomains flag is optional.
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";

    # Set caches, protocols, and accepted ciphers. This config will merit an A+ SSL Labs score as of Sept 2015.
    ssl_session_cache shared:SSL:20m;
    ssl_session_timeout 10m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers 'ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5';
}

تقدم Mozilla أداة إنشاء تكوين SSL ممتازةً أيضًا.

قواعد ذاكرة التخزين المؤقت الفائقة WP

# WP Super Cache rules.
# Designed to be included from a 'wordpress-ms-```' configuration file.

set $cache_uri $request_uri;

# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
        set $cache_uri 'null cache';
}

if ($query_string != "") {
        set $cache_uri 'null cache';
}  

# Don't cache uris containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
        set $cache_uri 'null cache';
}  

# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
        set $cache_uri 'null cache';
}

# START MOBILE
# Mobile browsers section to server them non-cached version. COMMENTED by default as most modern wordpress themes including twenty-eleven are responsive. Uncomment config lines in this section if you want to use a plugin like WP-Touch
# if ($http_x_wap_profile) {
#        set $cache_uri 'null cache';
#}

#if ($http_profile) {
#        set $cache_uri 'null cache';
#}

#if ($http_user_agent ~* (2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800)) {
 #       set $cache_uri 'null cache';
#}

#if ($http_user_agent ~* (w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-)) {
  #      set $cache_uri 'null cache';
#}
#END MOBILE

# Use cached or actual file if they exists, otherwise pass request to WordPress
location / {
        try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?$args ;
}

التعديلات التجريبية

إذا كنت تستخدم HTTPS فقد تستخدم أحدث نسخة مطورة من WP Super Cache بنية دليل مختلفةً للتمييز بين HTTP وHTTPS، وقد يبدو سطر try_files كما يلي:

location / {
        try_files /wp-content/cache/supercache/$http_host/$cache_uri/index-https.html $uri $uri/ /index.php?$args ;
}

قواعد ذاكرة التخزين المؤقتة W3 Total Cache

تستخدم W3 Total Cache بنية دليل مختلفةً لذاكرة التخزين المؤقت على القرص اعتمادًا على تكوين ووردبريس، وتبقى عمليات التحقق من صحة ذاكرة التخزين المؤقت كما هو موضح أدناه:

#W3 TOTAL CACHE CHECK
set $cache_uri $request_uri;

# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
        set $cache_uri 'null cache';
}  
if ($query_string != "") {
        set $cache_uri 'null cache';
}  

# Don't cache uris containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
        set $cache_uri 'null cache';
}  

# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
        set $cache_uri 'null cache';
}
#ADD mobile rules from WP SUPER CACHE section above

#APPEND A CODE BLOCK FROM BELOW```

استخدم ما يلي لووردبريس العادي، بدون مواقع متعددة:

# Use cached or actual file if they exists, otherwise pass request to WordPress
location / {
        try_files /wp-content/w3tc/pgcache/$cache_uri/_index.html $uri $uri/ /index.php?$args ;
}

وللمواقع المتعددة مع الأدلة الفرعية استخدم:

if ( $request_uri ~* "^/([_0-9a-zA-Z-]+)/.*" ){
        set $blog $1;
}

set $blog "${blog}.";

if ( $blog = "blog." ){
        set $blog "";
}

# Use cached or actual file if they exists, otherwise pass request to WordPress
location / {
        try_files /wp-content/w3tc-$blog$host/pgcache$cache_uri/_index.html $uri $uri/ /index.php?$args ;
}

ولمواقع متعددة مع نطاقات فرعية أو تعيين النطاق استخدم:

location / {
        try_files /wp-content/w3tc-$host/pgcache/$cache_uri/_index.html $uri $uri/ /index.php?$args;
}

ملاحظات:

  • يمكن لـ Nginx معالجة gzip وذاكرة التخزين المؤقت للمتصفح تلقائيًا، لذا من الأفضل ترك هذا الجزء لـ nginx.
  • ستعمل قواعد W3 Total Cache Minify مع الإعدادات أعلاه دون أي مشاكل.

Nginx fastcgi_cache

يمكن لـ Nginx إجراء التخزين المؤقت من جانبه لتقليل الحمل على الخادم، وعندما تريد استخدام fastcgi_cache المدمج في Nginx، يفضل تشغيل nginx باستخدام وحدة fastcgi_cache_purge، وستساعد nginx على مسح ذاكرة التخزين المؤقت لصفحة ما عند تحريرها. ومن ناحية ووردبريس، ستحتاج إلى تثبيت إضافة مثل مساعد Nginx للاستفادة من ميزة fastcgi_cache_purge.

ستبدو الإعدادات كما يلي:

حدد منطقة ذاكرة التخزين المؤقت Nginx في كتلة {…}http، خارج كتلة {..}server:

#move next 3 lines to /etc/nginx/nginx.conf if you want to use fastcgi_cache across many sites
fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:500m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;

بالنسبة لإعدادات موقع ووردبريس في الكتلة {..}server أضف كتلة تحقق من ذاكرة التخزين المؤقت على النحو التالي:

#fastcgi_cache start
set $no_cache 0;

# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
        set $no_cache 1;
}  
if ($query_string != "") {
        set $no_cache 1;
}  

# Don't cache uris containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
        set $no_cache 1;
}  

# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
        set $no_cache 1;
}

ثم أجرِ تغييرات على كتلة معالجة PHP.

فقط أضف هذا إلى كتلة php التالية، لاحظ السطر fastcgi_cache_valid 200 60m، الذي يخبر nginx بالتخزين المؤقت للاستجابات 200 -أي الصفحات العادية- فقط، مما يعني أن صفحات إعادة التوجيه لا تخزَّن مؤقتًا، وهذا مهم للمواقع متعددة اللغات، وإذا لم ينفَّذ فسيخزن nginx عنوان url الرئيسي في لغة واحدة، بدلًا من إعادة توجيه المستخدمين إلى المحتوى الخاص بهم وفقًا للغتهم.

fastcgi_cache_bypass $no_cache;
fastcgi_no_cache $no_cache;

fastcgi_cache WORDPRESS;
fastcgi_cache_valid 200 60m;

بحيث يصبح مثل هذا:

location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) {
        return 404;
    }
    # This is a robust solution for path info security issue and works with "cgi.fix_pathinfo = 1" in /etc/php.ini (default)

    include fastcgi.conf;
    fastcgi_index index.php;
#    fastcgi_intercept_errors on;
    fastcgi_pass php;

    fastcgi_cache_bypass $no_cache;
    fastcgi_no_cache $no_cache;

    fastcgi_cache WORDPRESS;
    fastcgi_cache_valid 200 60m;
}

أخيرًا أضف موقعًا للمسح الشرطي:

location ~ /purge(/.*) {
        # Uncomment the following two lines to allow purge only from the webserver
        #allow 127.0.0.1;
    #deny all;

        fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
}

إذا تلقيت خطأ "توجيه غير معروف fastcgicachepurge" فتحقق من أنَّ تثبيت Nginx يحتوي على وحدة fastcgicachepurge.

أداء أفضل للملفات الثابتة في المواقع المتعددة

يؤدي طلب ملف ثابت عند إعداد المواقع المتعددة إلى تشغيل php، أي الملف ms-files.php، ويمكنك الحصول على أداء أفضل بكثير باستخدام توجيه {..}Map في Nginx.

أضف ما يلي في إعدادات Nginx لموقعك فوق الكتلة {..}server:

map $http_host $blogid {
    default               0;

    example.com           1;
    site1.example.com     2;
    site1.com             2;
}

إنها مجرد قائمة بأسماء المواقع ومعرفات المدونات، ويمكنك استخدام مساعد Nginx للحصول على مثل هذه القائمة في أزواج تحوي أسماء المواقع ومعرفات المدونات، وستنشئ هذه الإضافة أيضًا ملف map.conf يمكنك تضمينه مباشرةً في قسم {..}map بالشكل التالي:

map $http_host $blogid {
    default               0;

    include /path/to/map.conf ;
}

بعد إنشاء قسم {..}map تحتاج إجراء تغيير واحد آخر في إعدادات Nginx لتعالج طلبات /files/ أولًا باستخدام {..}map في nginx:

location ~ ^/files/(.*)$ {
          try_files /wp-content/blogs.dir/$blogid/$uri /wp-includes/ms-files.php?file=$1 ;
          access_log off; log_not_found off; expires max;
 }

ملاحظات

انتبه إلى ما يلي:

  • عند إنشاء موقع جديد أو حذفه أو تعيين نطاق إضافي لموقع موجود؛ سيحدّث مساعد Nginx ملف map.conf تلقائيًا، ولكنك ستحتاج إلى إعادة تحميل إعدادات Nginx يدويًا، ويمكنك ذلك في أي وقت لاحق، وحتى ذلك الحين ستقدَّم ملفات المواقع الجديدة فقط باستخدام php-fpm.
  • لا تولد هذه الطريقة أي روابط رمزية symbolic links، لذلك لن تكون هناك مشكلات في عمليات الحذف العرضية أو البرامج النصية الاحتياطية التي تتبع روابط رمزية.
  • يمكن توسيع هذا بشكل جيد للشبكات الكبيرة، وسيوجد فقط ملف map.conf واحد.

وفي ملاحظة أخيرة مهمة: يفترض هذا الإعداد بأكمله أن جذر الموقع هو المدونة، وأن جميع الملفات التي نرجع إليها موجودة في المضيف، وإذا وضعت المدونة في دليل فرعي مثل blog/، فسيتعين تعديل القواعد، ويمكن للمستخدم جعل ذلك ممكنًا، فمثلًا يمكنك استخدام التوجيه التالي في كتلة "server" الرئيسية، وتطبيقه تلقائيًا على قواعد WP العامة:

set $wp_subdir "/blog";

انتبه هنا، إذ يمكن أن يؤدي خطأ مطبعي في Global restrictions file إلى حدوث ثغرات، ولاختبار ما إذا كان دليل uploads محميًا حقًا أنشئ ملف PHP مع بعض المحتوى، على سبيل المثال:

<?php phpinfo(); ?>

ارفعه إلى الدليل uploads، أو أحد أدلته الفرعية، ثم حاول الوصول إليه (تنفيذه) من متصفحك.

للالطلاع أكثر، يمكنك زيارة الآتي:

ترجمة -وبتصرف- للمقال Nginx من موقع wordpress.org.

اقرأ أيضًا


تفاعل الأعضاء

أفضل التعليقات

لا توجد أية تعليقات بعد



انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أضف تعليق

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • أضف...