Symfony 1.4 Fatal error Class 'myUser' not found - php

In error log I see:
Fatal error: Class 'myUser' not found in /usr/share/nginx/www/services/cache/frontend/dev/config/config_factories.yml.php on line 120
What can caouse this problem ?
Nginx config:
server {
listen 80;
root /usr/share/nginx/www/services/web;
index index.php index.html index.htm;
access_log /usr/share/nginx/www/log/access.log;
error_log /usr/share/nginx/www/log/error.log;
server_name server.lap;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
# pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location / {
index index.php;
try_files $uri /index.php?$args;
}
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ ^/(index|frontend|frontend_dev|backend|backend_dev)\.php$ {
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param HTTPS off;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}

Look to see if there is a myUser.class.php file in the lib folder of your app. If there isn't create one and in it add:
<?php
class myUser extends sfBasicSecurityUser
{
}
?>
Or if you are using sfGuardPlugin:
<?php
class myUser extends sfGuardSecurityUser
{
}
?>
Then clear the cache.

Related

nginx: how to serve /index.php of subfolders?

I have a legacy php websiste that has been migrated to a new server with nginx (and php 7.4)
My nginx has near only this
server {
listen 80;
server_name domain.tld;
root /var/www/domain.tld;
error_log /var/log/nginx/domain.tld-error.log warn;
access_log /var/log/nginx/domain.tldt-access.log combined;
client_body_buffer_size 10M;
client_max_body_size 10M;
location / {
try_files $uri /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}
If I access to mydomain.tld it works, it serves correctly mydomain.tld/index.php
but If I access mydomain.tld/subfolder or mydomain.tld/subfolder/ it doesn't serve mydomain.tld/subfolder/index.php as I expect
What am I doing wrong?
I resolved modifiying the suggestion of Daniel W
I moved the location / block under location ~ \.php$
But instead of remove the initial / I prepended also $uri
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
location / {
index index.php;
try_files $uri $uri/index.php?$args;
}
If I will find some pitfalls I will update my answer

nginx downloads php files instead of executing them

I'm trying to set up a LEMP stack and after going through several tutorials i can't seem to get php working here is my nginx config:
default.conf:
server {
listen 80 0.0.0.0;
listen [::]:80 0.0.0.0 ipv6only=on;
# note that these lines are originally from the "location /" block
root /usr/share/nginx/html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
I believe your problem is the second use of try_files inside the PHP block:
location ~ \.php$ {
===>try_files $uri =404;<====
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Just take that line out and try this:
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
You probably need to add this to your location ~ .php$ {}
include snippets/fastcgi-php.conf;
So it should look like:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
...
}
I found this tut:
https://www.linuxbabe.com/linux-server/how-to-install-lemp-stack-linux-nginx-mariadb-php-on-centos7
It worked!!!!! Here is my default.conf now:
server {
listen 80;
server_name www.example.com example.com;
root /usr/share/nginx/html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php$query_string;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

Nginx change the root location to wordpress site

Currently I have a Wordpress site under /var/www/html/wordpress and other php projects under /var/www/html/projects. I want my root location to point to wordpress one. Here is my current nginx config:
server {
listen 80 default_server;
server_name _;
set $yii_bootstrap "index.php";
root /var/www/html;
client_max_body_size 2M;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location /projects/inspection/ {
root /var/www/html;
try_files $uri /index.php$is_args$args;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
}
location /projects/ {
root /var/www/html;
index index.html $yii_bootstrap;
try_files $uri $uri/ /$yii_bootstrap?$args /index.php$is_args$args;
}
location / {
root /var/www/html/wordpress;
try_files $uri $uri/ =404;
index index.php index.html index.htm;
}
location ~ \.php{
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_pass php-fpm;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
include fastcgi_params;
}
error_page 404 /404.html;
location = /40x.html {
}
}
But it returns 404. I tried to put alias instead and it returns 403 forbidden. How should I handle this?

index.php not working with TOR nginx

all.
I'm using debian with nginx and php5-fpm. I had the site fully functional and then installed Tor to create and onion site. I was successful in configuring it to load an index.html however, when I use an index.php the Tor browser does not display the page. Instead, the Tor browser downloads the index.php. I'm not sure what configurations I need to make. The point of me doing this is for learning. I don't care about security or really using the .onion site. It's bothering me though not figuring it out. Thank you.
This is my server block config in /etc/nginx/sites-available/
server {
listen 127.0.0.1:80;
root /var/www/html/;
index index.php index.html index.htm;
server_name 4bgxjb2vkb7tvsgw.onion;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
root /var/www/html/;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
snippets/fastcgi-php.conf:
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;
# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php;
include fastcgi.conf;
Thank you for your help!
Try something like this:
location / {
try_files $uri $uri/ =404;
}
error_page 401 403 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

The php file is download instead execute on nginx

I use the Symfony config of Nginx server:
server {
server_name cmf.localhost www.cmf.localhost;
root /mnt/hgfs/www/cmf/web;
error_log /var/log/nginx/cmf.error.log;
access_log /var/log/nginx/cmf.access.log;
# strip app.php/ prefix if it is present
rewrite ^/app_dev\.php/?(.*)$ /$1 permanent;
location = /libs/ckfinder/core/connector/php/connector.php {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
location / {
index app_dev.php app.php;
try_files $uri #rewriteapp;
}
location #rewriteapp {
rewrite ^(.*)$ /app_dev.php/$1 last;
}
# pass the PHP scripts to FastCGI server from upstream phpfcgi
location ~ ^/(app|app_dev|config)\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
}
and it work well, but I also need to execute /libs/ckfinder/core/connector/php/connector.php. Now when I try to execute them, it simply download.
How can I config Nginx to executed /libs/ckfinder/core/connector/php/connector.php file?
server {
listen 80;
root /usr/share/nginx/www;
index index.php index.html index.htm;
server_name example.com;
location / {
try_files $uri $uri/ /index.html;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
# pass the PHP scripts to FastCGI server listening on the php-fpm socket
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

Categories