I am using Symfony 2. I have gone through all of the installation with configuring parameters.yml and running composer install and following the guide on http://symfony.com/doc/current/cookbook/deployment-tools.html
I have only a blank page when I enter my adress online, and the log files in app/logs is not written to. I have run the command sudo chgrp apache app/logs and chmod g+w /app/logs to make the folder writable but no success
under config_prod.yml:
monolog:
handlers:
main:
type: fingers_crossed
action_level: warning
handler: nested
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
A white page usually means that an error occurred before the Symfony environment (which includes the logger) is even loaded. That's probably why there's nothing written to the log. If Symfony were running, you would probably see the default 'error 500' message.
So what you should be actually looking for is a PHP error. Production environments offen suppress error messages by disabling display_errors in their php.ini. You could either enable this temporarily in order to see the errors directly on the erroneous page or -- even better -- log in the error log of your web server. PHP error messages should appear there as well.
Related
I have setup Mapbender on Ubuntu 20.04 on a VirutalBox machine. PostgreSQL, PostGIS and Geoserver are all installed on the VM. I created a map application and added a search router function (followed the instructions in the documentation). The search is working like a charm in the dev environment but in the prod, it is not. In the dev environment, it is giving a result and hovering the mouse over the result highlights the feature and clicking on the result moves and zooms the map to the feature.
In the prod environment, nothing seems to happen when typing the search string and pressing search. The devtools report an internal server error 500, which is not very helpful. Although, in Firefox, the devtools show Referrer policy "strict-origin-when-cross-origin" in red.
I have already modified the Postgres configuration files to Listeners = * and host 0.0.0.0 to make sure it is not a database access problem.
Host Machine: Windows 10 Pro 20H2
Guest Machine: Ubuntu 20.04
Mapbender 3.2.6
Database Postgresql 12.8 with Postgis 3.0
WMS Served through Geoserver
PHP7.2
While I am not sure I provided all the information to properly diagnose the problem, any indication on what to do to investigate this issue and solve it are appreciated.
Update:
I modified php.ini to enable error logging by setting the following switches:
error_reporting = E_ALL
display_errors = Off
log_errors = On
ignore_repeated_errors = On
ignore_repeated_source = Off
error_log = /var/log/apache2/php_errors.log
But no errors are being logged so far and php_errors.log file is not being created. Even creating the file is not having any effect on the logging. Am not sure what I am missing. I want to reiterate though that the search is working in the dev environment so can't see how it can be an authentication issue. I am trying the search in the prod environment on a browser from within the VM, so using localhost to access the application.
On dev tools I get the following:
jquery.min.js:formatted:4210 POST`
http://localhost/mapbender1/application/bh_admin/element/337/0-ed10fcc5-57e7-1f83-8a76-c32030225b85/search 500 (Internal Server Error)
send # jquery.min.js:formatted:4210
ajax # jquery.min.js:formatted:3992
n.<computed> # jquery.min.js:formatted:4044
getJSON # jquery.min.js:formatted:4033
_search # js:14187
(anonymous) # jquery-ui.min.js:6
(anonymous) # js:13976
dispatch # jquery.min.js:formatted:2119
r.handle # jquery.min.js:formatted:1998
When clicking on jquery.min.js:4210, the following line is highlighted in the file:
g.send(b.hasContent && b.data || null),
Update 2
Following #IonBazan suggestion, I found the prod.log file, albeit in a different folder, and the error indicates that the database service cannot be found. The log file was in:
var/www/mapbender1/app/logs
And this is the message in the log file:
request.CRITICAL: Uncaught PHP Exception
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException:
"You have requested a non-existent service
"doctrine.dbal.mobh_data_connection". Did you mean this:
"doctrine.dbal.default_connection"?" at
/var/www/mapbender1/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php
line 348 {"exception":"[object]
(Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException(code:
0): You have requested a non-existent service
"doctrine.dbal.mobh_data_connection". Did you mean this:
"doctrine.dbal.default_connection"? at
/var/www/mapbender1/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php:348)"}
[]
As I have mentioned before, the dev app is capable of accessing the service. This means, I suppose, that the DB connection parameters are correct in the parameters.yml and config.yml files. So I have a feeling there might be some cached item that needs updating, especially that Mapbender documentation mentions this:
The cache-mechanism of the development-environment behaves
differently: Not all files are cached, thus code changes are directly
visible. Therefore the usage of the app_dev.php is always slower than
the production-environment.
And
The directory app/cache contains the cache-files. It contains
directories for each environment (prod and dev). But the mechanism of
the dev-cache, as described before, behaves differently.
If changes of the Mapbender interface or the code are made, the
cache-directory (app/cache) has to be cleared to see the changes in
the application.
So this turned out to be a folder permission issue. The reason why the dev environment was working was because the dev caches less components than the prod, which makes changes made to configuration files like parameters.yml and config.yml reflected in the dev and not in the prod. At some point during the setup and configuration process, the ownership of the cache/prod folder went to root which left the www-data user without the proper access rights to the folder. So bottom line, the prod cache was not being updated which made the database connection service invisible to the prod environment, although the parameters.yml and config.yml had the correct settings.
So what I did was the following, noting that there are steps I performed which might have been unnecessary, but at this stage I will not be looking into finding out which step was not needed.
First step, stop the running services (Apache and PHP server):
sudo app/console server:stop
sudo service apache2 stop
Clear the prod cache:
sudo app/console cache:clear --env=prod --no-debug
I also used the cache:clear command with the no-warmup switch which essentially leaves you with an almost empty cache folder. I issued this command since the previous one left some files in the folder.
sudo app/console cache:clear --env=prod --no-warmup
Install the assets:
sudo app/console assets:install web --env=prod
Give www-data user the proper folder permissions:
sudo chown -R www-data:www-data /var/www/mapbender/app/cache
sudo chmod -R ug+w /var/www/mapbender/app/cache
Start Apache and PHP server:
sudo service apache2 start
sudo app/console server:start
Note that app/console needs to be executed from the folder /var/www/mapbender
Like I mentioned earlier, there might be unnecessary steps but this is more or less what I did and now the app is working as expected.
Disclaimer: I am not a developer and the information presented here was assembled from more than one source, including the Mapbender documentation.
I'm running php7.2-fpm with apache 2.4.29 on Ubuntu Server 18.04 LTS.
I'm unable to set a specific php error log file per host (as I normally do with php with apache pre-fork).
On apache host conf file I set my custom error log path:
ErrorLog /var/www/server_logs/myhost_error.log
LogLevel warn
But that file is empty
Looking at /etc/php/7.2/fpm/php-fpm.conf I saw that error log file is set to /var/log/php7.2-fpm.log and error level is enable and set to notice.
On my php project base path I put .user.ini containing
display_errors=on
display_startup_errors=on
error_reporting=E_ALL
html_errors=on
On my php project I generate a WARNING: I see it on screen but never get logged in my apache custom log error file nor in /var/log/php7.2-fpm.log
In /var/log/php7.2-fpm.log I only see
[17-Oct-2019 16:01:44] NOTICE: fpm is running, pid 25328
[17-Oct-2019 16:01:44] NOTICE: ready to handle connections
[17-Oct-2019 16:01:44] NOTICE: systemd monitor interval set to 10000ms
but no errors logged!
I cannot understand what I missed!
Anyone could help me please?
I am using the image richarvey/nginx-php-fpm:latest (1.5.2) and I started a container based on this image and executed /bin/bash inside.
There I :
have installed composer
created a new symfony4 project using composer create-project symfony/website-skeleton my-project
have edited my-project/config/packages/dev/monolog.yaml to set :
monolog:
handlers:
main:
type: stream
path: 'php://stderr'
level: debug
channels: ["!event"]
got the IP of my docker image using docker inspect
and dump my container logs using docker logs -f <my container>
When I load http://<my container ip>/my-project/public, I don't see the symfony debug logs in my container logs output.
Note : I see the nginx logs.
One of my coworker found the solution and the docker image maintainer implemented it :
https://gitlab.com/ric_harvey/nginx-php-fpm/commit/51bbf4e04f61873dfeae69e943fcdf0a900f2589#8ad4b94617a62f898119a66a878f8035b8605d13
As php-fpm is run in nodaemonized mode, you need to set the --force-stderr flag which "Force output to stderr in nodaemonize even if stderr is not a TTY."
https://www.gsp.com/cgi-bin/man.cgi?section=8&topic=php-fpm
I've uploaded the Yii2 advanced site on google cloud server.
I've created instance with Centos 7
Getting error :
The directory is not writable by the Web process | frontend/web/assets
I've also set the permission 777 but still not working
how can I resolve the error.
Not sure if disabling SELINUX is the answer as I've read too many warnings about that.
Found the following solution somewhere (my apologies to the original poster).
Just execute the following once you SSH into your instance:
sudo chcon -v --type=httpd_sys_script_rw_t frontend/web/assets
Step to follow to resolve the issue - Reference link
Login with SSH from your google cloud instance.
In SSH login as root user
[yourgmailname#instance-name ~]$ su // enter su for login as root
Password: // enter your password
Go to var dirctory
[root#instance-name var]# getenforce
Enforcing // output
If you see the Enforcing
Go to selinux
[root#instance-name var]# vi /etc/selinux/config
You will see the below code
This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
Change the SELINUX=enforcing to SELINUX=disabled and save the file
Reboot the server
[root#instance-name var]# reboot
On a Ubuntu web server [LAMP], I'm trying to get PHP errors to write into a php_error file, but no matter what I do, they keep going to the apache log.
Here's what I have tried/done:
Edited the php.ini file:
error_reporting = E_ALL | E_STRICT
display_error = Off
log_errors = On
error_log = /var/log/php_errors.log
Restarted Apache
Checked the phpinfo() output to verify that the changes I made to the php.ini file took -- they did.
After verifying that the errors were still going to the Apache log, I physically created the php_errors.log and tried again. Still going to the Apache log!
Rebooted the web server! Still...!
Anybody have a solution?
Check the directory permissions for /var/log. Ensure that the user your Web service is running as has write permissions to that folder. Alternatively, create a subfolder (/var/log/phplogs?) and assign explicit permissions on that for the user in question then change the error_log value to be a file in that folder
It had to do with ownership. One or the other has worked [for reasons that are not clear to me]:
chown www-data:www-data /var/log/php_error.log
chown same-user-as-www-home:same-user-as-web-home /var/log/php_error.log
Also, the following has made a difference:
chmod 664 /var/log/php_error.log
[as opposed to chmod 644...again for reasons that are not clear to me]
For the record, Ubuntu uses AppArmor and it limits what Apache does.
Additionally, to change the permissions to the file and editing the php.ini file, you must do the next steps:
Go to the next file
/etc/apparmor.d/abstractions
Edit this file
apache2-common
Add the next line
/var/log/php_errors.log rw,
where rw means the process could read and write this file
or you could also do:
sudo nano /etc/apparmor.d/abstractions/apache2-common
And finally, reload the configuration of apparmor
systemctl reload apparmor
Note: Centos/Redhat/Oracle Linux uses SELinux and it requires the same step but the configuration is different.