linux下如何批量设置文件夹及文件的权限

luby 技术文章 2026-06-18 22:18 105 阅读

linux下如何批量设置文件夹及文件的权限

# 设置正确的文件权限
sudo chown -R www-data:www-data /var/www/iwebshop
sudo find /var/www/iwebshop -type d -exec chmod 755 {} \;
sudo find /var/www/iwebshop -type f -exec chmod 644 {} \;

nginx配置文件示例,端口8081是普通动态页面,8082是iwebshop伪静态配置。

iwebshop设置伪静态,需要同时确认 php.ini 中已启用:‌

cgi.fix_pathinfo = 1

server {
    listen 8081;
    root /var/www/tiku;
    index index.php index.html;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ .php$ {
        include snippets/fastcgi-php.conf;
        # 请根据你的实际 PHP 版本修改 socket 路径,如 php7.4-fpm.sock 或 php8.1-fpm.sock
        fastcgi_pass unix:/run/php/php7.4-fpm.sock; 
    }
}
server {
    listen 8082;
    root /var/www/hxbb;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php$uri?$query_string;
       # try_files $uri $uri/ =404;
    }

    #location ~ .php$ {
    location ~ [^/].php(/|$) {
        #include snippets/fastcgi-php.conf;
        # 请根据你的实际 PHP 版本修改 socket 路径,如 php7.4-fpm.sock 或 php8.1-fpm.sock
        fastcgi_pass unix:/run/php/php7.4-fpm.sock; 
        fastcgi_index index.php;
        include fastcgi_params;
        # PATH_INFO 支持
        set $path_info "";
        set $real_script_name $fastcgi_script_name;
        if ($fastcgi_script_name ~ "^(.+?.php)(/.+)$") {
            set $real_script_name $1;
            set $path_info $2;
        }

        fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
        fastcgi_param SCRIPT_NAME $real_script_name;
        fastcgi_param PATH_INFO $path_info;
    }
    location ~ /.ht {
        deny all;
    }
}
评论 (0)
登录后发表评论

暂无评论