I an creating a PWA app and its working fine, but when I tried to upload on server I stuck on error. On windows local server, everything is fine even notifications, and I dont know much putty/linux commands.
check here my phpinfo file.
I am tring to upload to amazon ec2 server. I installed apache, php, ssl and other required things. And its working file except notifications.
When I call my notification file, I got 503 response. I installed composer, installed everything. I used this github library.
As I understand, I stuck on gmp extension, When I open phpinfo() I didnt see gmp over there. I installed gmp using sudo yum install php-gmp and also I see a file in php.d named as 20-gmp.ini and it included extension=gmp. Also restarted apache server using sudo apachectl stop, sudo apachectl start.
But still I am getting error. And I coudnt see gmp in phpinfo().
notificationb.php
<?php
require __DIR__ . '/vendor/autoload.php';
use Minishlink\WebPush\WebPush;
use Minishlink\WebPush\Subscription;
$subscription = Subscription::create(json_decode(file_get_contents('php://input'), true));
print_r($subscription);
$auth = array(
'VAPID' => array(
'subject' => 'https://github.com/Minishlink/web-push-php-example/',
'publicKey' => file_get_contents(__DIR__ . '/scripts/keys/public_key.txt'), // don't forget that your public key also lives in app.js
'privateKey' => file_get_contents(__DIR__ . '/scripts/keys/private_key.txt'), // in the real world, this would be in a secret file
),
);
$webPush = new WebPush($auth);
$res = $webPush->sendNotification(
$subscription,
"Welcome to Kaya. You can book Appointments and many more."
);
foreach ($webPush->flush() as $report) {
$endpoint = $report->getRequest()->getUri()->__toString();
if ($report->isSuccess()) {
echo "[v] Message sent successfully for subscription {$endpoint}.";
} else {
echo "[x] Message failed to sent for subscription {$endpoint}: {$report->getReason()}";
}
}
?>
If you need any thing, let me know in command. I will update here.
Edit 1: Also I tried to add gmp extension in php.ini in /etc/php.ini but still not added.
I think I am getting error on $subscription = Subscription::create(json_decode(file_get_contents('php://input'), true));
I know I am commenting my own question, As I was searching this answer for 3-4 days I think I should share this info with everyone.
The issue is, In linux, PHP have different-different configuration files. The main configuration file is php.ini. And it include other extensions after loading this file and override mail file. These additional configuration are located in /etc/php.d/ (in my case, which is common for mostly).
So just restarting apache server in not enough. We need to also restart php-fpm.
To restart php-fpm: sudo service php-fpm restart
And then restart apache: sudo apachectn restart
You can check more here
To apply change in php.ini, you need to restart apache server and also restart php.
sudo service php-fpm restart
sudo apachectn restart
Also sometime it took time to apply changes to server.
Related
I have a local WordPress installation running at: https://catalogue3.test.
Note that all .test domains should resolve to localhost, as I use Laravel valet. When I execute the following code in my Laravel project however, I get an exception as shown below.
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', "https://catalogue3.test", ['verify' => false]);
ConnectException
cURL error 6: Could not resolve: catalogue3.test (Domain name not
found) (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
When I run the command below in the terminal, the WordPress page is displayed.
curl https://catalogue3.test/ --insecure
Add
ip catalogue3.test
to your /etc/hosts file
I tried to add the domain to hosts and I tried to change dns in network settings, this answer is what worked for me.
Quick way to check if this is your problem is to do: curl --version
and php --ri curl
The versions should match. If they don't it's probably because brew
has installed curl-openssl. This can be removed by doing:
brew uninstall curl-openssl --ignore-dependencies
Maybe there's a way to configure the installed curl-openssl properly -
I've not investigated this yet.
I solved this adding catalogue3.test to /etc/hosts, even if I was using DnsMasq, and in theory, I wouldn't need it.
In my case (on macos) I had to add 127.0.0.1 as the first DNS server option in my WiFi settings.
Some useful info here too: https://github.com/laravel/valet/issues/736
I have this weird issue that was not happening before.
I am running a Ubuntu Box on Digital Ocean that uses NGINX and PHP-FPM. I also use PHP Deployer to deploy code between Stage and Prod.
Deployer uses symlinks to tell the server where the files are in this case /var/www/mydommain.com/current would be the symlink that points to /var/www/mydomain.com/releases/26.
That is all good and if I do cd /var/www/mydomain.com/current it will change to releases/26. The website however is still pointing to releases/25. I have restarted NGINX and PHP-FPM multiple time without success.
Why is NGINX still pointing to releases/25 when the symlink actually points to releases/26? I can't get it.
In NGINX config for this domain I have root /var/www/mydomain.com/current
I know this is an 8 months old question, but this might help others:
I ran into the same issue and noticed that if I edit my index file (index.php) of the previous release, the symlink is magically refreshed.
After deploying, I simply run:
touch /path/to/releases/[previous_release_number]/public_html/index.php
...to update the file's modification timestamp.
I ended up including it in my deploy:symlink task like this:
task('deploy:symlink', function () {
run("cd {{deploy_path}} && ln -sfn {{release_path}}/public_html ./public_html");
run("touch {{previous_release}}/public_html/index.php");
})->desc('Linking latest version to public_html'); // <= Added this
Hope this helps.
Regards, Wouter
This can be due to $document_root in your Nginx configuration being cached until you do sudo service php5.6-fpm restart.
You can replace $document_root with $realpath_root to avoid the caching.
This website helped me:
https://joshtronic.com/2019/07/29/symlinks-with-nginx-and-php-fpm/
After running the httpd by using the command service httpd restart, but I am unable to run the project locally. While running the project, it displayed the PHP code. Can you please help me to solve the issue? This is the PHP code:
<?php// allow testing from the upgrade page before the site is upgraded.if (isset($_GET['__testing_rewrite'])) {
if (isset($_GET['__elgg_uri']) && false !== strpos($_GET['__elgg_uri'], '__testing_rewrite')) {
echo "success";
}
exit;}require_once(dirname(__FILE__) . "/engine/start.php");$router = _elgg_services()->router;$request = _elgg_services()->request;if (!$router->route($request)) {
forward('', '404');}
Check the HTTP config and error log. The PHP module is not loaded any longer, or the .php extension (or whatever extension you've used) isn't associated with the PHP module any longer.
Until you give us more details, that's all we can answer with.
I am installing vtiger,
when i open the index page,
i got this error:
Fatal error: Call to a member function Execute() on null in C:\xampp\htdocs\vtigercrm\include\database\PearDatabase.php on line 357
i opened the PearDatabase.php file, and I found this:
if($this->avoidPreparedSql || empty($params)) {
$sql = $this->convert2Sql($sql, $params);
$result = $this->database->Execute($sql);
} else {
$result = $this->database->Execute($sql, $params);
}
the line 357 is:
$result = $this->database->Execute($sql);
If you have installed vtiger once locally, you have to clean cookies in your brower of your local vtiger domain.
That should fix your problem, what a amazing bug it is!
Make sure you have installed all the pre-requisites:
Pre-requisites from here:
Apache 2.1+
MySQL 5.1+ (default storage engine = InnoDB)
PHP 5.2+, 5.3
php-imap
php-curl
php-xml
max_memory (min. 256MB)
max_execution_time (min. 60 seconds)
error_reporting (E_ALL & ~E_NOTICE & ~E_DEPRECATED)
Hardware: 4 GB RAM, 250 GB Disk (for file attachments)
The error is suggesting that it can't work out what to do with the back end database.
You will receive this error when installing vTiger if your session_save_path() is not writable by your web server user.
In my case, my 'session_save_path' was /var/lib/php/7.1/session and was owned by root. I am using Nginx so I executed the following command to resolve my issue:
sudo chown -R nginx:nginx /var/lib/php/7.1/session
If you are using Apache, you would execute the following command to resolve your issue:
sudo chown -R www-data:www-data /var/lib/php/7.1/session
The information entered into the vTiger wizard is saved to $_SESSION as you navigate through the installation steps.
When the 'session_save_path' is owned by root rather than the web server user, the session data is not saved between function Step5() and function Step6() in modules/Install/views/Index.php. So when the config.inc.php file is created by the wizard, all the configuration data you entered into the form is not written to config.inc.php since your data was not saved in $_SESSION between the requests. This can be fixed by changing the permissions on your 'session_save_path' to be writable by the web server user.
You can find your session.save_path in your php.ini file or your www.conf file if you are using php-fpm:
/etc/php-fpm-7.1.d/www.conf:php_value[session.save_path] = /var/lib/php/7.1/session
This unhelpful error is actually because your database connection is unsuccessful in file include/database/PearDatabase.php in function connect() since all the database variables are empty.
Hope this helps.
Apparently my last question was too vague even though it was pretty straightforward.
I'm trying to use Embed.ly's API to embed some stuff, for example, some of the stuff shown here.
https://github.com/embedly/embedly-php/blob/master/README.rst
I have the entire Embedly.php source file in my working directory.
However, when I have the following in my header file:
<?php
//require_once('Embedly/src/Embedly/Embedly.php'); // if using pear
require_once('./Embedly.php'); // if using source
$api = new Embedly\Embedly(array('user_agent' => 'Mozilla/5.0 (compatible; mytestapp/1.0)'));
?>
And the following in my main page:
<?php
$objs = $api->oembed(array(
'urls' => array(
'http://www.youtube.com/watch?v=sPbJ4Z5D-n4&feature=topvideos',
'http://twitpic.com/3yr7hk'
)
));
?>
I get the following error:
( ! ) Fatal error: Call to undefined function Embedly\curl_init() in C:\wamp\www\Embedly.php on line 259
It looks like curl isn't installed or enabled.
If you're on you own server (assuming something similar to ubuntu server), a simple sudo apt-get install php5-curl should solve it.
Otherwise, you may have to contact your hosting provider.
Got this from a forum and it seems legit:
Close WAMP (if running)
Navigate to WAMP\bin\php(your version of php)\
Edit php.ini
Search for curl, uncomment extension=php_curl.dll
Navigate to WAMP\bin\Apache(your version of apache)\bin\
Edit php.ini
Search for curl, uncomment the line/remove the #, extension=php_curl.dll
Save the files
Restart WAMP