I am trying to enable XSL on Ubuntu 12.04 but its failing. I did this locally on my Ubuntu 13.04 and it was successful. Basically the following worked on my local computer.
apt-get install php5_xsl
edit php.ini file and add extension=php5_xsl.so
restart apache
I repeated the same procedures on my production server running Ubuntu 12.04 and PHP version 5.5.12 but the extension is not getting loaded from the phpinfo. I have also changed the extension=php5_xsl.so to extension=xsl.so because this is what in the extension directory.
I read that I might need to recompile PHP but I am not sure of this steps.
Try this:
sudo apt-get install php5-xsl
sudo php5enmod xsl
sudo service apache2 restart
Why:
http://www.lornajane.net/posts/2012/managing-php-5-4-extensions-on-ubuntu
What's happened here is that all debian-flavoured unixes have adopted
this standard for their PHP 5.4 packages, so if you're using debian,
ubuntu, or any of their relatives with PHP 5.4, you'll see a directory
structure like this. When you add a module to PHP, you'll add a file
to the mods-available directory enabling the module and adding any
config specific to it. If you want to enable the module, just do:
php5enmod http
This simply creates a symlink from the usual conf.d directory to point
to where the real files are in mods-available, prefixed with a number
that indicates the priority of the module. By default, the priority is
20.
Using this approach means we can toggle things on and off without
commenting out big chunks of config files and leaving them lying
around - if this seems familiar then that's no surprise; debian-like
linuxes manage their apache configuration in just the same way. Any
packages that you install using aptitude will use these exact same
commands to set up the configuration and then symlink it correctly. To
unlink, use the delightfully predictably-named php5dismod :)
Related
I setup a new LAMP stack on Ubuntu 16.04 via Virtualmin. I needed php5, so I added the ondrej repo (sudo add-apt-repository ppa:ondrej/php) and installed the packages I needed. Then I enabled php5 on apache (sudo a2enmod php5.6).
Usually when I do this I can change the php verion in my apache vhost configuration files.
Now here is the twist, apache will only run php5.6 now. If I disable it, uninstall it, etc, it just downloads the php files. I have combed over ever configration file and I cannot find where php7.0 is treated any differently that php5.6.
Also, it seems to be running under www-data instead of the virtual server owner regardless of the configurations.
I have trued to compare every configuration file (/etc/apache2) to a working setup on a different server, but I cannot find a significant difference.
Any intuition on this is appreciated.
So I'm running MAMP on Mountain Lion and I've installed gmagick and imagick using pecl, both are relase candidates (mainly because gmagick doesn't have a stable release and imagick 3.0.0 doesn't install, it gives a make error). The modules appear when I run php -i in the terminal but not in phpinfo(), I have checked the php.ini it is the same for both so that is not the issue.However I have installed bitset(which is a stable release) and it appears in phpinfo() and php -i. So my question is does PHP have any configuration option that does not load extensions if they are not stable? Btw, I did restart my server after the changes to the ini file.
You will probably now have two php installations on your machine. Mountain Lion ships with a preinstalled php version. Trylocate php.ini in Terminal to find out how many php.inis are installed.
In your phpinfo() page there is also noted which php.ini is in use. You might want to open the exact php.ini which is used for your phpinfo() and make sure the extentions are loaded.
There should be two lines like
extension=/path/to/gemagicext/gmagic.so
extension=/path/to/imagick/imagick.so
I faced a similar problem with php-fpm and nginx server. The problem was due to the fact that the updated php configuration was not reflected in the current active php-fpm worker processes. I have to manually kill the fpm process and restart it again to have the updated extensions info.
Steps that worked for me:
1) Look for active php-fpm process
ps ax | grep "fpm"
mostly this will list more than one process
2) kill process manually
kill -9 [pid_got_from_previous_command]
3) restart php-fpm process
sudo service php5-fpm start
Note: Trying something like sudo service php-fpm reload or sudo service php-fpm restart didn't work since the old child processes retained the old configuration. Killing the active processes and restarting php fpm what updated the phpinfo for me.
I had the same problem CentOS 6.6 x64, php 5.5.27 and I followed the steps from
http://php.net/manual/en/imagick.installation.php
First of all download a tar image of the ImageMagick install from here:
sourceforge.net/projects/imagemagick/files/
Unpack it and then from terminal issue the following commands:
1. "cd ImageMagick-6.9.1-10" - go where you placed the folder
2. ./configure
3. make
4. make install
5. make check
6. install imagick extension from pecl.php.net/package/imagick/download 3.1.2
7. cd imagick-3.1.2
8. phpize
9. ./configure --with-imagick=/opt/local
10. make
11. make install
12. Copy imagick.so in your PHP extensions folder and add extension=imagick.so in php.ini
Restart apache: service httpd restart
I am sure this problem is related to your extension and PHP server compatibility. I encountered such problems when I created my own extensions. Your extension should compatible with your PHP server in three main attributes:
1- The Zend API number which your PHP server is configured with ( in phpinfo() you can find this number), this number should be the same with your extension header file at build time.
2- The compiler version on your PHP server and your extension must be the same.
3- Thread safety in your PHP server is important. If you use thread-safe server then your extension must be built with php thread-safe library and if you use non-thread safe server you should build your extension with PHP-nts library.
I am using MAMP and would like to use mongo with PHP. I am stuck because the version of MAMP I'm using is the latest version I can find, and it's running PHP 5.2.11. The only Mongo PHP install I can find for OSX is for PHP 5.3.
Is there any way to get mongo working with PHP using MAMP?
For MAMP 2.1.2 and PHP 5.4.10
Download MongoDB php driver .
copy mongo.so to
/Applications/MAMP/bin/php/php5.4.10/lib/php/extensions/no-debug-non-zts-20100525/
and using temrinal
cd /Applications/MAMP/bin/php/php5.4.10/lib/php/extensions/no-debug-non-zts-20100525/ && wget https://github.com/downloads/stennie/mongo-php-driver/mongo.so
open
/Applications/MAMP/bin/php/php5.4.10/conf/php.ini
Find ; Extensions
add
extension=mongo.so
Restart MAMP.
Above steps will install MongoDB driver 1.2.10.
To install latest Mongodb driver using PECL
install autoconf using homebrew or Mac Ports
brew install autoconf
Download php 5.4.10 source from php.net.
rename uncompressed php source folder from php-5.4.10 to php and paste it in this folder
/Applications/MAMP/bin/php/php5.4.10/include/
using the terminal open php folder and run ./configure
cd /Applications/MAMP/bin/php/php5.4.10/include/php/ && ./configure
Add MAMP bin to your ~/.bash_profile
echo "export PATH=/Applications/MAMP/bin/php/php5.4.10/bin:$PATH" >> ~/.bash_profile
source ~/.bash_profile
install latest mongo
pecl install mongo
restart MAMP server :).
Here's a tutorial how to do it: http://www.davidgolding.net/mongodb/installing-mongodb-on-mamp-1-9-5.html
Post was removed so here's the tutorial:
Appsolute launched MAMP version 1.9.5 today, so I thought it’d be a great time to add MongoDB to it and improve my NoSQL skills.
Prepare MAMP for MongoDB files
Create a new folder at Applications/MAMP/db/mongo with three additional subfolders named bin, data, and tmp. Provide these folders with chmod 0755 access permissions. These folders will be the main runtime location for Mongo once MAMP gets it running.
Download MongoDB
Grab the latest Mac OS install package of MongoDB. My server setup called for OS X 64-bit, version 1.6.5. It’ll have a directory named bin. Drop the files from this folder into the /Applications/MAMP/db/mongo/bin folder you already created.
Download Mongo Driver for PHP
I’m running PHP 5.3 (why use MongoDB with any earlier version of PHP?), so I’ll need the mongo.so extension to get PHP and Mongo working together. This is available at the MongoDB GitHub repository, under the PHP 5.3 for Mac binary. After unpacking the downloaded file, place the mongo.so extension file in the /Applications/MAMP/bin/php5.3/lib/php/extensions folder.
Update: An alternative is to place the mongo.so file in the /Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626 folder and avoid having to edit the php.ini file. It appears that MAMP 1.9.5 already has the extension=mongo.so line in the extensions block of the php.ini file, even though version 1.9.5 doesn’t come bundled with Mongo.
4. Create Startup Routines for MAMP
Lastly, you’ll need to create the startup routines so that MAMP will launch Mongo along with MySQL and Apache. Create a new file at /Applications/MAMP/bin/startMongo.sh and place in it the following code:
# /bin/sh
/Applications/MAMP/db/mongo/bin/mongod --dbpath /Applications/MAMP/db/mongo/data --logpath /Applications/MAMP/db/mongo/mongodb.log --pidfilepath /Applications/MAMP/db/mongo/tmp/mongo.pid --fork --logappend
When called, this script will launch Mongo using the MAMP-relative paths rather than Mongo’s system defaults.
Create another file at /Applications/MAMP/bin/stopMongo.sh and place the shutdown method:
# /bin/sh
/bin/kill `cat /Applications/MAMP/db/mongo/tmp/mongo.pid`
This works like the previous script, except it kills the mongo.pid process, effectively shutting down Mongo.
To have MAMP automatically call these Mongo startup scripts, open the /Applications/MAMP/bin/start.sh and /Applications/MAMP/bin/stop.sh files, and insert the following lines above the startMysql.sh lines, respectively:
1
/Applications/MAMP/bin/startMongo.sh
1
/Applications/MAMP/bin/stopMongo.sh
Now MAMP will automatically launch Mongo upon startup.
The only thing left to do is tell PHP to run the mongo.so extension. If you’re running MAMP Pro, edit the php.ini file by selecting File > Edit Template > PHP 5.3 php.ini, otherwise you’ll need to lookup the path the php.ini file from the MAMP startup screen, under “phpInfo” and “Loaded Configuration File.”
Insert the following line in the php.ini file/template, save the file, then restart MAMP.
1
extension="/Applications/MAMP/bin/php5.3/lib/php/extensions/mongo.so"
Mongo should now run in the background on MAMP, which you can connect with from PHP using the main connection routines listed on the PHP site. Welcome to NoSQL on MAMP!
MAMP is now at version 2.2, which comes with PHP v 5.5.3. I managed to get Mongodb working had to jump through a few hoops to get there.
Start with a clean install of MAMP 2.2, make sure that's working.
1. I made this the system version of PHP, (not sure if necessary at this stage).
Find out the default version of php you are using, with the terminal command
$ which php
/usr/bin/php
Then back this up
$ sudo mv /usr/bin/php /usr/bin/php.bak
Then create a symlink to the MAMP latest version of php
$ sudo ln -s /Applications/MAMP/bin/php/php5.5.3/bin/php /usr/bin/php
Check this has been updated
$ which php
/Applications/MAMP/bin/php/php5.5.3/bin/php
2. Installing Mongo
$ cd /Applications/MAMP/db
$ curl http://downloads.mongodb.org/osx/mongodb-osx-x86_64-2.4.6.tgz > mongodb.tgz
$ tar -zxvf mongodb.tgz
$ rm mongodb.tgz
$ mv mongodb* mongo
$ mkdir mongo/data/db
Test to make sure mongo is working
$ ./mongo/bin/mongod --dbpath /Applications/MAMP/db/mongo/data/db
Should output some code, ending in 'waiting for connections on port 27017' press Ctrl + C to quit for now.
3. Now we can create a script to start/stop mongod automatically from the MAMP GUI. This inspiration came from a previous answer, by Alexandru Rada, but didn't quite work how he explained - I think this is to do with being a newer MAMP version.
In /Applications/MAMP/bin create a file called startMongo.sh and insert the following
# /bin/sh
/Applications/MAMP/db/mongo/bin/mongod --dbpath /Applications/MAMP/db/mongo/data/db --logpath /Applications/MAMP/logs/mongodb.log --pidfilepath /Applications/MAMP/tmp/mongo/mongo.pid --fork --logappend
I also created the mongo tmp folder at /Applications/MAMP/tmp/mongo
In the same bin directory create a file called stopMongo.sh and insert the following:
# /bin/sh
/bin/kill `cat /Applications/MAMP/tmp/mongo/mongo.pid`
Make these files executable
$ chmod 775 /Applications/MAMP/bin/startMongo.sh /Applications/MAMP/bin/stopMongo.sh
Now update the startApache.sh and stopApache.sh scripts to include our new files respectively.
Use the Activity Monitor in /Applications/Utilities and search for mongod. When you now start MAMP you should see the process mongod is started. When you stop or quit MAMP you should see this process is automatically killed.
4. We still need to install the mongo-php driver, which is also a pain. To do this I added the MAMP bin directory to my bash $PATH variable. To do this I had to edit the hidden file ~/.profile - but be aware that your $PATH might be loaded from somewhere else.
export PATH=$PATH:/Applications/MAMP/bin/php/php5.5.3/bin:/Applications/MAMP/db/mongo/bin
Note that each element is separated by a :. Quit terminal and re-open, then $ echo $PATH to check your new directories have been added to the path. You could also try $ which pecl or $ which mongod.
We still need some extras from PHP php.net download the same php stable version and unzip it. Create the folder 'include' at /Applications/MAMP/bin/php/php5.5.3/include . Drag the unzipped stable version of php to the include folder, and rename it to just 'php'.
$ cd /Applications/MAMP/bin/php/php5.5.3/include/php
$ ./configure
Now at last, we can hopefully run
$ sudo pecl install mongo
5. Now we just need to update our php config file to add the mongo.so extension.
Open /Applications/MAMP/bin/php/php5.5.3/conf/php.ini in a text editor, under the 'extensions' section, add in
extension=mongo.so
Quit and re-open MAMP!
Mac OS X 10.6 Snow Leopard (with the newest updates) has PHP 5.3 installed along with Apache.
You can enable the installed Apache in System Preferences, Sharing, Web Sharing (there is a help icon (?) which shows you details on using the system's web server).
See also this StackOverflow question:
Easiest way to activate PHP and MySQL on Mac OS 10.6 (Snow Leopard)?
Here's the way I did it and it was fairly simple.
First, read what Mongo says # http://www.mongodb.org/display/DOCS/PHP+Language+Center
When you run sudo pecl install mongo it's going to install it for the standard OSX PHP installation to use, so if for some reason you're using the built-in Apache installation.
Like you, I like using MAMP. I didn't want to go through figuring how to download Mongo into MAMP, so I just creating a symbolic link in the MAMP PHP Extensions folder and put the extension line in the MAMP php.ini. Restarted MAMP Apache and everything worked beautifully!
A couple things to note, after installing Mongo, note the extensions folder it installed it into then check MAMP php.ini to see where it has its extensions set to be. You'll notice the ending is very similar.
For MAMP PRO 2.0.5
You may compile your own mongo.so (http://m-schmidt.eu/2011/11/06/develop-mongodb-web-apps-with-mamp-under-mac-os-x/) or download compiled (http://www.davidgolding.net/mongodb/installing-mongodb-on-mamp-1-9-5.html).
I'd like compile.
After steps mongo.so don't include to php configuration, because in MAMP PRO php.ini placed in
/Applications/MAMP PRO/MAMP PRO.app/Contents/Resources
I using php5.3.6.ini file for my configuration.
I guess when php was installed on my box --with-tidy arg was not included.
When browsing my php.ini the line:
;extension=php_tidy.dll
is missing.
How can I add the module to my php install? Note I tried adding:
extension=php_tidy.dll
but with no luck.
I checked the docs but all they say is:
This extension is bundled with PHP 5 and greater, and is installed using the --with-tidy configure option.
On Ubuntu, you can add tidy to your php5 installation by running this command in a terminal:
$ sudo apt-get install php5-tidy
If you want to check if it is already installed or validate that the command above worked:
$ php -i | grep libTidy
libTidy Release => 25 March 2009 // means tidy is installed
To install both php5 and tidy at the same time, use this command (as an alternative to the "--with-tidy" configuration option):
$ sudo apt-get install php5 php5-tidy
For PHP 7 just run
sudo apt-get install php-tidy
And restart Apache, That's it :)
Update: Thanks to #Arnis Juraga
For the version above PHP 7, you can mention the version code as follows.
apt-get install php7.4-tidy
I was having the same trouble, and wrote up my solution here:
Installing Tidy 2.0 PHP extension on Ubuntu 10.10
http://web.onassar.com/blog/2010/11/16/installing-tidy-2-0-php-extension-on-ubuntu-10-10/
It works on newer versions of Ubuntu as well.
While it may not be the most direct route, it works well.
I hope it helps others.
Put that line in php.ini next to the other extension=...dll lines and make sure php_tidy.dll is in the directory configured in php.ini under extension_dir.
In ubuntu: you need to run the following command in terminal
sudo apt-get install php5-tidy
and the restart the server
sudo service apache2 restart.
For those who are having trouble enabling Tidy extension for PHP (using PHP handler for Apache server) on Windows (WAMP server), please note that you may be editing the wrong php.ini file. Assuming that WAMP server is installed in C:\wamp[ver]\ where [ver] is a variable version number.
File that you're probably editing:
C:\wamp[ver]\bin\php\php[ver]\php.ini
File that you must edit:
C:\wamp[ver]\bin\apache\apache[ver]\bin\php.ini
You also might want to make sure what's the correct php.ini file to edit by creating an info php file and add this code to it:
<?php phpinfo();
Then look for Loaded Configuration File string.
Finally make sure you uncomment this line within the correct php.ini file:
extension=tidy
I've been tasked to create a PHP app which accesses an existing PostgreSQL database. This is my first time working with Postgre, not to mention the PHP has already been installed in the Linux box on which the app is supposed to run. I have no experience setting up this stuff, I just code.
My question is that I can't seem to get the Postgre extension working in PHP. I checked the php.ini file, there were no "extension=..." lines. So I added "extension=pgsql.so". I then checked the "extension_dir" and found that there were only 2 files in there (ldap.so, phpcups.so), I added a pgsql.so file taken from another Linux box. I restarted httpd. And it does not work. I couldn't find any "pgsql" or "postgre" in phpinfo().
Forgive my noobness. I know too little Linux. I would really appreciate it if you can point me to the right direction.
I used the suggestion given by number5:
Dude, I'm on RedHat. I used the "yum" version of the command you gave, and I got this:
[root#perseus ~]# yum install php-pgsql
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=5&arch=x86_64&repo=extras error was
[Errno 4] IOError:
Error: Cannot find a valid baseurl for repo: extras
UNFORTUNATELY, the Linux server I'm using is NOT connected to the Internet. Any other way to install?
It depends on which Linux distro you are using.
If you are using Ubuntu/Debian, you need to:
sudo apt-get install php5-pgsql
Fedora/CentOS
yum install php-pgsql
usually you can find out which distro you are on by:
ls /etc/*-release
On CentOS extensions create separate *.ini file one per each php extension in /etc/php.d
So, don't alter main *.ini file, but create /etc/php.d/pgsql.ini and add there a line
extension=pgsql.so
Then you will need to restart Apache using
service httpd restart
But the best automated way is to just type
yum install php-pgsql
In your case that didn't work because of some problems in yum configuration. Go to /etc/yum-repos.d
Type
nano /etc/yum.repos.d/CentOS-Base.repo
Scroll down to [extras] section and ensure it is like this:
#additional packages that may be useful
[extras]
priority=1
name=CentOS-$releasever - Extras
=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
Correct it if needed, save file (Ctrl-X) and do the following:
yum clean all
yum upgrade
Afterwards try to repeat
yum install php-pgsql
Remove the .so file you've copied from the other machine (though it might work, there's no need to take the risk)
Use the distribution's package manager to install the php_pgsql/php5_pqsql module
Restart the apache and try again. Maybe the module has been added to an .ini file automagically
If not, run <?php echo 'ini: ', get_cfg_var('cfg_file_path'); to see which php.ini you have to edit
edit this ini file
restart the apache
My operation system Linux mint kde and there was same issue
pg_connect()
You must install if you are use php5.6
sudo apt-get install php5.6-pgsql
After you must change extention name in "php.ini" file.
;extension=php_pgsql.dll
'dll' to 'so'
For example
extension=php_pgsql.so