I think I did quite a good job on installing PDFlib on a system (Ubuntu 18.04) but something's not totally right yet. What I did so far:
Followed the instructions here: https://www.pdflib.com/fileadmin/pdflib/pdf/support/PDFlib-in-PHP-HowTo.pdf
Downloaded the correct php_pdflib.so file and placed it in the extension directory I got through phpinfo()
Added extension=php_pdflib.so in my php.ini
Ran a sudo systemctl restart apache2 to restart Apache and reload extensions
Checked with php -i | grep PDF whether the binary was loaded or not, result seems positive
PDFlib
PDFlib Support => enabled
PDFlib GmbH Binary-Version => 9.2.0
Now, when I run phpinfo(); from the web side through a file, there is no mention of PDFlib at all. When I run it through CLI, everything seems to be okay.
I also tried creating a new PDFlib() instance through CLI and web. CLI works, web doesn't.
Did I miss something in the install process?
I also tried creating a new PDFlib() instance through CLI and web. CLI works, web doesn't.
this is a typical situation. The PHP CLI and the PHP within the web server could have different configuration. So please check the extension_dir as well which the php.ini which was loaded in your web server phpinfo() output. Then you have do the the same configuration. Please check as well the PHP/Webserver log file for any error messages. Maybe it might be NTS/TS (threading) issue as well, but this will be mentioned in the error message.
Being not a good engineer today, I did several things at once, so I can't tell what exactly worked out in the end. Will write down my steps nevertheless, as it works now.
I double checked the configuration file paths and files through php -i and a phpinfo(); to see the differences between CLI and web frontend.
I removed the extension=php_pdflib from both php.ini files
I moved the php_pdflib.so from the extension directory one level up, it now lives in /usr/lib/php directly
I also renamed it to phplib.so (but that was more to break things on purpose and see what happens
I created a 30-pdflib.ini file in /etc/php/7.3/fpm/conf.d and wrote only extension=/usr/lib/php/pdflib.so in it
Added that line to /etc/php/7.3/cli/php.ini to see if there's a difference
I tried restarting Apache2 several times, but phpinfo() did not show any changes for the loaded configuration files or modules
I did a sudo reboot
Checked again and now PDFlib is loaded for CLI as well as for web
So, not sure if a hard reboot really fixed this, but it seems to me like that. Maybe this helps someone else.
Related
i'm trying to set the certain path for the php extension in my vscode (using linux)
i started installing the XAMPP
and after it..i tried to use the extension writing some php scripts(php extension INTELLISENSE and DEBUG), but the extension is not working properly and it's showing that error:
Cannot validate since /usr/bin/php is not a valid php executable. Use the setting 'php.validate.executablePath' to configure the PHP executable.
i tried to set it using que path which is provided by vscode documentation, but it's still no working.
Can anyone help me !! please!!!
I found a solution, typing in terminal
'whereis php'
that returns the absolute path for set it in the vscode extension
/opt/lampp/bin/php
Then, setting the path in the follow line
php.validate.executablePath: "/opt/lampp/bin/php",
So, I hope this solution is helping someone behind the screen.
Php path in windows
Typing in terminal
where php
And it'll gives the path as (in my case)
C:\xampp\php\php.exe
Just extending the answer by #Reinaldo Duguet with a ton of thanks to him !
If you are using Xampp, the PHP path can be found by running the local server and then typing localhost in the browser. This will open the Xampp dashboard. Click on phpinfo() and there you will get the exact path shown as
Configuration File (php.ini) Path = /opt/lampp/etc
Please note that the path may very as per the PHP installation in your system. So you may have to use the respective path shown with above ways.
Then, to let VSCode know this path, open settings in VSCode and search for "PHP debug" and click on the PHP > Debug:Executable Path setting
Add the following line at the first place after "{" telling VSCode where PHP is installed in the system.
"php.validate.executablePath": "/opt/lampp/etc",
If you are using Xampp, the PHP path can be found by running the local server and then typing
the correct version C:/xampp/php/php.exe
XAMPP isn't the best option for linux and i wouldn't recommend it.
Assuming this is not the problem, here is how to do :
find php executable
whereis php
Check your vscode installation. You want to make sure it's not using flatpak (it runs in a container and it would mess up everything)
go in vscode settings, search for php and set "php.debug.executablePath": "/your path/php"
If it still doesn't work, this might be a permission problem. Then :
copy the php executable in your user folder
sudo cp original_path/php /your_user_folder/php
add permissions
sudo chmod 777 /your_user_folder/php
If none of above worked, at this point, you may want to use a VM.
I just wanted to add a possibility here that ended up being my issue in case it helps someone else in the future. My issue was that I was using a Debian based distro and installed VSCode through the software app which relies on Snap apparently. Snap runs the programs in a sandbox and prevents them from seeing other locations on the computer. My solution was that I uninstalled the shop version and installed VScode manually via downloading directly from the website. After that, everything works as expected.
I have wamp install on my computer and IIS. All the websites are running well but then any command I type using php is not working :
php -v
php composer install
I would say it is the path variable (I am on windows) but the path is set correctly and it would generate an error of not finding php command. When I run those command I simply don't get any result.
What might be the problem, I am still searching but have not found any clue.
php -h
: return result with all the help information but php -a does nothing too.
After doing some research I found that this problem happens when I activate an extension by remove ; in php.ini whenever I leave php.ini without activating any extension everything works.
Check if the path contains php, also using the cd command, move to the location of the file and run the command you want to execute. If it works, you're sure the problem is the windows path.
I have fixed the issue. To see if the problem was with php.ini, I replaced the content of my php.ini with the php.ini-production file which made the php function well but almost all the extensions were desactivated.
As I was analysing I noticed wamp had many php extensions activated but in my php.ini residing under C:\wamp64\bin\php\php7.3.5 none of these extensions were activated following the path the file used by wamp I found it was using the phpForApache.ini via a link php.ini file inside C:\wamp64\bin\apache\apache2.4.39\bin
Since the wamp php configuration was working well, I just copied the content of that phpFOrApache.ini content in my php.ini after saving ... everything started working.
I have a bunch of PHP applications running on a remote webserver. For each of them I do var_dump(get_include_path()) and I get this: .:/usr/share/pear:/usr/share/php. Where does this value come from? I know that none of my apps deliberately change the include path. What I mean is there is nothing like set_include_path() or ini_set('include_path') in the code. There is also nothing like php_value include_path in the .htaccess files. To be 100% sure of it I am actually creating a brand new app with nothing more than a blank index.php (except for the var_dump) and I still get the same included path. I am pretty sure it is a global server configuration.
My server info is:
Linux version 2.6.9-89.0.20.ELxenU (Red Hat 3.4.6-11)
Is there any way to detect where this value is being set? I do have access to the server but I am no sys admin so my Linux capabilities are rather limited. I was hoping for some advice.
What I did so far is checked the php.ini and httpd.conf files. I know there might be more than one version of these files so to make sure I am looking in the right place:
For php.ini
I checked the output of phpinfo()
I ran this command $ php --ini. Besides the location of php.ini I found a bunch of other *.ini files parsed by PHP but none of them seem to do anything with paths
For httpd.conf
I ran this command /usr/sbin/httpd -V | grep HTTPD_ROOT
I ran this command /usr/sbin/httpd -V | grep SERVER_CONFIG_FILE
I am not sure if PEAR is installed or if it has anything to do with this. Running $ pear gives me Command not found.
Any help is greatly appreciated, thanks.
Take a look at
/usr/include/php5/main/build-defs.h:79:
#define PHP_INCLUDE_PATH ".:/usr/share/php:/usr/share/pear"
(Sorry, no Red Hat here, distro is Debian).
I have set up a MAMP server on my local computer.
The server runs fine, no problems, but I need to install the mcrypt extension on PHP as I need to install Laravel.
I've been following this tutorial:
http://coolestguidesontheplanet.com/install-mcrypt-php-mac-osx-10-9-mavericks-development-server/
I have an issue with the last step. When I create a new php.ini file using the following Terminal command, PHP refuses to run at all.
sudo cp /etc/php.ini.default /etc/php.ini
Basically with no php.ini file in the etc/ folder, the PHP works fine (PHP info pages load, sites using PHP run fine), but when it's in place, no PHP works and loading a PHP info page returns a blank white browser window.
Am I missing something?
OK I managed to figure out the issue, here's the solution for anyone stumbling on this in the future.
short_open_tags was disabled in the php.ini file. I simply enabled this, saved the file to the /etc folder and rebooted the Apache server and it works great now. I needed to modify the php.ini file again to add the mycrypt extension but now works great.
I have tried to install APC on my VPS and when I do php -m the APC entry appears in that list.
OS is centos
However, when I try this
print_r(get_loaded_extensions());
It is not listed in there. I have added
extensions=apc.so
in the php.ini in the root folder of the web app and in these two files
/usr/lib/php.ini
/usr/local/lib/php.ini
It is also not showing in the phpinfo page.
Any help is appreciated. I am
phpinfo() will tell you exactly what .ini files it's using. Then make sure that the .so files are actually in the appropriate extensions directory. You can't just drop them anywhere on your server and expect php to go looking for them. And of course, restart your server after you make any .ini changes