I'm a newbie and after I've successfully learnt enough to build my simple but useful web services, I managed to put myself in a position where I need to configure my own PHP build.
The problem is I don't really know what build means --never built anything either.
My broad question is:
Any good step by step tutorial that doesn't just say "must have dependencies"?
My specific question is:
For instance, one that shows how to build PHP with odbc, then rebuild (configure.nice and make nice?) with imap in addition.
If someone finds a PHP bundle that comes with odbc, great; with odbc & imap, better. But I'm really looking for someone to show me how to fish. Please.
Thnx.
A.
Gazler is correct, for a simple setup, you can just configure Ubuntu through the repositories via apt-get. For RHEL-based systems - yum would be the equivalent. However, if you are wanting to know more of how to compile from scratch (which would give you more control over installation), then you can do so.
Basics of compiling an application:
Download source from website (such as PHP, www.php.net)
untar the source (tar -xzvf source.tar.gz)
cd source
Configure the source (./configure [install-option-flags])
Compile source (make)
Test Install (doesn't actually install) - make test
Install the software (make install)
Step 4 is a very broad step. You will need to figure out what options you want to configure - see PHP Core Configuration Options.
Requirements for installing PHP will differ between environments, so that's too broad to cover in one answer, however, you will at least need a c-compiler to compile the source. Usually gcc is my choice, and is usually installed already. On Ubuntu (Debian-based) use apt-get install build-essential or search and install via yum on RHEL-based systems, I believe it would be something like yum install gcc.
You will probably run into dependencies issues as you compile, as I said its a very broad step, however, once you figure out the requirements that you need, you should be good to go, so long as you document your steps for your environment.
Again, the easiest way to go is to install via your software repository (apt-get, yum, emerge, pacman, etc), but these don't give you as much leverage on controlling your environment installation, whereas building from source gives you all the configuration control that you'd need.
You haven't mentioned what distro you are on, On ubuntu you can do:
sudo apt-get install lamp-server^ php5-imap php5-odbc
That should be enough to get you started and configured.
Related
Me and a friend of mine are working with a project. She was responsible for a part of it, while I would add some functionalities to her code. So she send me her code and I should make it work in my machine and add my part.
However, I'm facing this problem. She has used yaml in the project (which I had no idea it existed before, I don't do web programming, only algorithm implementation). I tried to follow her instructions but got stuck at
Fatal error: Call to undefined function yaml_parse_file() in /var/www/html/cdn/map_of_site.php on line 8
So I thought that I should install the yaml library (which I think I did correctly).
I also added the yaml parser in the php.ini
But the error continues to appear.
The worst part is that I won't be able to get in touch with her for a couple of days (and I kind of dislike telling her that I don't know how to make her code work).
Could you please tell me in general what is required to make a project that uses yaml_parse_file() function work? Like what should I install or where to install it ...
PS: I work with linux mint and the project is php
Your frend used a php module that you don't have installed or enabled.
You can try to install it in the regular way (I don't know linux mint myself):
- apt-get install php5-yaml
- yum install php5-yaml
Or something like that.
If yaml is not available like that, you can try to use pecl.
You need this package: http://pecl.php.net/package/yaml
If you have pecl installed on your system (apt-get install pecl), you can just do pecl install yaml.
Usually when the extension is installed it is also directly enabled. You can test if it is enabled by creating a php file with <?php phpinfo(); ?> in it and running or visiting it (then search for yaml).
It turned out I hadn't installed yaml correctly. This article and the instructions that linux itself gives (<3) helped me solve it:
https://code.google.com/p/php-yaml/wiki/InstallingWithPecl
I am not sure if this is the proper place for this, so I apologize if I should ask it elsewhere.
I am attempting to setup an old Drupal 5 site just for the purpose of being able to view it short term. To do this I need to install PHP 5.2 on the web server (Ubuntu 10.04). Does anyone have any suggestions on how to do this? I can't find a simple way to install old versions of PHP.
This is quite a problem, as you probably know PHP-5.2 is been dead for some time now, so you can't just apt-get install php. The best way to go is to compile it yourself.
You can grab a copy from the github PHP repository, and the follow the installation instructions (under ubuntu you'll need first to install the meta package build-essential to get all the tools needed to compile it).
Be aware that you should not run php5.2 in production by now!
PS: You'll probably have a better answer if you try superuser or serverfault.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I'd like to install the 'pthreads' PHP extension on Ubuntu. I'm using Ubuntu 12.04.1 LTS. And I can upgrade if needed. I really don't want to compile anything from source. For example recompile PHP from source sounds like a horrible idea to me.
In my view, the best option is to install this extension with aptitude command. For example like aptitude install php5-mysql. Another good idea is to use pecl pecl install pthreads. But is does not work for me because of the following error:
checking checking for ZTS... configure: error: pthreads requires ZTS, please re-compile PHP with ZTS enabled
Let me explain why I don't like the idea to recompile PHP from source:
I guess I should uninstall original PHP package then and all the dependencies. Because if I compile it over standard PHP then any packages update would overwrite my changes. And yes, another option is to keep PHP from updating. Anyway this introduces some extra work and makes the setup more complicated. We work in the distributed team. And I don't want other people to deal with this complicated setup on production servers.
I want to install updates on servers. And I don't want to recompile PHP because of security fixes etc.
I don't want to compile anything on production servers and do this many times. Then I should build my own packages and update them with new versions etc. Sorry but I'm not smart enough to do this. May be in 2-3 years but not now. Because there are a lot of things to keep in mind here. For example how, to replace standard PHP package with custom package while still satisfying all dependencies.
Some references:
Dynamically Configure PHP for Thread Safety --enable-maintainer-zts, or use YUM to install pThreads?
How to use Pthreads PHP extension (in Ubuntu) - Some talks about what I'm going to do here.
Building pthreads
This article seems to be old and not actual. I'll keep it for reference only. And I guess it should be read as 'PHP was not thread safe 3 years ago'.
Don’t Believe The Lies: PHP Isn’t Thread-Safe Yet
ZTS: [Z]end [T]hread [S]afety.
ZTS is a compile time option that cannot be enabled at runtime. It allows the PHP interpreter, which usually executes in a single thread, to be executed in many, each with their own isolated instance of the interpreter.
The only option for you appears to be a fresh build, and then using package building tools for your distribution.
I'm not able to advise on the creation of a deb directly, however, creating an rpm is quite trivial, https://github.com/krakjoe/spex there's a starting place for that, you can then use alien to turn an RPM into a deb if you are not able to find out how to create deb packages directly.
Building from source is going to be inescapable, unless you can find some repository with a thread safe build of PHP, with a complete build environment. To that end, the information http://pthreads.org/building may be of use to you. It really isn't that hard to build PHP, nor does it take many hours, on modern hardware you can have a build in less than a minute. You can and should take the opportunity to trim the fat from your installation.
On a side note, the article you reference about PHP not being thread safe is from 2008, it's very wrong. The core is thread safe, there are a few extensions that are inherently unsafe ( not abstracted badly, but fundamentally unsuitable ).
It seems, Ubuntu doesn't have a package for the thread-safe PHP in the official repositories.
Pthreads extension requires ZTS. Thus, you have two options:
compile it yourself:
find a .deb package somewhere, e.g. repositories of the other Debian-like systems.
I'd compile and package it myself using "checkintsall" utility. Thus, Apt will have ability to keep track of PHP version. I would also request Canonical for a package for ZTS PHP.
I have been compiling PHP for years with the configuration options I want. I compile extensions I use from source. Is there an advantage to doing this versus installing it from a package manager like apt-get or yum. I assumed it would also give me a leaner binary. I noticed that their are PHP modules in the repos such as "php53-gd". What if there wasn't a package available for something I wanted such as cURL for PHP?
I understand the disadvantages of compiling such as needing to download/install dependencies based on my configuration options. I'm not really concerned with that.
So the question is:
Compile PHP on Linux or just use apt-get / yum? Can I get all the things I need from the repos? Does anyone out there still compile it from source?
Any insight is appreciated! Thanks.
I compile from source every time. It's not hard to corral the mentioned issues with regards to compiling manually. For example, my ./configure settings are saved to a file which is version controlled, so when a new version of PHP is stable and I am ready to make the switch, I download and extract the file, then run this command:
./configure `sh /path/to/my/configure/php.sh`
Not too difficult. And because it's in version control, I can add notes as to why a module was added or removed.
Another benefit of manual compilation is it allows me to keep the PHP footprint as minimal as possible. I pass the --disable-all flag, then add the modules I need. However, there is a downside to this minimalist approach, recently I needed to install Magento, so I had to recompile with --enable-hash and --with-mcyrpt flags. Even though I needed to add new flags, it wasn't difficult to add to the configure file and recompile.
Compiling from source has a few quirks:
There are hundreds of config parameters and flags. And you might not know the optimal ones that need to be used.
if you rely on apt-get's PHP, then you can be assured that you will get the latest patches and security updates if you set up auto-upgrade on your server.
the configuration of php.ini varies a lot. Sometimes your OS may decide some defaults for you which may work better with the rest of the system.
installing extensions like xdebug or other packages are a lot easier with apt.
However, it's worth compiling php from scratch if you want to learn. Also if you don't use some portions of it, you can always disable them in configuration - but then again it might not make much difference to performance.
I compiled php for specific needs only, like :
very small hard disk space so required a minimalist php version
and/or
need only a few specific modules or extensions
and/or
needed for a specific application
and/or
needed to optimize performances: when compiling on the machine where it's used, this allows some performance improvements, if using compile options to get a real tuned version for your system,
and/or
needed multiple and different php versions on the same machine.
and/or
I had a specific nux distro like only a busybox, so no other options than compiling.
But for common usage, e.g. in 80% of the cases, it's not worth spending time to compile and better using the repository version. But I learned a lot by compiling.
Personally, it's a matter of opinion. If you are in a hurry, apt-get it, if you have time to learn and possibly need to reinstall 20 times...compile it.
There are tons of guides out there for PHP compiling. It has a ton of flags for configuration, especially for GD and other libraries. Personally if this is for learning and development, just get LAMP or use apt-get...especially if you need to use Apache
I feel the primary reason for compiling is to have latest version binary (stable or nightly). package managers (most distors) are often annoyingly slow in this respect.
The other reason is that its very common problem that production systems are not wholesale upgraded using package managers. Even if that can be easy. Since package managers create dependency chains and you may not want to upgrade those items. So just to pick one item, compiling is an option. It keeps everything else as it is. You ofcourse have to always study the upgrade issues and make sure nothing else will fail.
I'm trying to build a post-to-wall system. I followed a tutorial and it looks like I'm fairly close. However, loads of warnings come up when I post instead of the actual post. Do I need to setup a database somwewhere? I've never done much with PHP or databases, so excuse my ignorance.
http://beulahprint.ie/facebook_wallpost_system/
This all depends on whether you have underlying access to the machine that you are doing your development on.
If it is a linux machine and you are able to log into it then the following command will work for Red Hat (and it's derivatives: fedora, centos, etc...) as well as deban based systems such as ubuntu:
mysql --version
If this command reports some form of error they you will probably need to install mysql with one of the following commands:
sudo yum install mysql-server
OR
sudo apt-get install mysql-server php5-mysql
The sudo part makes you superuser so that you may install the software (not everyone) can install software you know. When you have run this command the computer will go through all the normal steps to install the software, but it will ask you a number of questions like: what would you like the root password to be? what IP is mysql going to run on? Luckily MySql fills most of these in by default.
If you are running on windows then it is just a matter of downloading the installation file from the mysql website, double clicking the .exe, and following the installation steps.
Good luck!
EXTRA: If you are looking for an easy way to access your mysql database you can't go far wrong with 'MySQL GUI Tools', just google it.
All of the errors you are seeing are due to a missing database and the inclusion of db files. You'll need to connect to the database (using PDO or MySQLi) and update it with the content you are entering. Looks like you are about halfway there.