I've been having some issues with phpmyadmin suddenly not cooperating with my php configuration, so I decided to reinstall php7 and phpmyadmin from the latest stable tar file on their respective websites.
(Edit: Here is a link to the issue that this is a sub-issue of: phpmyadmin Error with php7: Missing json extension)
When I uninstalled php7 (which was originally installed via this ppa: ondrej/php)
then reinstalled it via the tar file, the php files went into usr/lib instead of etc/ which I understand to be the default php directory. Why are they being installed in usr/lib now?
Also, when I check this new directory, it seem to be missing php.ini and the apache2 service directory that php usually ships with. Why is this? Do I have to install these separately now?
In short: Why does installing php7 from a tar file have such different defaults than the apt install of php5, and what can I do to make sure that something like phpmyadmin can understand and use this install of php7?
Thanks for any input.
If you compile from source, there are various configuration options to determine where files go. The defaults for configure are not necessarily the defaults for a rpm or deb package.
Along with the PHP configure options: http://php.net/manual/en/configure.about.php, you have GNU general configuration options like --prefix to determine the install directory or --sysconfdir to determine the system configuration directory.
See all the options here: https://gcc.gnu.org/install/configure.html
--prefix=dirname
Specify the toplevel installation directory. This is the recommended way to install the tools into a directory other than the
default. The toplevel installation directory defaults to /usr/local.
--exec-prefix=dirname
Specify the toplevel installation directory for architecture-dependent files. The default is prefix.
--bindir=dirname
Specify the installation directory for the executables called by users (such as gcc and g++). The default is exec-prefix/bin.
--libdir=dirname
Specify the installation directory for object code libraries and internal data files of GCC. The default is exec-prefix/lib.
--libexecdir=dirname
Specify the installation directory for internal executables of GCC. The default is exec-prefix/libexec.
--with-slibdir=dirname
Specify the installation directory for the shared libgcc library. The default is libdir.
--datarootdir=dirname
Specify the root of the directory tree for read-only architecture-independent data files referenced by GCC. The default is
prefix/share.
--infodir=dirname
Specify the installation directory for documentation in info format. The default is datarootdir/info.
--datadir=dirname
Specify the installation directory for some architecture-independent data files referenced by GCC. The default is
datarootdir.
Related
I pulled a docker image php apache, then installed some modules via apt globally.
PHP is installed on /usr/local
php --ini shows that the configuration file path is /usr/local/etc/php, with two files php.ini-development and php.ini-production under the directory.
Modules are loaded in /etc/php/7.2/cli/conf.d and /etc/php/7.2/apache2/conf.d
There are php.ini files in /etc/php/7.2/cli and /etc/php/7.2/apache2
Problem: php does not load modules in /etc/php/7.2/cli/conf.d or /etc/php/7.2/apache2/conf.d
My questions:
Is local software completely isolated that does not read global configurations at all?
In this case (PHP installed in local), is the whole directory /etc/php/xxx useless because it is not loaded?
What is best practice then? What I am thinking is by making symbolic links to global configurations or installing packages locally if possible
Is it recommended installing softwares in /usr/local instead of global system?
I compiled PHP but there is no "extensions" folder. I do not see any configuration flags related to extensions. Is the extension folder manually added after or when I install an extension.
The following website had the modules I needed: https://pecl.php.net/
Specifically, apc.so, geoip.so, imagick.so and redis.so
On the OLD system I need to find which version was being used so I was able to install on the NEW system. The following showed me the version for imagick.
/usr/local/php54/bin/php --re imagick | head -1
Then I download the package to the new system using wget.
wget https://pecl.php.net/get/imagick-3.4.1.tgz
Uncompress...
tar zxvf imagick-3.4.1.tgz
CD to the directory
cd imagick-3.4.1
Run the following which gives the configure file.
/usr/local/php54/bin/phpize
Configure
configure --with-php-config=/usr/local/php54/bin/php-config
Followed by make, make test and make install.
After doing the make install you'll see something similar to the following.
Installing shared extensions: /usr/local/php54/lib/php/extensions/no-debug-non-zts-20100525/
Installing header files: /usr/local/php54/include/php/
The extensions directory is created for you.
Ubuntu 16.04.2
LSPHP7.0
wget -O - http://rpms.litespeedtech.com/debian/enable_lst_debain_repo.sh | bash
apt install -y lsphp70
Then I added /usr/local/lsws/lsphp70/bin to $PATH and made a symlink for /usr/local/lsws/lsphp70/bin/php7.0 to /usr/local/lsws/lsphp70/bin/php. This way I can run php in terminal as cli version.
apt install composer
composer require geoip2/geoip2:~2.0
I got an error said the requested PHP extension curl is missing from your system.
And also it said
To enable extensions, verify that they are enabled in those .ini files:
- /etc/php/7.0/cli/php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
But when I run php -i | grep php.ini it shows the ini is not /etc/php/7.0/cli/php.ini but /usr/local/lsws/lsphp70/etc/php/7.0/litespeed/php.ini
Further more, I run php --ini, it shows:
Configuration File (php.ini) Path: /usr/local/lsws/lsphp70//etc/php/7.0/litespeed/
Loaded Configuration File: /usr/local/lsws/lsphp70/etc/php/7.0/litespeed/php.ini
Scan for additional .ini files in: /usr/local/lsws/lsphp70//etc/php/7.0/mods-available/
Additional .ini files parsed: /usr/local/lsws/lsphp70//etc/php/7.0/mods-available/curl.ini,
/usr/local/lsws/lsphp70//etc/php/7.0/mods-available/imap.ini,
/usr/local/lsws/lsphp70//etc/php/7.0/mods-available/json.ini,
/usr/local/lsws/lsphp70//etc/php/7.0/mods-available/mysqli.ini,
/usr/local/lsws/lsphp70//etc/php/7.0/mods-available/opcache.ini,
/usr/local/lsws/lsphp70//etc/php/7.0/mods-available/pdo_mysql.ini
How can php cli get /etc/php/7.0/cli/php.ini as its php config file? Anyone gives a clue? thanks.
Ubuntu normally installs system default php(currently php7.0) to /usr/bin/php
Composer will normally call the PHP defined in $PATH, usually /usr/bin/php.
The Error "the requested PHP extension curl is missing from your system" means Ubuntu system default php7.0 curl is missing. To resolve:
apt-get install php7.0-curl
So far, it should resolve your problem already.
LiteSpeed Web Server normally use LiteSpeed API to communicate with PHP engine, which is faster than other APIs. In LiteSpeed Ubuntu/Debian repo, it provides different versions of lsphp, which will be at different location other than system default location, normally at /usr/local/lsws/lsphpxx/bin/.
Composer will normally use system default php location as explain above. If you want to overwrite PHP path to use lsphp70 php binary, you will need to add this path to the beginning of $PATH.
export PATH="/usr/local/lsws/lsphp70/bin/:$PATH"
This way, when you run:
which php
System should use the php found first in the PATH, which is /usr/local/lsws/lsphp70/bin/php
In this case, when you see similar php-curl missing error message, you should run:
apt-get install lsphp70-curl
to fix the problem.
To make the new PATH permanently, you can edit ~/.profile or .bashrc, or any other similar way, which is beyond the discussion of this topic.
I'm developing an application in PHP on a Linux server. The server has at least two different versions of php installed on it: 5.2.0 and 5.2.9.
The 5.2.0 version has the following directory /usr/local/lib/php in the include_path in php.ini.
I need to find out where the 5.2.9 version of this directory is located.
I checked the include_path setting in the 5.2.9 php.ini but it only has . and /usr/share/pear for include_path.
(Note that I just installed pear right now, since the 5.2.9 php was originally configured without pear.) The files in /usr/share/pear do not seem to match what I see in /usr/local/lib/php and it seems a little absurd to tell pear that php_dir is /usr/share/pear. Any ideas?
UPDATE - Is it possible that /usr/local/lib/php also belongs to php 5.2.9? Is there anything within this directory itself I can look at, to see?
If the directory you're looking for exists (it might not if you excluded pear during install): The default location would be /xxx/lib/php where /xxx is the installation prefix.
For example, on one of my servers, one of my PHP executables (I have 4 versions installed) is located /custom/php5.3.5/bin/php so it's corresponding PEAR/general library directory is /custom/php5.3.5/lib/php
(/custom/php5.3.5 being the installation prefix, normally it would be /usr/local or /usr.)
If your lib/php directory has a pearcmd.php file, call (yourphpbin) pearcmd.php info pear and it should be able to tell you pear version, it's requirements and whatnot. (If pearcmd.php exists, there's a good chance pear exists in that directory.) The pear shell-script would by default be at /xxx/bin/pear again /xxx being the installation prefix.
As far as I'm aware, you can set it up so that PEAR is shared among multiple versions of PHP. I would assume that's how the /usr/share/pear one is set up. (Distribution repository-provided?) Not sure if the same holds true for pecl. If you have multiple installs of pear, you just need to make sure you install the packages you want to use into the right pear install.
PHP will happily use whatever PEAR installation you tell it to in include_path.
Try the whereis command. It usualy gets you the binary, man page and configuration paths.
$ whereis php
You can then check the information each PHP version outputs:
$ /path/to/php.binary -i
There should be information about the included paths and configuration files used.
To find it, use:
]# sudo updatedb
]# locate php
That might return LOTS of results, you can filter in various ways. I usually try this first:
]# locate php | grep bin
You can try this command in the console:
which php
I am just curious about the process of installing an extension because I am trying to install php's uploadprogress extension on Ubuntu. I have a default php installation in my usr/ directory, but I have a XAMPP server set up (separate php apache mysql package) in another location in /opt. This is the installation I use for testing.
When I use the command pecl install uploadprogress, the extension installs automatically to the /usr directory. As a test I took the uploadprogress.so file out of the /usr directory php location and put it in the opt location where my XAMPP installation is. I then modified the php.ini for my XAMPP installation and put the extension in. When I ran phpinfo() it showed uploadprogress as installed, however when uploading a file, the uploadprogress function returns null.
My question is, when a php extension is installed, what processes are done, and what files are created and modified? If I manually download the uploadprogress.tgz and manually compile, it still installs to the default directory of /usr/local/php5/ext and I figure there must be more done then just a .so file created in the extension directory. How can I change the location that the extension installs to? I want to have the extension available to my other XAMPP installation in /opt.
My question is, when a php extension is installed, what processes are done, and what files are created and modified?
That depends on the extension, but normally there is the building and compilation of the extension. Temporary files are created, the configuration could getting modified and the actual module file (.so/.dll) is getting written (at least).
Keep in mind that some modules require certain settings in php.ini before they work. If you have copied over only the .so file then you should copy over the relevant part of the php.ini as well.
How can I change the location that the extension installs to?
You normally compile it for the location you want to install it to. If the default location is not the location you want it to be, you can try to specify the output directory in the build process, and there is php-config.
You want to run configure --help to see what options it gives to you to compile the extension and to look for the install directory path option. Maybe this answer helps you with pecl How do you change the default Pear/PECL build folder from /var/tmp?. A .so file is a special standalone library. It's stripped from any linkage and is basically an object file.