How to configure travis-ci to use phpenv's php version in Apache?
phpenv's README states that ~/.phpenv/lib/libphp5.so is set whenever "phpenv global" is called, however when I try to configure apache to use this as its apxs library I get this:
Travis outputs:
/home/travis/build/OpenBuildings/Clippings/.phpenv/lib/libphp5.so: cannot open shared object file: No such file or directory
I don't think using "apt-get install libapache2-mod-php5" is the right call as I would rather use the specifically set php version from travis' config.
My config so far is:
before_script:
- sudo apt-get update
- sudo apt-get install -y --force-yes apache2
- echo "extension=memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- printf "\n" | pecl install imagick
- echo "LoadModule php5_module $(pwd)/.phpenv/lib/libphp5.so" | sudo tee /etc/apache2/mods-available/php5.load
- sudo cp build/travis/etc/apache2/clippings /etc/apache2/sites-available/clippings
- sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/clippings
- sudo a2ensite clippings
- sudo a2enmod rewrite
- sudo a2enmod php5
- sudo service apache2 restart
Apparently there are 2 "phpenv" libraries, and travis is using the other one.
So after a bit of digging I managed to configure appache successfully with php-fpm (which is supported by travis)
I've made a pull rquest for travis-ci docs to reflect my findings, and it's already merged to master: http://about.travis-ci.org/docs/user/languages/php/
Related
I have been trying to update PHP on my install of WordPress on Google Cloud.
I have followed these instructions: How do I upgrade from PHP 7.0 to 7.3 on google cloud platform?.
When I do a php -v command, it shows that it is updated, but within WordPress it is still showing version 7.0, not the updated version.
Your system appears to have two installations of PHP. One for the CLI and another Apache or you have not restarted Apache after the update. First restart Apache and recheck.
The command to install Apache PHP is sudo apt install libapache2-mod-php7.3.
Warning: Be careful with manual updates of PHP and other software that may have interdependencies. Make sure you have backed up your system (image) before so that you can recover is something goes wrong. Debian 4.9 is very old (obsolete) and might not be supported or even tested with the latest versions of third-party software.
The Linux command where php will tell you where PHP is installed. To figure out if you have a different installation for Apache, create a new web page, such as myphpinfo.php with the following contents. Then use your browser to view the page:
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
Your browser will display a page like this:
Use SSH commands:
Go to root
sudo -i
install latest version of php
apt-get install php7.4
update it
apt-get update
install packages
apt-get install ca-certificates apt-transport-https
wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list
check your php version
php -v
enable php7.4 and disable your current php7.0
sudo a2dismod php7.0
sudo a2enmod php7.4
install the libraries
sudo apt-get install phpmyadmin php-mbstring php-gettext
sudo apt-get install php-mysql
sudo apt-get install php-curl
sudo apt-get install php-xml
sudo apt-get install php-gd
restart apache
sudo service apache2 restart
I'm trying to install xdebug on Ubuntu:
sudo apt-get install php-xdebug
and getting following error:
Need to get 806 kB of archives. After this operation, 4.423 kB of
additional disk space will be used. Err:1
http://ppa.launchpad.net/ondrej/php/ubuntu artful/main amd64
php-xdebug amd64 2.5.5-3+ubuntu17.10.1+deb.sury.org+1 404 Not Found
E: Failed to fetch
http://ppa.launchpad.net/ondrej/php/ubuntu/pool/main/x/xdebug/php-xdebug_2.5.5-3+ubuntu17.10.1+deb.sury.org+1_amd64.deb
404 Not Found E: Unable to fetch some archives, maybe run apt-get
update or try with --fix-missing?
How can I solve this problem ?
First, you need to update local packages using the following command:
sudo apt update
# OR
sudo apt-get update
Now you can install xdebug with the following command:
sudo apt install php-xdebug
And configure it as:
sudo nano /etc/php/7.0/mods-available/xdebug.ini
Add the following code into it:
zend_extension=/usr/lib/php/20151012/xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9005 #if you want to change the port you can change
Note: Directory 20151012 is most likely to be different for you. cd into /usr/lib/php and check which directory in this format has the xdebug.so file inside it and use that path.
And then restart the services:
sudo systemctl restart php7.0-fpm
sudo systemctl restart nginx # If you are using nginx server
sudo systemctl restart apache2 # If you are using apache server
I use the following method and it works
retrieve content from php info
$ php -i> info.txt
copy all the text in the info.txt file then enter the xdebug installation wizard
and follow the ranks available there.
will look like this
Download xdebug-2.7.2.tgz
Install the pre-requisites for compiling PHP extensions.
On your Ubuntu system, install them with: apt-get install php-dev autoconf automake
Unpack the downloaded file with tar -xvzf xdebug-2.7.2.tgz
Run: cd xdebug-2.7.2
Run: phpize (See the FAQ if you don't have phpize).
As part of its output it should show:
Configuring for:
...
Zend Module Api No: 20170718
Zend Extension Api No: 320170718
If it does not, you are using the wrong phpize. Please follow this FAQ entry and skip the next step.
Run: ./configure
Run: make
Run: cp modules/xdebug.so /usr/lib/php/20170718
Update /etc/php/7.2/cli/php.ini and change the line
zend_extension = /usr/lib/php/20170718/xdebug.so
How to install Xdebug on Ubuntu
If none of the above solutions worked for you, then your last resort might be to use pecl
If you don't have pecl installed already:
sudo apt -y install php7.3-dev php-pear // replace php7.3 with your version
Run pecl to install xdebug:
sudo pecl install xdebug
At the end of the installation, you may see this output:
Build process completed successfully
Installing '/usr/lib/php/20180731/xdebug.so'
install ok: channel://pecl.php.net/xdebug-3.0.2
configuration option "php_ini" is not set to php.ini location
You should add "zend_extension=/usr/lib/php/20180731/xdebug.so" to php.ini
Open your php.ini file, add the zend_exntension line at the very bottom (skip if pecl was able to place it already):
sudo vim /etc/php/7.3/apache2/php.ini // again replace 7.3 with your version
Finally, restart your webserver, or PHP-FPM, depending on what you are using.
I think that you should update the local package index with the latest changes made in the repositories first by typing the following command :
sudo apt update
Or
sudo apt-get update
The APT package index is essentially a database of available packages from the repositories defined in the /etc/apt/sources.list file and in the /etc/apt/sources.list.d directory.
Credits
For anyone finding this answer, please bear in mind that there are significant changes between xdebug 2 and xdebug 3. There is upgrade guide provided by XDebug here: http://xdebug.org/docs/upgrade_guide
Update for php 7.4.8: In the Xdebug configuration file
/etc/php/7.4/mods-available/xdebug.ini
I had to add the line:
xdebug.force_display_errors = 1
As Xdebug wouldn't work instead.
please, disable ppa/php and run sudo apt install php-xdebug
Since Laravel4 requires mcrypt extension, and PHP7 doesn't seem to have mcrypt extension, is there any workaround for this to work?
Had the same issue - PHP7 missing mcrypt.
This worked for me. When asked, keep local PHP configuration files.
sudo apt-get update
sudo apt-get install mcrypt php7.0-mcrypt
sudo apt-get upgrade
Restart FPM (or Apache or NGINX etc.) after installation.
I'm on Mac and with laravel valet I've solved with this:
brew install php70-mcrypt
Even if you enable mcrypt in php.ini, this issue may occur.
Try the following steps.
sudo apt-get update
sudo apt-get install mcrypt php7.0-mcrypt
I am working in ubuntu 16.04 and the following commands also helped me.
whereis php -shows the files with this name
php -v -shows the php version
which php -shows current php version that is running on the server
On ubuntu: According to launchpad.net the package for mcrypt is called php7.0-mcrypt.
sudo apt-get install php7.0-mcrypt to install
Open terminal with Ctrl + Alt + T and run following commands for PHP7.0 on Ubuntu 16.4
sudo apt-get install mcrypt php7.0-mcrypt
sudo service apache2 restart
php7 have mcrypt, you can enable it in php.ini and then everything will work fine.
do like this:
wget http://jp2.php.net/distributions/php-7.0.3.tar.gz
tar zxf php-7.0.3.tar.gz
cd php-7.0.3/ext/mcrypt
/php7-path/bin/phpize (when error such as configure: error: mcrypt.h not found. Please reinstall libmcrypt run apt-get install libmcrypt-dev)
./configure --with-php-config=/php7-path/bin/php-config
(sudo) make && make install .this will install the mcrypt.so in php-7.0.3/ext/mcrypt/modules
cp to the /usr/lib/php/20151012/ what is the shared extensions dir
create a mcrypt.ini in /etc/php/mods-available/ write as extension=mcrypt.so
create link to this such as sudo ln -s /etc/php/mods-available/mcrypt.ini 20-mcrypt.ini in /etc/php/7.0/fpm/conf.d
create link to this such as sudo ln -s /etc/php/mods-available/mcrypt.ini 20-mcrypt.ini in /etc/php/7.0/cli/conf.d
sudo service nginx restart
sudo service php7.0-fpm restart
yes it is.
I use, Dotdeb, an extra repository providing up-to-date all kinds of cool toys for your Debian servers like Nginx, PHP, MySQL, Redis etc.
Update your sources.list
deb http://packages.dotdeb.org {distribution} all
deb-src http://packages.dotdeb.org {distribution} all
GnuPG keys
wget https://www.dotdeb.org/dotdeb.gpg
sudo apt-key add dotdeb.gpg
Update apt & build something amazing.
sudo apt-get update
PHP7 contains mcrypt extension internally (source-path/ext/mcrypt/).
But it depends on Libmcrypt soft.
Step 1.
Download libmcrypt-x.x.tar.gz from http://mcrypt.sourceforge.net/
and build it.
cd libmcrypt-x.x
./configure
make
make install
Step 2.
Rebuild PHP7 from source and add --with-mcrypt option.
./configure ... --with-mcrypt
Other way without rebuilding PHP7
cd php7-source-path/ext/mcrypt/
/php7-path/bin/phpize
./configure --with-php-config=/php7-path/bin/php-config
make && make install
echo "extension=mcrypt.so" >> /php7-path/ext/php.ini
Restart php
Im using ubuntu 12.04, and php 5.x I need to use sqlite3 in it but Im getting an error of
php fatal error: class sqlite3 not found
I done all the installation processes,
like
$ sudo apt-get install php5-cli php5-dev make
$ sudo apt-get install libsqlite3-0 libsqlite3-dev
$ sudo apt-get install php5-sqlite3
$ sudo apt-get remove php5-sqlite3
$ cd ~
$ wget http://pecl.php.net/get/sqlite3-0.6.tgz
$ tar -zxf sqlite3-0.6.tgz
$ cd sqlite3-0.6/
$ sudo phpize
$ sudo ./configure
$ sudo make
$ sudo make install
$ sudo apache2ctl restart
and
cd /etc/php5/conf.d
cat > sqlite3.ini
# configuration for php SQLite3 module
extension=sqlite3.so
^D
sudo /etc/init.d/apache2 restart
now what else I want to do???
Can anyone please help me to fix this...
Thankyou In advance.
Found a solution my self,
I installed
$ sudo apt-get install php5-sqlite
not
$ sudo apt-get install php5-sqlite3
and using sqlite3 class only.. no issue now.
Step 1 :
For PHP5, use
sudo apt-get install php5-sqlite
For PHP7.0, use
sudo apt-get install php7.0-sqlite
For PHP7.1, use
sudo apt-get install php7.1-sqlite
For PHP7.2, use
sudo apt-get install php7.2-sqlite
For PHP7.3, use
sudo apt-get install php7.3-sqlite
Step 2 :
Restart Apache
sudo service apache2 restart
For the error PHP Fatal error: Uncaught Error: Class 'SQLite3' not found in /path/file.php:1 on ArchLinux:
Install the sqlite extension for PHP:
$ sudo pacman -S php-sqlite
Then edit /etc/php/php.ini and add:
extension=pdo_sqlite
extension=sqlite3
Source: 1
I had the same problem even I have installed all libraries.
If you run php-fcgi, you should restart it:
sudo service php-fcgi restart
Try also restart apache:
sudo service apache restart
My PHP is 7.3 so I used the following
For PHP7.3, use
sudo apt install php7.3-sqlite3
And don't forget to restart your Apache2
sudo service apache2 restart
In order to install the missing class sqlite3, please run:
apt-get install php7.4-sqlite3
If you use XAMPP or anything else first close it.
Go to this directory: xampp > php > php.ini (find this file php.ini on PHP folder)
Open php.ini file with notepad
Search "SQLite3"
Remove ";" this line ;extension=sqlite3
Finally be extension=sqlite3
Save file
Open XAMPP
I had the same error. If you are on Windows, don't forget to uncomment php_sqlite3.dll (and optionally php_pdo_sqlite.dll) extension in php.ini. Save php.ini and start the script again.
(I added this answer to the question with the ubuntu tag because this question is on the first place in google for the request php sqlite3 not found).
For php5.6 use:
sudo apt-get install php5.6-sqlite3
run this command in linux system or (based on your operating system and php versoin )
system info - ubuntu 20
php 7.4
server - php local
sudo apt-get install php7.4-sqlite3
then you need to restart the your web server app like apache, nginx, or local php server then try to run
you can run the code test sqlite working
<?php
class MyDB extends SQLite3 {
function __construct() {
$this->open('sqlitedb.db');
}
}
$db = new MyDB();
if(!$db) {
echo $db->lastErrorMsg();
} else {
echo "Opened database successfully\n";
}
?>
create php file index.php
i am using php local server
php -S localhost:8000
(http://localhost:8000) open that url
I'm trying a simple web service example and I get this error even though I uncommented extension=php_soap.dll in the php.ini file:
Fatal error: Class 'SoapClient' not found in C:\Program Files (x86)\EasyPHP-5.3.9\www\server.php on line 2
Diagnose
Look up the following inside your script file
phpinfo();
If you can't find Soap Client set to enabled like so:
Fix
Do the following:
Locate php.ini in your apache bin folder, I.e Apache/bin/php.ini
Remove the ; from the beginning of extension=php_soap.dll
Restart your Apache server
Look up your phpinfo(); again and check if you see a similar picture to the one above
If you do, problem solved!
On the other hand if this doesn't solve your issue, you may want to check the requirements for SOAP here. Also in the comment section you can find good advice on connecting to https.
To install SOAP in PHP-7 run following in your Ubuntu terminal:
sudo apt-get install php7.0-soap
To install SOAP in PHP-7.1 run following in your Ubuntu terminal:
sudo apt-get install php7.1-soap
To install SOAP in PHP-7.2 run following in your Ubuntu terminal:
sudo apt-get install php7.2-soap
To install SOAP in PHP-7.3 run following in your Ubuntu terminal:
sudo apt-get install php7.3-soap
For AWS (RHEL):
sudo yum install php56-soap
(56 here is 5.6 PHP version - put your version here).
To install SOAP in PHP5.6 run following in your Ubuntu 14.04 terminal:
sudo apt-get install php5.6-soap
service php5.6-fpm restart
service apache2 restart
See if SOAP was enabled:
php -m
(You should see SOAP between returned text.)
I had to run
php-config --configure-options --enable-soap
as root and restart apache.
That worked! Now my phpinfo() call shows the SOAP section.
I solved this issue on PHP 7.0.22-0ubuntu0.16.04.1 nginx
sudo apt-get install php7.0-soap
sudo systemctl restart php7.0-fpm
sudo systemctl restart nginx
I couln't find the SOAP section in phpinfo() so I had to install it.
For information the SOAP extension requires the libxml PHP extension. This means that passing in --enable-libxml is also required according to http://php.net/manual/en/soap.requirements.php
From WHM panel
Software » Module Installers » PHP Extensions & Applications Package
Install SOAP 0.13.0
WARNING: "pear/HTTP_Request" is deprecated in favor of "pear/HTTP_Request2"
install ok: channel://pear.php.net/SOAP-0.13.0
Install HTTP_Request2 (optional)
install ok: channel://pear.php.net/HTTP_Request2
Restart Services » HTTP Server (Apache)
From shell command
1.pear install SOAP
2.reboot
For XAMPP users, open php.ini file located in C:/xampp/php and remove the ; from the beginning of extension=soap. Then restart Apache and that's it!
For Docker* add this line:
RUN apt-get update && \
apt-get install -y libxml2-dev && \
docker-php-ext-install soap
*: For debian based images, ie. won't work for alpine variants.
For PHP 7.4 & Docker
add this line in Dockerfile:
RUN apt-get update && apt-get install -y \
libxml2-dev \
RUN docker-php-ext-install soap
Rebuild the image and restart ;)
You have to inherit nusoap.php class and put it in your project directory, you can download it from the Internet.
Use this code:
require_once('nusoap.php');
On Centos 7.8 and PHP 7.3
yum install php-soap
service httpd restart
For PHP 8:
sudo apt update
sudo apt-get install php8.0-soap
In my case, the Symfony cache was causing the problem,
after running composer install the problem was gone.
I had a similar problem. It was due to the scope and solved by replacing new SoapClient by new \SoapClient.