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.
I am trying to setup a basic apache 2 webserver just for testing purposes. I have apache 2 installed on Ubuntu 11.10. I can access the root directory on the webserver just fine by going to "localhost" in my browser. This is all located in the default directory: /var/www. However, the problem starts whenever I try to access the subdirectories of my webserver. So, for example if I goto "localhost/phpproject/", which has an index.php file listed in it (and I did test to make sure PHP was working correctly), all it seems to want to do in my browser is attempt to download a file when I type in the address instead of actually displaying anything.
I even tried to give full permissions on the subdirectory to make sure it wasn't just a permissions-related problem. Any ideas?
First of all, you shouldn't be keeping your development files in /var/www folder. Configure your apache to keep your web files within your home directory. In doing so, you don't have to have sudo privilege to edit files in /var/www. If you want to follow my setup, create a directory called www in your home folder /home/yourname/www. Look at my config of /etc/apache2/sites-enabled/000-default
http://pastebin.com/3gcE59Lh
It works good for me.
If you change your config like this, make sure to restart apache [sudo service apache2 restart]
Make sure that you installed PHP correctly and registered PHP in your Apache configuration.
This is the key here, it looks like it's sending you the index.php file, test a PHP file in the main folder behind this sub-directory and see if it tries to download it.
File Could just be:
<?php
phpinfo();
See if putting that in index.php in the parent folder gives you a phpinfo page or tries to download index.php.
If it tries to download it it's just that PHP is not configured in apache to handle files that end in .php
To configure it, add the following lines to your httpd.conf file
LoadModule php4_module modules/libphp4.so
#
# Cause the PHP interpreter handle files with a .php extension.
#
<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 9524288
</Files>
AddType application/x-httpd-php .php
Make sure that you installed PHP correctly and registered PHP in your apache configuration.
The manual should explain the required installation steps in detail.
in Ubuntu you should install the LAMP option using tasksel at the CL. That will give you Apache, MySQL and PHP all working together. It sounds like you may have installed them separatley and have not configured PHP correctly. mime types determine the servers handling of specific file types.
apesa#ubunt$ sudo tasksel
Follow the prompts
EDIT:
We used to make all the config changes in httpd.conf. If you used package manager, like you did then you will have a distributed configuration environment. You will need to go to etc/apache2/mods enabled and look in the php.conf file. There are directions inside. It sounds like you need to make sure the web server understands the directories and FS locations. Look at #Chrispy example. You won't be using the first line as the php module in your env are loaded via php.load and the config is done in php.conf. That AddType directive is important and tells the server to exec your file instead of serving it. have a look. BTW, the Apache Project supports one of the best listservers out there at URL:http://httpd.apache.org/userslist.html
I want to create a Chrome app, but I have the same problem as this guy. When I add the .php extension and I run the app, it downloads the file.Should I do something more? I have installed PHP (if that means to download and extract the file in the same folder with my app, I'd be wrong). I'm a beginner... :(
EDIT
Some of you told me to install Apache or IIS. I said earlier that I want to create a Chrome app.
Do I need to install Apache? Where would I run it (I don't have a local host, Chrome extensions and apps use the "chrome-extension://" prefix, which means it is hosted on the browser). What about more information (you've all been helpful by now)?
EDIT 2
It turns out that Google Chrome doesn't allow developers toto run PHP inside Chrome apps.
Thanks for your help!
This means the server is either missing the PHP plugin (either CGI or otherwise) or the the server doesn't recognize that it must pass a file with the extension in to PHP for pre-processing.
If you're on a host out of your control (e.g. using GoDaddy) then make sure they allow PHP (some of the free hosts won't have PHP as they deam it an unnecessary security risk). If it's your own server, make sure you installed PHP and it's enabled.
If it DOES has PHP installed, but you're not getting it to parse, you'll need to bind the .php extension to the PHP handler using either an .htaccess file or the config.
For apache, your http.conf needs the following (assuming you already have PHP plugin):
AddType application/x-httpd-php .php
Or for something more broad, place an .htaccess file with the above code in your hosted directory.
EDIT
You mentioned you installed PHP. I'm going to assume you're using Apache, as IIS now has a Web Extensions installer that would (typically) take care of the "hard part" for you. So, having said that, open your http.conf (Usually located in C:\Program Files\Apache Software Foundation\Apache2.2\conf\ [using 2.2 as a demo version]). Within that file, at the bottom, add the following [replacing files paths to those that correlate to your own install]:
LoadModule php5_module "C:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/php"
A better reference can be found by googling "install PHP [version] on [webserver]". Here's just one of the results I was able to locate.
Do you have a server installed on your machine? PHP is a server-side script & unlike Javascript you cannot run it without a server.
PHP files are server side code only. So you need to install a local server like APACHE to get the PHP script to execute.
PHP must be run on a web server, not your desktop. Install PHP on your webserver, then open the PHP file from a web browser via: http://localhost/yourfile.php
You need an Apache server on your computer. download xampp: http://www.apachefriends.org/en/xampp.html and put your files in the htdocs folder.
EDIT:
This will explain how to install a PHP environment: http://www.tanguay.info/web2008/tutorial.php?idCode=phpDevelopmentQuick
When I modify the php.ini document found in
Applications/MAMP/conf/php5/php.ini
The changes are not reflected in the php info page in the MAMP interface
WHY?
You need to restart MAMP (Or indeed any Apache Server) for changes in php.ini to take effect. Restart MAMP using the GUI.
If you are still experiencing no changes, it's possible you are editing the wrong php.ini file. In MAMP, each php version has it's own php.ini file.
To make utterly sure you are editing the right php.ini file, use the following steps:
Create a new .php file in your favourite text editor.
Type
<?php phpinfo(); ?>
and save it in MAMP's htdocs directory.
Save it as index.php
Make sure MAMP is running!
Start Safari, or any browser, and type "localhost:8888" into your
URL bar.
You should see a purple table filled with information about your
apache server.
The 6th row should be titled "Configuration File (php.ini)", and on
the right of this, a path should be displayed to the php.ini file apache is
currently using. It should look like this:
"/Applications/MAMP/bin/php/php5.4.4/conf"
Now, either use Finder to look browse to this location and edit the
.ini file with Text Edit, or use Terminal.
If you want to use Terminal, open a new window and type the
following: 'cd (and then copy and paste the path you gained from
step 6)'. It should look like something like this: 'cd
/Applications/MAMP/bin/php/php5.4.4/conf'
Now type 'ls'
Typing ls will show you the files within the 'conf' directory. The
correct php.ini file should be displayed amongst other files such as 'pear.conf'. If you can
see 'php.ini', we're nearly there. If not, you've gone wrong somewhere, so
read over the previous steps.
Now type 'sudo nano
/Applications/MAMP/bin/php/php5.4.4/conf/php.ini'
And give Terminal your password when it asks for it
The php.ini file will be opened in
Terminal's integrated text-editor, nano. Edit it, and save it using
Nano.
Simply quit terminal. 15) Restart Apache using MAMP's GUI 16)
Browse to localhost:8888 in your favourite browser. Your changes
should be reflected in the configuration screen.
I understand this instructions may be hard to follow, but just contact me if you want to use team viewer or something to get this working! Good luck
Possible answers:
You forgot to restart the Apache
webserver after the change
PHP uses a
php.ini from a different location (Check
the PHPIniDir setting in your Apache
config).
It seems that there are 2 php.ini files in the MAMP installation. The one that seems to be parsed in my case is not in the config/ folder but in the bin/php/php5.3.14/conf/php.ini
I would like to know how you upgrade PHP in Xampp for Windows? I tried to download the latest PHP version from the main PHP site but when I check (phpinfo) I still get that the previous version is still in use.
Take a backup of your htdocs and data folder (subfolder of MySQL folder), reinstall upgraded version and replace those folders.
Note:
In case you have changed config files like PHP (php.ini), Apache (httpd.conf) or any other, please take back up of those files as well and replace them with newly installed version.
Simplest method to upgrade PHP in XAMPP:
Download latest portable version of XAMPP.
Extract the archive(not where XAMPP already installed).
Copy the PHP folder from the extracted archive.
Keep back up of PHP folder which is in installed XAMPP directory. You can backup it like changing the PHP folder name to PHP-old or
like PHP-version-number
Paste the PHP folder which you copied from the extracted archive.
Replace the php.ini file with your backup folder php.ini file in case you have changed the default settings earlier.
That's all, start/restart the server.
You can go through the following link as it helped me, should work for you as well. http://hype-free.blogspot.com/2007/07/updating-php-in-xampp-for-windows.html
Realizing that my answer helped couple of users, here is the edit from original link:
Edit:
First of all Always backup your data.
Download the latest binary version of PHP (make sure to get the .zip package not the installer)
De-archive it to a directory
Overwrite the contents of directory in the php subfolder of your XAMPP installation directory.
Overwrite the contents of the directory apache\bin with the newer versions.
Now the trick: take the files which have a '_2' in their names (for example php5apache2_2.dll or php5apache2_2_filter.dll), copy them in the apache\bin subdirectory and remove the '_2' part, overwriting the existing files. This is necessary because by XAMPP uses Apache version 2.2 and the files with the 2 prefix are built for Apache 2.0, so you must take the files build for the newer version (which has a different plugin interface) and rename them in the filenames XAMPP expects.
NOTE: there are two directories to be updated with new version of files, namely php sub-directory and apache/bin sub-directory, inside XAMPP installation.
I have upgraded to php7.2 from php5.6
Steps which I followed.
Download PHP binary from here. I have downloaded VC15 x86 Thread Safe Zip file.
Created a backup of xampp/php folder.
Extract all the contents of zip file to xampp/php folder.
Copied php.ini (as I have modified it before and I want my configuration back, if you were using default one then skip this step.)
Edit below file
C:\xampp\apache\conf\extra\http-xampp.conf
5.1. Replace
LoadFile "C:/xampp/php/php5ts.dll"
LoadFile "C:/xampp/php/libpq.dll"
LoadModule php5_module "C:/xampp/php/php5apache2_4.dll"
to
LoadFile "C:/xampp/php/php7ts.dll"
LoadFile "C:/xampp/php/libpq.dll"
LoadModule php7_module "C:/xampp/php/php7apache2_4.dll"
Restart Apache
I needed to update my php from 5.3.8 to 5.3.29. (both Thread Safe) on Windows
Steps I did:
Back-up my initial php folder, under xampp.
Downloaded zip from here
http://windows.php.net/download/#php-5.3-ts-VC9-x86
Unpack that zip into xampp folder.
Copied php.ini file from old php folder into new one.
Copied a couple of folders that I didn't have in the new php folder,
from old one. For example: extras, which contained browscap.ini file
(this one is needed)
Copied needed extensions, from old php ext folder into new php
ext folder. I copied them manually, by checking list of extensions from php.ini file.
Copied also these files: php5apache2_2.dll, php5ts.dll
Hope that I covered everything.
Most probably these steps will not work if you change major versions of php, e.g. 5.3.x to 5.4.x, but for minor versions, it should work.
Also, a good way to see what's wrong... start command line and try to start httpd.exe, under xampp/apache/bin from there, it will list errors found.
I think you need to actually download and install XAMPP with the desired PHP version. I dont think you can just upgrade the components of XAMPP individually unless there is a facility provided for this within XAMPP itself.
download your desired version of php binary from http://windows.php.net/download/ website. download Thread Safe binary zip version.
Unzip the downloaded version of the PHP in a separate folder.
Please make sure that your new php folder name is not "PHP". May be you can use filder name as the version name. For example for php 5.4 you can use php54.
Copy the new php folder into your xampp folder. Now go to yourxampp/apache/conf/extra folder. Open file httpd-xampp.conf from the folder extra. Change the following variables:
Variable PHPINIDir to be /
Varaible LoadModule to be //php5apache2_2.dl
Save the file httpd-xampp.conf. Restart your XAMPP apache server. If your server get restarted successfully then your server php version is upgraded.
I don't have enough reputation to comment yet, but, to add to ssharma's answer:
After you copy your htdocs folder to a safe place, just export your databases from PHPmyadmin. Simply go to each of your databases and click on the export tab at the top. Export them as sql (or whatever, really - just remember what you chose). Upgrade your XAMPP installation. Now, in the new version of XAMPP, create the databases that you want to re-insert. Example: you have a database named 'test' that you exported from your old installation, name the new, empty database the same thing. Now, go into 'test' and hit the import button along the top (right next to the export button). Click on choose file, find the sql file that you exported earlier (should be 'test.sql') and import. Your tables and data will be in place.
NOTE: There's an option to export the entire collection of databases (it names the file 127.0.0.1.sql). But, I've never had much luck getting it to import correctly. Do each of your databases separately to ensure it works. I made this post kind of long-winded, but that's because I like to write for the people that don't know exactly what they're doing yet (I, myself, was there not too long ago (all of us were at some point)).
Shorthand version of my answer:
1) Export your databases individually
2) Import into your new installation of XAMPP
Go to phpinfo(), press ctrl+f, and type thread to check the value.
If it is enabled download the non thread safe version, otherwise download the thread safe version from here (zip).
Extract it, and rename the folder to php.
Go to your xampp folder rename the default php folder to something else.
Copy the extracted (renamed php) folder in xampp directory.
Copy the php.ini file from default/old php folder (That you renamed) and paste it into the new php folder.
Restart xampp server and you're good to go.
There are newer beta versions of Xampp that come with newer PHP upgrades.
you should check at http://www.apachefriends.org
I've updated the PHP to 8 by downloading the files from here.
https://sourceforge.net/projects/xampp/files/XAMPP%20Windows/8.0.6/
Uploaded it to the xampp directory by renaming the previous PHP folder to something else. But, then got the following error while starting the apache.
Error: Apache shutdown unexpectedly.
This may be due to a blocked port, missing dependencies,
improper privileges, a crash, or a shutdown by another method.
Press the Logs button to view error logs and check
the Windows Event Viewer for more clues
If you need more help, copy and post this
entire log window on the forums
After that, I've replaced the apache directory as well from the xampp folder with a newer version which I've downloaded, it sorted the issue out.
Got another problem while trying to access the phpmyadmin page, then again renamed the previous phpmyadmin folder from the xampp directory and uploaded the new version from the downloaded files. It's fixed the issue.
http://www.apachefriends.org/en/xampp-windows.html
In this site you can get
XAMPP Add-Ons
by using this add on you can upgrade the latest versions.
I just upgrade my old XAMPP portable with PHP 5.3.X(Include Mercury & FileZilla & Tomcat) to XAMPP portable with PHP 5.6.X ( Include previous versions ) ...
My way:
First download last xampp portable(my using version: xampp-portable-win32-5.6.14-3-VC11Direct Download Link) Last XAMPP
Extract new download file to drive d , because new version dont have mercury,filezilla,tomcat in it , then i copy these packages from my old version to new one
Now on old xampp first copy all htdocs files to new xampp htdocs
Now on old xampp backup all of database in 5 two 10 separated sql files
Now on new xampp going and change some settings like max_upload_size and etc on php.ini and also in /apache/conf/extra/httpd-xampp.conf
Now delete ( make a rar archive and delete ) it , and copy new xampp from drive D to drive C
Now start new xampp , going to phpmyadmin , create a user and password that i use in previous xampp and add all privileges that user.
Now going to import tab on phpmyadmin and separately import sql files.
Now i test xampp with all new features in drive C
NOTE
On Export database tab on phpmyadmin, select UTF-8 Character and check Disable foreign key checks checkbox
and on import tab uncheck Enable foreign key checks.
1) Backup your htdocs folder
2) export your databases (follow this tutorial)
3) uninstall xampp
4) install the new version of xampp
5) replace the htdocs folder that you have backed up
6) Import your databases you had exported before
Note: In case you have changed config files like PHP (php.ini), Apache (httpd.conf) or any other, please take back up of those files as well and replace them with newly installed version.
To update with latest PHP version in xampp without losing your htdocs data you need to download the zip file of your desired version of PHP from sourceforge.net, then copy the PHP folder from the extracted file and paste it into your xampp folder.
NOTE: Don't forget to rename the old PHP file folder which already exists.
Then simply edit your php.ini file with the current path to reach the right PHP folder
After that, you need to re-run your xampp.
I found a video on youtube which can help you.
how to update php version in xampp
1) Download new PHP from the official site (better some zip). Old php directory rename to php_old and create again php directory and put there unzipped files.
In php.ini connect needed modules if you used something that was turned off by default (like Memcached etc.), but doesn't forget to add corresponding .dll files.
2) In my case, I had to update Apache. So repeat the same steps: download the new package, rename directories, create new apache directory and put their new files.
Now you can try to restart apache running apache_start.bat from xampp folder (better run this bat, than restart apache service from Windows services window, cause in this case in console you'll see all errors if there will be some, including lines in config where you'll have problem). If you updated Apache and run this file, in the list of services you'll see Apache2.2, but in description you can get another version (in my case that was Apache/2.4.7).
In case of Apache update you can get some problems, so mind:
after you replace the whole directory, you may need to configure you apache/conf/httpd.conf file (copy virtual hosts from old config, set up DocumentRoots, permissions for directories, all paths, extend the list of index files (by default apache has only index.html so other index files will be just ignored and Apache will just list the site root directory in browser), configure you logs etc.)
connect modules you need (if you used something that was not turned on by default like mod_rewrite etc.)
Note
In order to run apache server after upgradation PHP 7.4.x requires Microsoft Visual C++ Redistributable for Visual Studio 2019 which can be downloaded here under the heading Other Tools and Frameworks. otherwise apache server won't start.
Upgrading to PHP 8
It's not a good idea to just swap out an older version of PHP in XAMPP to a new major version like PHP 8, as there's the possibility it could introduce lots of potential problems and incompatibilities due to tools, configurations and codebases that weren't designed to play together.
Instead, it's a much better idea in the long run to just update to the latest version of XAMPP itself - this will upgrade both PHP and any other binaries that PHP needs to work with, including MySQL and PHPMyAdmin, to versions that are designed to be compatible with PHP 8. This way you also take more complete advantage of the security and speed advantages of updating to newer versions - for example, modern versions of PHPMyAdmin are miles faster and much less buggy than versions that are a few years old.
Unfortunately there is no automatic way to update XAMPP, but it can be accomplished manually with very little effort - simply follow the steps below.
How to update XAMPP to PHP 8 properly
Rename your current, working XAMPP folder (located at C:\XAMPP by default) to XAMPP.old or something similar to indicate it's the old version.
Download the XAMPP installer for the version of XAMPP/PHP you want (note that the XAMPP versions mirror PHP versions to make it easier to know which PHP version you're getting), and install it to C:XAMPP
Go through the install process and feel free to deselect any software you don't need, like Mercury Mail and Tomcat, to prevent them cluttering up the XAMPP folder
Once the install is finished, copy the following folders from your old installation in C:\XAMPP.old to your new installation in C:\XAMPP:
mysql\data
mysql\backup
Any website or project folders you have in htdocs\
You've now moved all of your important data over from your last installation, so if you didn't customise your XAMPP installation a lot or don't care about moving your customisations over, you can stop at this stage and you should have a fully-working installation of XAMPP running on PHP 8.
If you do want to keep any configuration changes you've made
We're gonna be moving over all of the main configuration files from your old XAMPP installation at C:\XAMPP.old.
First is the php\php.ini file - you should not just copy this file over, as it contains configuration options that are very specific to the current PHP installation. If you've made changes to it or you're not sure whether you have, you can use a diff tool like git diff --color -y OLDFILE NEWFILE to compare your old php.ini file with the one you just installed - if you see any lines in red, these are the lines you should copy to your C:\XAMPP\php.ini file.
The rest of the files can be simply copied over, if you think you've made any changes to them.
apache\httpd.conf
apache\conf\extra\httpd-ssl.conf
apache\conf\extra\httpd-xampp.conf
apache\conf\extra\httpd-vhosts.conf
Realistically, these will be the same across XAMPP installations so copying them over anyway shouldn't hurt anything - but it's always a good idea to keep around the C:\XAMPP.old folder for a few weeks while you're testing out the new installation.
Finally, if you ever set up SSH on your XAMPP server you can copy the keys in apache\conf\ssl.key\ to avoid having to set these up again.
You can now restart your server to confirm that your new versions of Apache and MySQL are working, and visit localhost/phpmyadmin to confirm that the latest version of PHPMyAdmin has been installed successfully.
For Upgradation php in Xampp you can follow this steps, Else you can skip these 4 steps and direct install MAMP (for windows as well) from site and here is the direct download link
Step 1: Make backups
Before starting, make sure to backup any settings, custom modules and most importantly the htdocs directory, which contains your scripts and page resources. This directory is normally located atC:\xampp\htdocs\
Step 2: Preparation
Download PHP 5.3.0rc2. I use the VC6 build in order to minimise any potential compatibility issues.
It is also recommended that you download the latest Windows version of XAMPP. While this is an upgrade guide that shouldwork with previous versions of XAMPP, it is recommended that a fresh copy of the core files is used.
Stop any instances of the Apache service that might be running.
Step 3: The upgrade
This guide will assume your XAMPP directory is C:\xampp\
Extract the XAMPP archive to a directory of your choosing, I would recommend using the default C:\xampp\
Extract the contents of the PHP archive to C:\xampp\php\, overwriting the contents of this directory with the new files.
Open the file C:\xampp\apache\conf\extra\httpd-xampp.conf and ensure the following lines are present in this order:
LoadFile "/xampp/php/php5ts.dll"
LoadModule php5_module "/xampp/apache/bin/php5apache2_2.dll"
Replace C:\xampp\php\php.ini with C:\xampp\php\php.ini-dist
Uncomment the lines:
;extension=php_mbstring.dll
;extension=php_pdo_sqlite.dll
Replace the line
magic_quotes_gpc = On
with
magic_quotes_gpc = Off
Copy all files in the C:\xampp\php\ to C:\xampp\apache\bin\ (do not
copy the subdirectories or their contents).
After following the above steps, restart your Apache service (this can be done using C:\xampp\xampp-control.exe or manually through the control panel/command prompt). Your PHPinfo should indicate that the upgrade has been successful.
I will update this post if I discover any problems from using this method, or a cleaner (automated) means of performing the upgrade.