Skip to main content
deleted 1 character in body
Source Link
Arcticooling
  • 4.5k
  • 18
  • 56
  • 107

When I create a new webapp conf in Nginx I use the following template:

server {
    root /var/www/html/${domain};
    server_name ${domain} www.${domain};
    location ~*  \.(jpg|jpeg|png|gif|ico|css|js|ttf|woff|pdf)$ {
        expires 365d; 
    }
    location / {
        index index.php index.html index.htm fastcgi_index;
        try_files $uri $uri =404 $uri/ /index.php?$args;
    }
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Note the following location block in that template:

location ~ \.php$ {
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

Is there a "safe" way to make it version agnostic (that is, not to target version 7.0 specifically, or any other version, for that matter).

Do you know a way to do that? I'm not sure regex is the best way to go, maybe there's just another way to config this.

Update

BTW, running these 7.0 commands isdirectives can also be a bit painful, - you sometimes just want to run a script, without starting to measure versions:

sed -i 's/post_max_size \= .M/post_max_size \= 200M/g' /etc/php/7.0/fpm/php.ini
sed -i 's/upload_max_filesize \= .M/upload_max_filesize \= 200M/g' /etc/php/7.0/fpm/php.ini
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" /etc/php/7.0/fpm/php.ini
/etc/init.d/php7.0-fpm restart && systemctl restart nginx.service

When I create a new webapp conf in Nginx I use the following template:

server {
    root /var/www/html/${domain};
    server_name ${domain} www.${domain};
    location ~*  \.(jpg|jpeg|png|gif|ico|css|js|ttf|woff|pdf)$ {
        expires 365d; 
    }
    location / {
        index index.php index.html index.htm fastcgi_index;
        try_files $uri $uri =404 $uri/ /index.php?$args;
    }
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Note the following location block in that template:

location ~ \.php$ {
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

Is there a "safe" way to make it version agnostic (that is, not to target version 7.0 specifically, or any other version, for that matter).

Do you know a way to do that? I'm not sure regex is the best way to go, maybe there's just another way to config this.

Update

BTW, running these 7.0 commands is also a bit painful, you sometimes just want to run a script, without starting to measure versions:

sed -i 's/post_max_size \= .M/post_max_size \= 200M/g' /etc/php/7.0/fpm/php.ini
sed -i 's/upload_max_filesize \= .M/upload_max_filesize \= 200M/g' /etc/php/7.0/fpm/php.ini
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" /etc/php/7.0/fpm/php.ini
/etc/init.d/php7.0-fpm restart && systemctl restart nginx.service

When I create a new webapp conf in Nginx I use the following template:

server {
    root /var/www/html/${domain};
    server_name ${domain} www.${domain};
    location ~*  \.(jpg|jpeg|png|gif|ico|css|js|ttf|woff|pdf)$ {
        expires 365d; 
    }
    location / {
        index index.php index.html index.htm fastcgi_index;
        try_files $uri $uri =404 $uri/ /index.php?$args;
    }
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Note the following location block in that template:

location ~ \.php$ {
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

Is there a "safe" way to make it version agnostic (that is, not to target version 7.0 specifically, or any other version, for that matter).

Do you know a way to do that? I'm not sure regex is the best way to go, maybe there's just another way to config this.

Update

BTW, these 7.0 directives can also be a bit painful - you sometimes just want to run a script, without starting to measure versions:

sed -i 's/post_max_size \= .M/post_max_size \= 200M/g' /etc/php/7.0/fpm/php.ini
sed -i 's/upload_max_filesize \= .M/upload_max_filesize \= 200M/g' /etc/php/7.0/fpm/php.ini
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" /etc/php/7.0/fpm/php.ini
/etc/init.d/php7.0-fpm restart && systemctl restart nginx.service
deleted 8 characters in body
Source Link
Arcticooling
  • 4.5k
  • 18
  • 56
  • 107

When I create a new webapp conf in Nginx I use the following template:

server {
    root /var/www/html/${domain};
    server_name ${domain} www.${domain};
    location ~*  \.(jpg|jpeg|png|gif|ico|css|js|ttf|woff|pdf)$ {
        expires 365d; 
    }
    location / {
        index index.php index.html index.htm fastcgi_index;
        try_files $uri $uri =404 $uri/ /index.php?$args;
    }
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Note the following location block in that template:

location ~ \.php$ {
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

Is there a "safe" way to make it version agnostic (that is, not to target version 7.0 specifically, or any other version, for that matter).

Do you know a way to do that? I'm not sure regex is the best way to go, maybe there's just another way to config this.

Update

I must sayBTW, running these commands 7.0 specificallycommands is alsoalso a bit painful, you sometimes just want to run a script, without starting to measure versions:

sed -i 's/post_max_size \= .M/post_max_size \= 200M/g' /etc/php/7.0/fpm/php.ini
sed -i 's/upload_max_filesize \= .M/upload_max_filesize \= 200M/g' /etc/php/7.0/fpm/php.ini
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" /etc/php/7.0/fpm/php.ini
/etc/init.d/php7.0-fpm restart && systemctl restart nginx.service

When I create a new webapp conf in Nginx I use the following template:

server {
    root /var/www/html/${domain};
    server_name ${domain} www.${domain};
    location ~*  \.(jpg|jpeg|png|gif|ico|css|js|ttf|woff|pdf)$ {
        expires 365d; 
    }
    location / {
        index index.php index.html index.htm fastcgi_index;
        try_files $uri $uri =404 $uri/ /index.php?$args;
    }
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Note the following location block in that template:

location ~ \.php$ {
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

Is there a "safe" way to make it version agnostic (that is, not to target version 7.0 specifically, or any other version, for that matter).

Do you know a way to do that? I'm not sure regex is the best way to go, maybe there's just another way to config this.

Update

I must say, running these commands 7.0 specifically is also a bit painful, you sometimes just run a script, without starting to measure versions:

sed -i 's/post_max_size \= .M/post_max_size \= 200M/g' /etc/php/7.0/fpm/php.ini
sed -i 's/upload_max_filesize \= .M/upload_max_filesize \= 200M/g' /etc/php/7.0/fpm/php.ini
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" /etc/php/7.0/fpm/php.ini
/etc/init.d/php7.0-fpm restart && systemctl restart nginx.service

When I create a new webapp conf in Nginx I use the following template:

server {
    root /var/www/html/${domain};
    server_name ${domain} www.${domain};
    location ~*  \.(jpg|jpeg|png|gif|ico|css|js|ttf|woff|pdf)$ {
        expires 365d; 
    }
    location / {
        index index.php index.html index.htm fastcgi_index;
        try_files $uri $uri =404 $uri/ /index.php?$args;
    }
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Note the following location block in that template:

location ~ \.php$ {
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

Is there a "safe" way to make it version agnostic (that is, not to target version 7.0 specifically, or any other version, for that matter).

Do you know a way to do that? I'm not sure regex is the best way to go, maybe there's just another way to config this.

Update

BTW, running these 7.0 commands is also a bit painful, you sometimes just want to run a script, without starting to measure versions:

sed -i 's/post_max_size \= .M/post_max_size \= 200M/g' /etc/php/7.0/fpm/php.ini
sed -i 's/upload_max_filesize \= .M/upload_max_filesize \= 200M/g' /etc/php/7.0/fpm/php.ini
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" /etc/php/7.0/fpm/php.ini
/etc/init.d/php7.0-fpm restart && systemctl restart nginx.service
added 499 characters in body
Source Link
Arcticooling
  • 4.5k
  • 18
  • 56
  • 107

When I create a new webapp conf in Nginx I use the following template:

server {
    root /var/www/html/${domain};
    server_name ${domain} www.${domain};
    location ~*  \.(jpg|jpeg|png|gif|ico|css|js|ttf|woff|pdf)$ {
        expires 365d; 
    }
    location / {
        index index.php index.html index.htm fastcgi_index;
        try_files $uri $uri =404 $uri/ /index.php?$args;
    }
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Note the following location block in that template:

location ~ \.php$ {
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

Is there a "safe" way to make it version agnostic (that is, not to target version 7.0 specifically, or any other version, for that matter).

Do you know a way to do that? I'm not sure regex is the best way to go, maybe there's just another way to config this.

Update

I must say, running these commands 7.0 specifically is also a bit painful, you sometimes just run a script, without starting to measure versions:

sed -i 's/post_max_size \= .M/post_max_size \= 200M/g' /etc/php/7.0/fpm/php.ini
sed -i 's/upload_max_filesize \= .M/upload_max_filesize \= 200M/g' /etc/php/7.0/fpm/php.ini
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" /etc/php/7.0/fpm/php.ini
/etc/init.d/php7.0-fpm restart && systemctl restart nginx.service

When I create a new webapp conf in Nginx I use the following template:

server {
    root /var/www/html/${domain};
    server_name ${domain} www.${domain};
    location ~*  \.(jpg|jpeg|png|gif|ico|css|js|ttf|woff|pdf)$ {
        expires 365d; 
    }
    location / {
        index index.php index.html index.htm fastcgi_index;
        try_files $uri $uri =404 $uri/ /index.php?$args;
    }
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Note the following location block in that template:

location ~ \.php$ {
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

Is there a "safe" way to make it version agnostic (that is, not to target version 7.0 specifically, or any other version, for that matter).

Do you know a way to do that? I'm not sure regex is the best way to go, maybe there's just another way to config this.

When I create a new webapp conf in Nginx I use the following template:

server {
    root /var/www/html/${domain};
    server_name ${domain} www.${domain};
    location ~*  \.(jpg|jpeg|png|gif|ico|css|js|ttf|woff|pdf)$ {
        expires 365d; 
    }
    location / {
        index index.php index.html index.htm fastcgi_index;
        try_files $uri $uri =404 $uri/ /index.php?$args;
    }
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Note the following location block in that template:

location ~ \.php$ {
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

Is there a "safe" way to make it version agnostic (that is, not to target version 7.0 specifically, or any other version, for that matter).

Do you know a way to do that? I'm not sure regex is the best way to go, maybe there's just another way to config this.

Update

I must say, running these commands 7.0 specifically is also a bit painful, you sometimes just run a script, without starting to measure versions:

sed -i 's/post_max_size \= .M/post_max_size \= 200M/g' /etc/php/7.0/fpm/php.ini
sed -i 's/upload_max_filesize \= .M/upload_max_filesize \= 200M/g' /etc/php/7.0/fpm/php.ini
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" /etc/php/7.0/fpm/php.ini
/etc/init.d/php7.0-fpm restart && systemctl restart nginx.service
Source Link
Arcticooling
  • 4.5k
  • 18
  • 56
  • 107
Loading