[UPDATE]
edited artisan file like this
ini_set('display_errors',1);
error_reporting(-1);
and I got this error
Parse error: syntax error, unexpected '?' in /home/u635130117/domains/example.com/public_html/laravel/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 500
Here's the code
if (isset($arguments[1]) && is_string($arguments[1])) {
return $factory->of($arguments[0], $arguments[1])->times($arguments[2] ?? null); //line 500
} elseif (isset($arguments[1])) {
return $factory->of($arguments[0])->times($arguments[1]);
}
I have connected to the shared hosting using SSH but can't run any artisan command like clearing cache or listing artisan commands I get nothing at all no output. I tested creating a new command and it's not created too.
The parse error occurs if the php version is to low. So we discovered there are more than one versions of php installed on the server after the execution of php -v returned php version 5.6.40.
Finally in the phpinfo were the path of the php 7 version which is also being used by the webserver. This was /opt/alt/php72/usr/bin/php.
Commands can now executed by using /opt/alt/php72/usr/bin/php like /opt/alt/php72/usr/bin/php artisan key:generate.
You can also create an alias like php7 or just php for this. It's described here.
Related
Warning: ini_set(): Session save handler "redis" cannot be found on my page where I have use the code as shown below
ini_set('session.save_handler', 'redis');
This code works fine if the PHP version is 7.4 but when I upgraded PHP to PHP8 or PHP8.1 it stops working and gives me a warning "Warning: ini_set(): Session save handler "redis" cannot be found"
Also when I run the phpinfo() I do not find any PHP extension for Redis which is visible in case of PHP7.4
It looks like redis extension isn't available at your php modules. Check by using this command:
php -m | grep redis
So if it's empty, you need to install and configure it properly:
Visit this link to check how to install php redis extension.
Open your php.ini file (php --ini to check location)
Check for extension_dir property and make sure it points to correct extensions directory.
Add this code below - extension=redis.so
Restart your PHP-FPM service
Now try it once more:
php -m | grep redis
Should return redis now. Now ini_set command should work!
I am receiving below error while using put command and uploading file on snowflake.
It is Error 400
It works for other files but fails for only one file with below error.
Error link - https://sfc-uk-ds1-customer-stage.s3.amazonaws.com/drko-s-ukss0127/tables/2323577421858/FACT_RFM_SEGMENTATION.csv?partNumber=83&uploadId=PosKnuUecwKdJdFOQopotAdcwdk2IJ2wtgwsrvbDD_mSas7L.vD.7Bz8bXX1M_QAZKyVWiaxdf5I6ime9FWSwQHI0BpV17WGVRgfpMSd5_hhm92jNGI3a2JrRiTvsblz
Snowflake Put command -
user_details#XSMALL_WHSE#DEV_DB.FACT>put file://D:\snowflake\lab_db_csv_files\file_name.csv #"FACT".%"table_name" auto_compress=False;
I tried with both Auto_compress False and True. but it is not working in any case.
I remember one of the versions had an issue with the PUT command.
Check your current version by running:
snowsql --version
Then try to use different versions:
snowsql --version 1.2.18
Above command will launch SnowSQL using version 1.2.18, then test again.
I am getting syntax errors when I try to check the exit status of a bash script using monit's "check program". If I run the bash script manually, it doesn't error. But if I do monit reload with my monit check program in the config, monit gives me errors.
Here's my current monit .conf file --
check program myscript with path "/etc/monit.d/script_to_run.sh"
if status != 0 then alert
If I change it to this to make sure monit uses bash to parse the file...
check program myscript with path "/usr/bash /etc/monit.d/script_to_run.sh"
if status != 0 then alert
Then I get this error
Warning: Program does not exist: '"/bin/bash /etc/monit.d/script_to_run.sh"'
Even a test script results in errors --
If I have this in script_to_run.sh:
#!/bin/bash
exit 0
Monit will complain
Error: syntax error 'exit'
If I have this in script_to_run.sh:
#!/bin/bash
echo "hello"
Monit will complain
Error: syntax error 'echo'
For reference -- I have monit 5.4, have followed the "check program" example in the man monit doc, and am able to configure/use monit "check process..." just fine on the same server.
ok, fixed. for future reference for anyone reading this -- never put .sh files in /etc/monit.d/
that was the problem. i moved the .sh file to a different directory and everything is fine now.
I am using Amazon AMI on AWS cloud. Unfortunately, by default Amazon is shipping older version of Monit - 5.2.5
https://forums.aws.amazon.com/thread.jspa?threadID=215645
They suggest to install version of monit otherwise. Amazon forum gave this workaround:
sudo yum install -y https://kojipkgs.fedoraproject.org//packages/monit/5.14/1.el6/x86_64/monit-5.14-1.el6.x86_64.rpm
I want to use s3cmd from my PHP script. Everything is working from shell but same not working from my PHP script.
shell_exec('s3cmd --config=/root/s3cmd.conf ls');
this is not working, and then i gave full path to my s3cmd installation
shell_exec('/usr/sbin/s3cmd --config=/root/s3cmd.conf ls');
Not working in PHP script but the same is working in command,
The PHP file which is calling the shell_exec is in webroot.
Might be the problem that s3cmd is configured as a root user and i am running from PHP which is www-data. if this is the problem how can i create config file for www-data.
Help me what i am doing wrong.
Thanks
EDIT
I am using S3cmd. To run commands in my cron script. cron Script is a PHP script. The user running the cron is web11 and the s3cmd is configured using the root user.
so when i run s3cmd using shell_exec() in my PHP script it fails. But when i run in shell it works fine.
s3cmd ls
This works fine. as i am login using root user.
i tried to run it using runuser command
runuser -l root -c "s3cmd ls"
This works fine and displays list of buckets. But when i run using
runuser -l root -c "s3cmd ls"
This does not work. I tried by giving full path of the s3cmd
/usr/bin/s3cmd ls
this works in shell but not in my PHP script.
I changed permissions 777 for the php script and made root the owner of that user. but still does not work.
How can i run s3cmd from PHP script. ? i am on amazon Ec2 Instance.
Why not use the AWS SDK for PHP? You can have the same functionality using the S3Client.listObjects() method
shell_exec('s3cmd --config=/root/s3cmd.conf ls');
What might be missing here is the target of the S3 command "ls" ?!
It's working fine in PHP scripts like this :
exec("/usr/bin/s3cmd --config=.s3cfg info s3://YOUR-BUCKET/YOUR-FILE 2> /dev/null", $s3output, $s3return);
// switch due to return code (of shell !)
if($s3return == "0"){
echo "my file exists";
}
else {
echo "Error Code : " . $s3return;
}
This asumes, you ran "s3cmd --configure" successfully.
I installed memcache in the following way:
1) yum install memcached
2) yum install php-pecl-memcached
3) Also enabled the 'memcached.so' in php.ini
I tested the memcached in the follwing way:
$mc = new Memcache;
$mc->addServer('localhost', 11211);
echo "Server's version: " . $mc->getVersion() ;
But it generates the following error:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/memcached.so' - /usr/lib64/php/modules/memcached.so: undefined symbol: php_json_encode in Unknown on line 0
PHP Fatal error: Class 'Memcache' not found in /root/memcacheTest.php on line 2
Thank u.
I don't know PHP well (or at all), but from the error message I'll hazzard a guess that you do not have the PHP JSON extension installed, which is apparently needed by the memchached extension.
Apparently, the JSON extension has been in PHP since version 5.2.0, therefore:
You have an older version and you need to upgrade or install the JSON extension yourself
or
Your operating system distributor supplies the PHP JSON extension in a different package that you have not installed.
There is of course the possibility of a misconfiguration, but I think it's slightly less likely.
This showed memcached.so didn't loaded successfully.
Error shows the reason: json.so should be load before memcached.so
Please use php -m | grep memcached to check whether memcached.so is loaded successfully.
If show memcached, this mean it succeeded.
If show like PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/memcached.so' - /usr/lib64/php/modules/memcached.so: undefined symbol: php_json_decode_ex in Unknown on line 0
Here is the solusion:
e.g your php.ini is /etc/php.ini, your php.d is /etc/php.d/
Solution 1
comment 'memcached.so' in php.ini
vim /etc/php.d/memcached.ini
add extension=memcached.so in /memcached.ini
php -m | grep memcached check whether memcached is succeed loaded
Solution 2
rm /etc/php.d/json.ini
add extension=json.so in php.in before extension=memcached.so
php -m | grep memcached check whether memcached is succeed loaded
Can you check and double check user permissions? Additionally, my experience with PHP is that the distribution repository versions of PHP aren't very good. I solved those symbol errors by compiling PHP from the ground up. But that's a very radical and time-consuming solution.
http://pecl.php.net/bugs/bug.php?id=17574&edit=1
Just make sure that extension=json.so is specified BEFORE
extension=memcached.so.
I had placed extension=memcached.so in php.ini, and extension=json.so
was specified in /etc/php.d/json.ini, that is parsed AFTER php.ini.
That is why PHP can't find php_json_encode() at the point of loading
memcached.so.
Also, check that the permissions on memcached.so are the same as the other extensions
Try to install the version 2.0. It helped for me.
yum -y install gcc-c++
wget http://launchpad.net/libmemcached/1.0/0.50/+download/libmemcached-0.50.tar.gz
tar xzf libmemcached-0.50.tar.gz
cd libmemcached-0.50
./configure
make
make install
wget http://pecl.php.net/get/memcached-2.0.0b2.tgz
pecl install memcached-2.0.0b2.tgz
echo 'extension=memcached.so' > /etc/php.d/memcached.ini
service php-fpm restart
cd ..
rm -r libmemcached-0.50*
rm -r memcached-