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?
Related
When I try to install MongoDB with composer, it complains that I don't have the mongodb extension configured in my ini files. It's looking at the regular php ini files but mine are under /fpm as I'm using nginx. How can I tell composer to use the FPM version of PHP?
I found two solutions:
(after I figured out that composer uses the php-cli configuration)
Link the php-fpm configuration into the php-cli configuration, as detailed in:
http://paulwhippconsulting.com/blog/getting-php-cli-to-match-php5-fpm-so-it-behaves-consistently-under-nginx/
This seems more elegant, but doesn't seem to be official so it may break.
Copy all your configuration directives (.ini files) to both the php-cli and the php-fpm configuration directories.
The downside of this ofcourse is that if not done carefully, your production and development environment end up having different configuration settings.
I'm getting back in to web development so have decided to re-install my Mac's dev environment from scratch with homebrew (I'm following the tutorial at https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions which is probably the best tutorial on the subject that I've ever read).
Everything is going fine apart from using PECL to install extensions like APCU and Xdebug. I think I can get extensions working in a slightly hacky way, but I'd rather properly understand what's going on here.
My php.ini file is located at /usr/local/etc/php/7.1/php.ini. When PECL installs an extension, it seems to add a line to the top of php.ini immediately above the [PHP] line, e.g.:
1 zend_extension="xdebug.so"
2 extension="apcu.so"
3 [PHP]
4
5 ;;;;;;;;;;;;;;;;;;;
6 ; About php.ini ;
7 ;;;;;;;;;;;;;;;;;;;
8 ; PHP's initialization file, generally called php.ini, is responsible for
9 ; configuring many of the aspects of PHP's behavior.
The tutorial advises going to /usr/local/etc/php/7.1/conf.d/ and creating individual config files for each extension. i.e., lines 1 and 2 in php.ini would be deleted, and /usr/local/etc/php/7.1/conf.d/ext-apcu.ini and /usr/local/etc/php/7.1/conf.d/ext-xdebug.ini would be created, with config settings for each extension included in the relevant ext-xx.ini file.
Neither the default PECL approach of referencing the extension in php.ini nor the recommended approach of using an ext-xx.ini file for each extension seems to load the extensions successfully. I can hack round this by specifying a path to the extensions (/usr/local/lib/php/pecl/somedatestamp/extension.so), but I'd rather not have to. So:
(I'm pretty sure the answer to this is "yes", but just to be sure): does the server just scan through the conf.d folder and try to load any extension.so that is described in every ext-extension.so file it finds?
How do I set the equivalent of $PATH for my PHP configuration? phpinfo() refers to an extension_dir variable and gives the value as /usr/local/Cellar/php#7.1/7.1.20/lib/php/20160303, and there's an extension_dir variable set in php.ini but it's commented out. So where is PHP getting the value it's displaying through phpinfo(), and is it possible to specify multiple directories where PHP will look for extensions?
Server doesn't scan for *.so files automatically, it loads extensions mentioned in php config files in extension=extension.so and zend_extension=extension.so configurations. To check all config files which are loaded during server start run the command php --ini, my example output is:
$ php --ini
Configuration File (php.ini) Path: /usr/local/etc/php/7.1
Loaded Configuration File: /usr/local/etc/php/7.1/php.ini
Scan for additional .ini files in: /usr/local/etc/php/7.1/conf.d
Additional .ini files parsed: /usr/local/etc/php/7.1/conf.d/ext-opcache.ini,
/usr/local/etc/php/7.1/conf.d/ext-phalcon.ini,
/usr/local/etc/php/7.1/conf.d/ext-xdebug.ini,
/usr/local/etc/php/7.1/conf.d/php-memory-limits.ini
In you case it looks like you might have messed versions: your config file is located in /usr/local/etc/php/7.1/php.ini (version 7.1) but you are trying to put additional config files in /usr/local/etc/php/5.6/conf.d/ (version 5.6). Try to put them in /usr/local/etc/php/7.1/conf.d
You should specify extension dir path in your php.ini, I have the value
extension_dir = "/usr/local/lib/php/pecl/20160303"
This value is valid for php version 7.1, timestamp 20160303 specifies PHP API version for the extensions.
You can also check that PECL configuration for the extension dir has the same value as in php config using the command
pecl config-get ext_dir
After these steps you can check if extension is loaded with the command
php -m
It lists all the loaded php modules and extensions. If some extension is mentioned in config file but could not be loaded, you will get warning.
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.
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.
I have done the following:
Downloaded ffmpeg from http://sourceforge.net/projects/ffmpeg-php/files/
Copied php_ffmpeg.dll from the php5 folder to the
C:\wamp\bin\php\ext
Copied files from common to the windows/system32 folder
Added the extension=php_ffmpeg.dll to php.ini file
Restarted all services (Apache, PHP...)
enabled extension=php_ffmpeg.dll directive in my php.ini.
But it still doesn't show up when I do a php info page. I thought it might have something to do with that fact that I'm using php version 5.3.0. I have googled for a php_ffmpeg.dll for php version 5.3.0 and haven't had any luck.
Have you installed ffmpeg software on to the system first, before installing http://sourceforge.net/projects/ffmpeg-php/files/ this?