Problems encountered when compiling PHP in Linux

Source: Internet
Author: User
Tags perl script
Problems encountered when compiling PHP in Linux-general Linux technology-Linux programming and kernel information. The following is a detailed description. 1. I use anonymous CVS to get the latest source code package, but no script file is configured!

You must install the GNU autoconf package to generate a configuration script file from configure. in. Run the command on the CVS server to obtain the./buildconf under the top-level directory of the source code. (Note: unless you run the configure -- enable-maintainer-mode option, the configuration script will not be regenerated, even if configure. the in file has been updated, so when you find configure. in has changed, and you have to do it manually. in config or config. after status is run, you should see a number like @ VARIABLE @ in your Makefile .)

   2. I encountered a Problem When configuring PHP to work in Apache.

It says it cannot find httpd. h, but I think it's there! Tell configure/setup script the location of Apache's top-level directory. That is to say, You need to mark -- with-apache =/path/to/apache, instead of -- with-apache =/path/to/apache/src.

   3. When I run conifgure, it says it cannot find the include file or some libraries: GD, gdbm, or some other packages!
You can check the configure script, the header file or non-standard library location, to send some special signs to the C Preprocessor. Example: CPPFLAGS =-I/path/to/include LDFLAGS =-L/path/to/library./configure

If your shell uses csh-variant, then it will be (Why ?) : Env CPPFLAGS =-I/path/to/include LDFLAGS =-L/path/to/library./configure

   4. An error occurred while compiling the file language-parser.tab.c with the prompt: yytname undeclared.

You need to update your Bison version. You can find the latest version at ftp://ftp.gnu.org/pub/gnu/bison.

   5. When I run make, it is normal at first, but eventually fails. When I connect to the final application, the error indicates that some files cannot be found.

Some old versions of make cannot put the compiled files under the functions Directory into the same directory, and try to run cp *. o functions and then run make to see if it is better. If so, you should update your GNU Make version.

   6. When connecting to PHP, a bunch of errors are reported: undefined references.

Check the connection lines in the file to make sure all related packages are correctly included. This is usually because '-ld' is missing and there are some database packages you want to support.

If you are connecting to Apache 1.2.x, do you remember to add some additional information in the EXTRA_LIBS line and re-run the Apache's Configure script? See the INSTALL file in the release package. Many people say that when they add '-ld', they will immediately get libphp4.a.

   7. I don't know how to compile PHP in Apache 1.3.

In fact, it is very simple. follow these steps:

Get Apache 1.3 source code, http://www.apache.org/dist/ in the following position.

Decompress the package in a directory, such as/usr/local/src/apache-1.3.

Compile PHP:./configure -- with-apache =/Under the PHP release package directory/ /Apache-1.3 (replaced by the actual apache-1.3 directory location) .

Run: make and then: make install to compile PHP and copy the required files to the Apache directory.

Change to your/ /Apache-1.3/src directory, edit the Configuration file, and add the following lines to the file: AddModule modules/php4/libphp4.a.

Input:./Configure and then: make.

In this way, you have an httpd file!

Note: You can also use the new Apache./configure script. See README. configure in the release package and check the INSTALL file in the PHP release package.

   8. I installed the Apache module step by step (under Unix), but when I opened the PHP script in a browser, it asked me if I wanted to save it.

This means that your PHP module is not loaded. You can check from the following three points:

Make sure that the Httpd you run is the Httpd you just compiled for PHP. You can run:/path/to/binary/httpd-l.
If you do not see the mod_php4.c column, you have run the incorrect Httpd. You 'd better reinstall it.

Make sure you are in Apache. the correct Mime type is added to the conf file. it should be like this: AddType application/x-httpd-php3. php3 (PHP 3) or AddType application/x-httpd-php. php (PHP 4) also ensures that the AddType line is not included in Or Block, they will make it invalid.

Finally, the default configuration files of Apache 1.2 and Apache 1.3 are located differently. You should check the location of the configuration file with AddType added. You can put some obvious errors or changes in httpd. conf so that the system will notify you if the file is read.

   9. the system uses -- activate-module = src/modules/php4/libphp4.a. The file does not exist, I have to change it to -- activate-module = src/modules/php4/libmodphp4.a, but it does not work! What should I do?

Please note that libphp4.a does not exist. The apache process will create it!

   10. I Want To compile PHP into a static module of Apache and use -- activate-module = src/modules/php4/libphp4.a. However, the system says that my compiler is not ANSI compatible.

This error message is misled by Apache and can be corrected by updating the version.

   11. When I use -- with-apxs to compile PHP, I always get some strange errors.

In this case, you can check from three points. First, for some reason, Apache did not create an appropriate flag variable when compiling the apxs Perl script and found your apxs script (try the which apxs command, usually in/usr/local/apache/bin/apxs or/usr/sbin/apxs. open it and find the following line: my $ export _cflags_shlib = ''; # substituted via Makefile. tmplmy $ export _ld_shlib = ''; # substituted via Makefile. tmplmy $ export _ldflags_shlib = ''; # substituted via Makefile. tmpl

If you see this, the problem lies here, because the value contains spaces or other incorrect values, such as 'q ()'. Change it like the following: my $ export _cflags_shlib = '-fpic-DSHARED_MODULE'; # substituted via Makefile. tmplmy $ export _ld_shlib = 'gcc '; # substituted via Makefile. tmplmy $ export _ldflags_shlib = q (-shared); # substituted via Makefile. tmpl

The second possible cause is that the. apxs script Red Hat version is incorrect only on Red Hat 6.1 and 6.2. Check this line: my $ CFG_LIBEXECDIR = 'modules'; # substituted via APACI install

If you see it, change it to the following line: my $ export _libexecdir = '/usr/lib/apache'; # substituted via APACI install

Third, if you re-configure or reinstall Apache, you must execute make clean after./configure and before make.

   12. During make, I got a lot of errors about microtime and a lot of RUSAGE _ stuff.

During the installation of make, if you see the following error: microtime. c: In function 'php _ if_getrusage': microtime. c: 94: storage size of 'usg' isn' t knownmicrotime. c: 97: 'rusage _ SELF 'undeclared (first use in this function) microtime. c: 97: (Each undeclared identifier is reported only oncemicrotime. c: 97: for each function it appears in .) microtime. c: 103: 'rusage _ CHILDREN 'undeclared (first use in this function) make [3]: *** [microtime. lo] Error 1 make [3]: Leaving directory '/home/master/php-4.0.1/ext/standard' make [2]: * ** [all-recursive] Error 1 make [2]: Leaving directory '/home/master/php-4.0.1/ext/standard' make [1]: * ** [all-recursive] Error 1 make [1]: Leaving directory '/home/master/php-4.0.1/ext' make: *** [all-recursive] Error 1

That's your system error. You should fix the/usr/include file. The specific method is to install the glibc-devel package that matches your glibc. These errors are definitely irrelevant to PHP. To prove this, you can do this: $ cat> test. c < X $ gcc-E test. c>/dev/null

If an error occurs, your contained files are damaged.

   13. I Want To Upgrade PHP. Where can I see the./configure line used for the initial configuration and installation of php I am running?

You can see that you have installed the config. nice file in the PHP source directory. If not, there is another method. You only need to run

The first line of the script on the output page is the./configure line, which is the line you used to configure PHP.

   14. When compiling PHP with GD library, it does not give some strange errors, or it produces segfaults errors during execution.

Make sure that you use the same dependent libraries (such as libpng) when compiling the GD library and PHP ).
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.