Get php7 to work with apache - php

I am trying to set up PHP7 to work with Apache on macOS sierra. I managed to install correctly (I checked using php -v) but there is no libexec directory where php was installed. This is a problem because I need to link to this folder to get php to work with apache. I can get to /usr/local/Cellar/php71/7.1.6_18. In that directory there are many more directories and files but no libexec directory. How do I configure Apache now?

Related

How to downgrade php from 7.1.1 to 5.6 in xampp 7.1.1?

I want to downgrade php version from 7.1.1 to 5.6 in xampp 7.1.1. But I can't find any option.
I think the most safest downgrade path from PHP7 to PHP5 in Xampp is:
Download a self-packaged version of Xampp with PHP5 from here (as of today this is xampp-win32-5.6.37-0-VC11.zip).
Rename the php folder to php7 in Xampp.
Now copy the php folder from xampp-win32-5.6.37-0-VC11.zip into your Xampp install folder.
Make a backup from .\xampp\apache\conf\extra\httpd-xampp.conf file.
Replace this file from xampp-win32-5.6.37-0-VC11.zip as well.
This way the config files (including php.ini) has settings from the Xampp team.
Before any changes, to verify changed Apache configs, you can compare both Xampp release folder at .\xampp\apache\conf with tools like Meld.
I should note that please download PHP 5 and 7 Xampp packages released at the same time.
Notify me if I miss something.
If you want to downgrade php from 7.1.1 to 5.6 in xampp follow the steps(For Windows):-
Go to https://sourceforge.net/projects/xampp/files/XAMPP%20Windows/5.6.36/
Download and extract the file xampp-win32-5.6.36-0-VC11.zip see the image
[image 1][1]
Delete php folder and apache folder present in C:\xampp
Copy php folder and apache folder from extracted file and paste it to C:\xampp
Add " C: " before \xampp\ to php ini file present in php folder.
Start your apache and MySQL and check php version. It will show php 5.6.36
Just delete this xampp, and download 5.6 version.
There is no option to downgrade XAMPP. XAMPP is hardcoded with specific PHP version to make sure all the modules are compatible and working properly. However if your project needs PHP 5.6, you can just install a older version of XAMPP with PHP 5.6 packaged into it.
Source: How to downgrade php from 5.5 to 5.3
Change the .htaccess code to switch to PHP 5.6:
AddHandler application/x-httpd-php56 .php
XAMPP is an integrated package and you can not downgrade or change one of its component such as php. (There are some solutions that you can use but there is little chances that everything work fine.)
You can download the package from these links:
https://www.apachefriends.org/download.html
https://sourceforge.net/projects/xampp/files/
You had better to download the old package form sourceforge.net.
You do not have to install another version of Xampp. I've managed to use PHP 5.6 on my Xampp PHP 7 version. Here is what you need to do to make it works:
Raname (backup) <XAMPP_DIR>\php to <XAMPP_DIR>\php~7
Copy (backup) <XAMPP_DIR>\apache\conf\extra\httpd-xampp.conf to <XAMPP_DIR>\apache\conf\extra\httpd-xampp~7.conf
Download PHP5 and unpack it to <XAMPP_DIR>\php
Edit <XAMPP_DIR>\apache\conf\extra\httpd-xampp.conf and change all php5 occurrences to php7. You need to change php7apache2_4.dll to php5apache2_4.dll, php7ts.dll to php5ts.dll and php7_module to php5_module
Ensure all your paths are correct like extension_dir in php.ini.
Restart Apache and voila.
If you want to downgrade php version, just simply edit yout .htaccess file.
Like you want to downgrade any php version to 5.6, just add this into .htaccess file
<FilesMatch "\.(php4|php5|php7|php3|php2|php|phtml)$">
etHandler application/x-lsphp56
</FilesMatch>
I know it might be late but I'm just adding to Lanti's answer since it's the most popular, I had the same problem as Wouter Vanherck in the comments and I can't comment yet.
What helped for me was instead of just replacing \xampp\apache\conf\extra\httpd-xampp.conf I replaced the whole apache folder. I basically did the same thing with it as with the php folder (steps 2 and 3).
Now the error is fixed and Apache starts just fine.
Using WAMP is perforce option if we want to use more then one version of php.
It is very easy to do, all you need to do is
1) download 5.6 from [1]: https://sourceforge.net/projects/xampp/files/XAMPP%20Windows/5.6.36/, the run the setup and install in folder "xampp"
2) download 7.6 from [https://sourceforge.net/projects/xampp/files/XAMPP%20Windows/7.4.2/xampp-portable-windows-x64-7.4.2-0-VC15-installer.exe/download][1] and run the setup in "xampp2"
NOte: after that you now have separate xampp installed in your system. all you do now is to run each xampp as a separate entity. Alway quite the 5.6 if you want to run 7.6
This solution is Only for local system / localhost on windows:
The simplest way to install xampp 5.6.X version as per your requirement in other windows drive then run xampp 5.6.X services from it's control panel for php 5.6 version.
NOTE: If you already have xampp (any other version) on your system then please close that xampp's services then start xampp 5.6.x services otherwise this solution will not work.
You can download your required (xampp 5.6 as per question) xampp version from below link:
https://sourceforge.net/projects/xampp/files/XAMPP%20Windows/
I have used this solution many times, it worked like charm. I hope this will also help you. Thank you to ask this question.
i was trying the same, so i downloaded the .7zip version of XAMPP with php 5.6.33 from
https://sourceforge.net/projects/xampp/files/XAMPP%20Windows/5.6.33/
then followed the steps below:
1. rename c:\xampp\php to c:\xampp\php7
2. raname C:\xampp\apache\conf\extra\httpd-xampp.conf to httpd-xampp7.OLD
3. copy php folder from XAMPP_5.6 7zip archive to c:\xampp\
4. copy file httpd-xampp.conf from XAMPP_5.6 7zip archive to C:\xampp\apache\conf\extra\
open xampp control panel and start Apache and then visit ( i am using port 82 instead of default 80)
http://localhost
and then click PHPInfo to see if it is working as expected.
Opening localhost shows dashboard
Opening phpinfo shows version 5.6

Installing phalcon on apps Mac OS

I am really struggling with getting phalcon up and running in my ampps installation. I believe its correctly installed on my system because when I run php -m, I see the phalcon module. However, when I put
<?php phpinfo(); ?>
in a file (info.php) and in the www directory and load it in the browser, the phalcon module doesn't show up. I am relatively new to both php and ampps, so I know i'm definitely doing something wrong. Please help.
Thank you
First, try to restart apache.
Second, make sure that you installed with this tutorial, using homebrew: https://docs.phalconphp.com/pt/latest/reference/install.html#mac-os-x
Follow the installation docs here https://phalconphp.com/en/download/linux (follow that which belongs to your distro)
Then add this line extension=phalcon.so to your php.ini located in your Ampps folder. for me it was located at /usr/local/ampps/php-7.1/etc
Then copy the phalcon.so file located at /usr/lib/php/{number digits} and place in you Ampps extension directory /usr/local/ampps/php-7.1/lib/extensions/ext
Then restart your Ampps and open the php extensions from the UI. Then enable the phalcon extension from the popup

How to downgrade php from 5.5 to 5.3

Is there a way to downgrade php 5.5 to 5.3 in xampp? I searched on google but every one just tell me to uninstall xampp and install an older version. Could I have php 5.5 downgrade to 5.3 without reinstall xampp?
Short answer is no.
XAMPP is normally built around a specific PHP version to ensure plugins and modules are all compatible and working correctly.
If your project specifically needs PHP 5.3 - the cleanest method is simply reinstalling an older version of XAMPP with PHP 5.3 packaged into it.
XAMPP 1.7.7 was their last update before moving off PHP 5.3.
Long answer: it is possible!
Temporarily rename existing xampp folder
Install xampp 1.7.7 into xampp folder
name
Folder containing just installed 1.7.7 distribution rename to different name and previously existing xampp folder rename back just to xampp.
In xampp folder rename php and apache folders to different names (I propose php_prev and apache_prev) so you can after switch back to them by renaming them back.
Copy apache and php folders from folder with xampp
1.7.7 into xampp directory
In xampp directory comment line apache/conf/httpd.conf:458
#Include "conf/extra/httpd-perl.conf"
In xampp directory do next replaces in files:
php/pci.bat:15
from
"C:\xampp\php\.\php.exe" -f "\xampp\php\pci" -- %*
to
set XAMPPPHPDIR=C:\xampp\php
"%XAMPPPHPDIR%\php.exe" -f "%XAMPPPHPDIR%\pci" -- %*
php/pciconf.bat:15
from
"C:\xampp\php\.\php.exe" -f "\xampp\php\pciconf" -- %*
to
set XAMPPPHPDIR=C:\xampp\php
"%XAMPPPHPDIR%\.\php.exe" -f "%XAMPPPHPDIR%\pciconf" -- %*
php/pear.bat:33
from
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=C:\xampp\php\.\php.exe"
to
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=C:\xampp\php\php.exe"
php/peardev.bat:33
from
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=C:\xampp\php\.\php.exe"
to
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=C:\xampp\php\php.exe"
php/pecl.bat:32
from
IF "%PHP_PEAR_BIN_DIR%"=="" SET "PHP_PEAR_BIN_DIR=C:\xampp\php"
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=C:\xampp\php\.\php.exe"
to
IF "%PHP_PEAR_BIN_DIR%"=="" SET "PHP_PEAR_BIN_DIR=C:\xampp\php\"
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=C:\xampp\php\php.exe"
php/phar.phar.bat:1
from
%~dp0php.exe %~dp0pharcommand.phar %*
to
"%~dp0php.exe" "%~dp0pharcommand.phar" %*
Enjoy new XAMPP with PHP 5.3
Checked by myself in XAMPP 5.6.31, 7.0.15 & 7.1.1 with XAMPP Control Panel v3.2.2
It is possible! Yes
In many cases, you might want to use XAMPP with a different PHP version than the one that comes preinstalled.
You might do this to get the benefits of a newer version of PHP, or to reproduce bugs using an earlier
version of PHP.
To use a different version of PHP with XAMPP, follow these steps:
Download a binary build of the PHP version that you wish to use from the PHP website, and extract the contents of the compressed
archive file to your XAMPP installation directory (usually, C:\xampp).
Ensure that you give it a different directory name to avoid
overwriting the existing PHP version. For example, in this tutorial,
we’ll call the new directory C:\xampp\php5-6-0. NOTE : Ensure that the
PHP build you download matches the Apache build (VC9 or VC11) in your
XAMPP platform.
Within the new directory, rename the php.ini-development file to php.ini. If you prefer to use production settings, you could instead
rename the php.ini-production file to php.ini.
Edit the httpd-xampp.conf file in the apache\conf\extra\ subdirectory of your XAMPP installation directory. Within this file,
search for all instances of the old PHP directory path and replace
them with the path to the new PHP directory created in Step 1. In
particular, be sure to change the lines
LoadFile "/xampp/php/php5ts.dll"
LoadFile "/xampp/php/libpq.dll"
LoadModule php5_module "/xampp/php/php5apache2_4.dll"
to
LoadFile "/xampp/php5-6-0/php5ts.dll"
LoadFile "/xampp/php5-6-0/libpq.dll"
LoadModule php5_module "/xampp/php5-6-0/php5apache2_4.dll"
NOTE : Remember to adjust the file and directory paths above to reflect
valid paths on your system.
Restart your Apache server through the XAMPP control panel for your changes to take effect. The new version of PHP should now be active.
To verify this, browse to the URL
http://localhost/xampp/phpinfo.php, which displays the output of the
phpinfo() command, and check the version number at the top of the
page.
I did this in my local environment. Wasn't difficult but obviously it was done in "unsupported" way.
To do the downgrade you need just to download php 5.3 from http://php.net/releases/ (zip archive), than go to xampp folder and copy subfolder "php" to e.g. php5.5 (just for backup). Than remove content of the folder php and unzip content of zip archive downloaded from php.net. The next step is to adjust configuration (php.ini) - you can refer to your backed-up version from php 5.5. After that just run xampp control utility - everything should work (at least worked in my local environment). I didn't found any problem with such installation, although I didn't tested this too intensively.
I just used a very simpler way for this and I just put it here if it could help anyone else.
I just had so much data on my database and I didn't want to transfer my whole Database so I just installed an older version of XAMPP with the PHP version that I required in a new directory (example:XAMPP-OLD) then I opened two control panel of 2 different version of XAMPP and start the MYSQL from the Newer version and Start Apache from the older version to use the other version of PHP.
just keep in mind to transfer files to the other XAMPP folder

with mac's default php and apache installation, where is the www folder equivalent?

When I used to use windows, i just install wamp, and put php code files inside the www folder and navigate to localhost/file_name.php to see that page in action. Now with my new macbook air, php and apache came with the machine, what are the equivalence of "put php files inside www folder" and "navigate to localhost/file_name.php"? How do I do what I used to do in Mac? (also I don't want to reinstall anything, no MAMP please.)
You can look in /etc/apache2/httpd.conf to find more settings and to change it but the default for OSX 10.8 is /Library/WebServer/Documents.
Some more information on how to setup PHP to work with Apache on OSX can be found at: https://discussions.apple.com/docs/DOC-3083

php curl works from cli but not from apache

I can't get cURL to work from inside Apache by any means. It's actually fairly strange too provided that:
I can execute my PHP pages from the CLI and it POSTs my requests perfectly fine
When I look at my error logs, I get "PHP Fatal error: Call to undefined function curl_init()" as if the extension isn't installed at all. Similarly, a quick `phpinfo()` also yields such as if the extension isn't installed.
Additionally, when I built PHP, I opted the "--enable-curl" flag.
You are probably not loading the extension in the appropriate php.ini. The file should include something like:
[PHP_CURL]
extension=php_curl.dll
Also, --enable-curl is not a PHP configure option. --with-curl=[DIR] is the one you'd want. Check out the cURL installation instructions.
php_curl.dll should be inside PHP's ext directory when configured correctly.
I had same problem after installing php5-curl. I rebooted apache and that fixed it.
sudo /etc/init.d/apache2 restart for ubuntu 12.04
I had similar problem - worked from cli, silently failed from Apache 2.4
I've tried:
1) copying ssleay32.dll and libeay32.dll from php folder into apache\bin folder - didn't work
2) deleting ssleay32.dll and libeay32.dll from apache\bin folder completely - WORKED.
You should restart apache server each time you make change to make it work.
Also you should install both x86 and x64 versions of C++ Resistributable Visual Studio from Microsoft.

Categories