I am working on a leaflet map site with access to real time weather data. To avoid having to use SUID, because of it's security problems, I am using symbolic links from /var/www to my imagery data. These are simple png files, and this is working.
I then wanted to have real time data based on mouse position hovering over the image data. For this, I created an SQLite3 database with the actual values. At first, as a test, I manually put this database in the site root, and everything worked out perfectly. Unfortunately I cannot have that database in that location. I then did the exact same procedure used for my imagery data (which worked) with this database.
The process was:
In my site root:
ln -sf /path/to/db/ db
chmod 777 /path/to/db/data.db
The file is then read by a simple PHP program for querying:
<?php
$lat = floatval($_GET['lat']);
$lon = floatval($_GET['lon']);
$db = new SQLite3('db/sst.db'); # line 6
$results = $db->query("SELECT sst FROM current ORDER BY (($lat-lat)*($lat-lat) + ($lon-lon)*($lon-lon)) ASC LIMIT 1");
while ($row = $results->fetchArray()) {
echo $row['sst'];
}
?>
Unfortunately, now I am getting this error in the browser console:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
Inspecting /var/log/apache2/error.log file I get the following error:
PHP Fatal error: Uncaught exception 'Exception' with message 'Unable to open database:
unable to open database file' in /var/www/Mapea/sst.php:6\nStack trace:\n#0
/var/www/Mapea/sst.php(6): SQLite3->__construct('db/sst.db')\n#1 {main}\n thrown in
/var/www/Mapea/sst.php on line 6
Following CL's query on what permissions I had on /path, /path/to, and /path/to/db, I discovered that /path permissions were not correct.
After using the following command:
chmod 755 /path
My application is now working 100%.
In addition to the obvious rights on the full path to the file, one additional thing that may be an issue is SELinux.
If you still have permissions issues after double checking the file rights, this is the most likely culprit.
For example, on RHEL 8, the default security policy doesn't let Apache accessing a file on an NFS volume, and you'll need to pass the command
setsebool -P httpd_use_nfs 1
to (permanently with -P) authorize it.
Related
I'm trying to create my first SilverStripe website following this tutorial.
So far I have created my website and configured my .env page.
# DB credentials
SS_DATABASE_CLASS="MySQLDatabase"
SS_DATABASE_SERVER="localhost"
SS_DATABASE_USERNAME="root"
SS_DATABASE_PASSWORD=""
SS_DATABASE_NAME="SS_examples"
SS_ENVIRONMENT_TYPE="dev"
I'm not sure entirely how the database is created when creating a site. I checked my databases and I do not have one for it. I can make one manually but I wasn't sure if I should and list it under SS_DATABASE_NAME, or if it will auto-create the db.
I'm assuming this is why when I visit my local site localhost/SSexample/public I get an error saying "The website server has not been able to respond to your request".
Am I missing a step in setting up the site or should I manually create a db named SS_examples?
on a side note my apache server is set up with xampp and my SilverStripe project is in C:/xamp/htdocs.
Steps I took to create site:
Built site in C:\xampp\htdocs by running: composer create-project silverstripe/installer SSexample
Visited my project by going to localhost/SSexample/public
created .env file as listed above
ERROR LOGS
[2019-12-31 22:29:22] error-log.ERROR: Uncaught Exception SilverStripe\ORM\Connect\DatabaseException: "Couldn't run query: SELECT DISTINCT "SiteConfig"."ClassName", "SiteConfig"."LastEdited", "SiteConfig"."Created", "SiteConfig"."Title", "SiteConfig"."Tagline", "SiteConfig"."CanViewType", "SiteConfig"."CanEditType", "SiteConfig"."CanCreateTopLevelType", "SiteConfig"."ID", CASE WHEN "SiteConfig"."ClassName" IS NOT NULL THEN "SiteConfig"."ClassName" ELSE 'SilverStripe\\SiteConfig\\SiteConfig' END AS "RecordClassName" FROM "SiteConfig" LIMIT 1 Table 'ss_lessons.siteconfig' doesn't exist" at C:\xampp\htdocs\SSlessons\vendor\silverstripe\framework\src\ORM\Connect\DBConnector.php line 64 {"exception":"[object] (SilverStripe\\ORM\\Connect\\DatabaseException(code: 0): Couldn't run query:\n\nSELECT DISTINCT \"SiteConfig\".\"ClassName\", \"SiteConfig\".\"LastEdited\", \"SiteConfig\".\"Created\", \"SiteConfig\".\"Title\", \"SiteConfig\".\"Tagline\", \"SiteConfig\".\"CanViewType\", \"SiteConfig\".\"CanEditType\", \"SiteConfig\".\"CanCreateTopLevelType\", \"SiteConfig\".\"ID\", \n\t\t\tCASE WHEN \"SiteConfig\".\"ClassName\" IS NOT NULL THEN \"SiteConfig\".\"ClassName\"\n\t\t\tELSE 'SilverStripe\\\\SiteConfig\\\\SiteConfig' END AS \"RecordClassName\"\n\r\nFROM \"SiteConfig\"\n\r\nLIMIT 1\n\nTable 'ss_lessons.siteconfig' doesn't exist at C:\\xampp\\htdocs\\SSlessons\\vendor\\silverstripe\\framework\\src\\ORM\\Connect\\DBConnector.php:64)"} []
It seems that the installer at localhost/SSexample/public should allow you to configure your database connection settings (and create the database for you).
Getting The website server has not been able to respond to your request error means that you have a problem with webserver - is it running?
EDIT: The website server has not been able to respond to your request is actually Silverstripe's generic error 500 message.
EDIT2: one has to enable dev environment - by adding SS_ENVIRONMENT_TYPE="dev" to .env file and then access localhost/SSexample/public/dev/build to get database created and populated.
I am trying to take backup of my website`s files and database and upload it to google drive from my website via Google drive Api.
Followed instructions as per these links - backup files to google drive using php
https://www.matthewhipkin.co.uk/codelib/automatically-backing-up-your-web-server-files-to-googledrive-with-php/ and did the following -
downloaded the backupgoogledrive folder from https://github.com/hippy2094/backuptogoogledrive and uploaded that in my public_html/backup folder and renamed backuptogoogle.php as backup/index.php
I created the client ID, client secret and an authCode and put those in the setting.inc along with my MySQL username, password and database name. $homedir was put as /home/myuser/ and $sitedir was set to public_html/
Then, I ran in SSH - php /home/user/backup/index.php
This ran fine generating a json file and backup for files and database also was found in google drive.
Then, I set up cron job as follows -
5 0 * * 6 /usr/local/bin/php /home/myusername/public_html/backup/index.php
This should run the script at 00:05 on a saturday but it did NOT run or backup to google drive.
After that, I changed the cron to run every 15 minutes. I noticed that the files and database backups are going to home/myuser folder instead of google drive and the error_log in that folder is giving this error every 15 minutes -
Fatal error: Uncaught exception 'Google_AuthException' with message
'Error fetching OAuth2 access token, message: 'invalid_grant'' in
/home/myuser/public_html/backup/google-api-php-client/src/auth/Google_OAuth2.php:115
Stack trace:
#0
/home/myuser/public_html/backup/google-api-php-client/src/Google_Client.php(127):
Google_OAuth2->authenticate(Array, '4/SCxgUoxjnbe_0...')
#1
/home/myuser/public_html/backup/index.php(38):
Google_Client->authenticate('4/SCxgUoxjnbe_0...')
#2 {main} thrown in
/home/myuser/public_html/backup/google-api-php-client/src/auth/Google_OAuth2.php
on line 115`
Please note while registering at Google API at https://console.developers.google.com/apis I selected Other option in the Credentials Page and not Web Application because my aim is only to take backup for my site. Also, when I selected the Web Application option and generated the client ID and secret and tried to generate the authCode via url generated in SSH, it would give an error with the SSH generated url. So, the solutions for invalid grant which are mentioned in other posts do not work for me as I do not get option for setting call back url.
Please tell what I am doing wrong. Why I am able to run the script successfully manually and not via cron ? When I am running the script manually running in SSH. Only problem happens when cron runs.
Thanks in advance.
Found the solutions as follows -
Put in the file index.php this code -
chdir('/home/user/backup');
Then the cron backed - up the file to google drive properly. So, the problem was with the cron path.
I need to upload my symfony 3 project online, but I have only access to ftp. So I did all necessary steps I found:
composer update
Clear the cache for production: php app/console cache:clear --env=prod
Upload all app folder on server
After I open my website I got the following error:
Fatal error: require(): Failed opening required
'/nfsmnt/hosting2_1/a/8/a87b3594-7cfe-459e-ad62-286d2dba2c54/zorbfutbal.sk/web/var..\vendor\symfony\symfony\src\Symfony\Component\ClassLoader\ApcClassLoader.php'
(include_path='.:/usr/php56/lib/php') in
/nfsmnt/hosting2_1/a/8/a87b3594-7cfe-459e-ad62-286d2dba2c54/zorbfutbal.sk/web/var/bootstrap.php.cache on line 1780
I checked the file and I have it there and also set all permissions.
What is confusing me is that path from error before my actual domain name.
"/nfsmnt/hosting2_1/a/8/a87b3594-7cfe-459e-ad62-286d2dba2c54/"
I dont know where it comed from and how to fix it.
Any idea? Thanks
You are absolutely sure you set the file permissions correctly like indicated here:
http://symfony.com/doc/current/setup/file_permissions.html#using-acl-on-a-system-that-supports-setfacl-linux-bsd
The message you posted seems to point to something like that.
Also run:
php bin/symfony_requirements
just to check that you've met all the other requirements.
Friends need help.
After a system failure on the host there was such a mistake.
Fatal error: unknown class App\Entry in /home/uzbek/uzbek.rf/www/app/Vacancy.php on line 25
error: inflate: data stream error (unknown comperssion method)
fatal: loose object 130dc6556560992b5a0f13992d5f0d716867c6ba (stored in .git/objects/13/0dc6556560992b5a0f13992d5f0d716867c6ba) is corrupt
fatal: The remote end hung up unexpectedly
The site gives you a white screen , what to do?
I understand that this is a problem with Git, but I'm with him, unfortunately , bad. :(
If you have a "good" copy of the repository
First of all you need to know if you have a backup somewhere (another copy of the repository).
If you do simply grab the last good copy and you are good to go.
If you don not have a "good" copy of the repository
If will be hard to "fix" the repository.
First of all try to find out which file is broken:
git show 0dc6556560992b5a0f13992d5f0d716867c6ba
or:
git cat-file -p 0dc6556560992b5a0f13992d5f0d716867c6ba
Once you know which file is it try to recover it from the history of your editor.
You can also run :
git fsck --full
to see if you have some other "broken" objects.
Following a Doctrine / CodeIgniter tutorial
Everything is good up until the very end when I try to insert data through my controller
$user = new Entities\User;
$user->setFirstName('Joel');
$this->doctrine->em->persist($user);
I get:
Fatal error: Uncaught exception 'Doctrine\ORM\Proxy\ProxyException' with message 'You must configure a proxy directory. See docs for details' in C:\wamp\www\ci\application\libraries\Doctrine\ORM\Proxy\ProxyException.php on line 33
( ! ) Doctrine\ORM\Proxy\ProxyException: You must configure a proxy directory. See docs for details in C:\wamp\www\ci\application\libraries\Doctrine\ORM\Proxy\ProxyException.php on line 33
This might be due to a difference in the tutorial version of Doctrine vs. the current version as noted here, but the tutorial version is no longer supported by Doctrine and I'm not sure what to change.
Did you set the proxy directory by doing somewhere :
// set up proxy configuration
$config->setProxyDir(APPPATH.'models/Proxies');
$config->setProxyNamespace('Proxies');
You have a problem with the setting of the proxy dir.
Check that the proxy directory is well defined and that the directory exists.
Hope this helps.
It looks like permission trouble:
To fix, i did
sudo chown -R www-data:www-data .