Cross-compile apache2 + PhP5

Source: Internet
Author: User
Tags fully qualified domain name
Compiling environment:
1. Linux host: fedora7
2. architecture of the Development Board: MIPS
3. Cross Compiler: gcc.3.4.2
4. Cross-compiler Directory:/opt/gcc342
5. Software Version: httpd-2.2.13.tar.gz

Compilation and installation of apach2:
1. Configure
Cc =/opt/gcc342/bin/mipsel-Linux-gcc cpp =/opt/gcc342/bin/mipsel-Linux-cpp ld =/opt/gcc342/bin/mipsel-Linux -ld ar =/opt/gcc342/bin/mipsel-Linux-ar objdump =/opt/gcc342/bin/mipsel-Linux-objdump as =/opt/gcc342/bin/mipsel -Linux-as strip =/opt/gcc342/bin/mipsel-Linux-strip. /configure -- Host = mipsel-Linux -- target = mipsel-Linux -- Build = i686-pc-linux-gnu -- prefix =/uer/local/apache2 -- With-Program-name = apache2 -- enable-module = so -- enable-module = rewrite -- enable-shared = max

In the above command:
1) Cross-compiler environment variable settings: cc =/opt/gcc342/bin/mipsel-Linux-gcc cpp =/opt/gcc342/bin/mipsel-Linux-cpp ld =/opt/gcc342/bin/mipsel-Linux -ld ar =/opt/gcc342/bin/mipsel-Linux-ar objdump =/opt/gcc342/bin/mipsel-Linux-objdump as =/opt/gcc342/bin/mipsel -Linux-as strip =/opt/gcc342/bin/mipsel-Linux-strip. /conf is the setting of some environment variables of the cross compiler.
2) Cross-compilation settings: -- Host = mipsel-Linux -- target = mipsel-Linux -- Build = i686-pc-linux-gnu;
-- Host = platform on which the software runs (the system of your development board) host = architecture-vendor-kernel-standard library (mipsel-Linux indicates mips architecture, unknow vendor, Linux kernel, GNU glibc standard library .)
-- Target = Why platform service of software
-- Build = under which platform the software is compiled (the system where you compile the target file)
3) apache2 Configuration:
-- With-Program-name = apache2: Change the generated file name. The default value is httpd.
-- Enable-module = So is used to extract the Apache core module supported by DSO. This is important for the dynamic module to be installed later, and PhP5 is the dynamic module to be installed later.
-- Enable-module = rewrite module is used to implement address rewriting. Because the rewrite module requires dBm support, if it is not compiled into Apache during initial installation, in the future, you need to re-compile the entire Apache to implement this function. Therefore, unless you are sure that the rewrite module will not be used in the future, we recommend that you compile the rewrite module during the first compilation.
-- Enable-shared = max when compiling Apache, all Apache standard modules except so are compiled into DSO modules. Instead of compiling it into the Apache core.

2. Compile and install
Make;
Make install;

3. Copy the/uer/local/apache2 directory to the file system directory of the target board to Remove useless files. In fact, files are useful, but the target board is too small to delete.
Keep the bin/apache2 CONF/module/lib/htdocs/file and check whether the configuration in CONF/apache2.conf is desired.

4. Start on the target board
/Uer/local/apache2/bin/Apache-K start

5. Enter the local address in the browser and "it work!" will appear !", The configuration is successful.

6. Errors:
1). In the/configure process, configure: Error: cannot check for file existence when cross compiling occurs. The specific cause is not found and should be caused by cross compilation.
Solution: locate the error in the corresponding directory and remove {(Exit 1); Exit 1 ;}; my problem usually occurs in srclib/APR/configure.
2) Compile:
A ../include/apr_want.h: 93: Error: redefinition of 'struct iovec'
Solution: In srclib/APR/include/apr_want.h, inject struct iovec
B../dftables: cannot execute binary file
Solution: because cross-compiled files cannot be executed on the compiled host, compiling a local version of dftables overwrites srclib/PCRE/dftables.
C ../gen_test_char: cannot execute binary file
Same as above
D. undefined reference to 'pthread _ sigmask'
Solution: Add-lpthread to the ar_libs variable in build/config_var.mk.
3) Start
A. the file cannot be found.
Solution: Check whether the path set in/usr/local/apache2/CONF/apache2.conf is correct or whether the file exists.
B. apache2: Bad User Name Daemon
Solution: Run adduser daemon.
C. "apache2: apr_sockaddr_info_get () failed for (none)
Apache2: cocould not reliably determine the server's fully qualified domain name, using 127.0.0.1 for servername"
Replace # servername www.example.com: 80 in the/usr/local/apache2/CONF/apache2.conf file with servername localhost: 80
D. "(125) address already in use: make_sock: cocould not bind to address 0.0.0.0: 80
No listening sockets available, shutting down"
Port 80 is in use, indicating httpd already exists

PHP 5 Compilation and installation:
1. configue
Cc =/opt/gcc342/bin/mipsel-Linux-gcc cpp =/opt/gcc342/bin/mipsel-Linux-cpp ld =/opt/gcc342/bin/mipsel-Linux -ld ar =/opt/gcc342/bin/mipsel-Linux-ar objdump =/opt/gcc342/bin/mipsel-Linux-objdump as =/opt/gcc342/bin/mipsel -Linux-as strip =/opt/gcc342/bin/mipsel-Linux-strip. /configure -- Host = mipsel-Linux -- target = mipsel-Linux -- Build = i686-pc-linux-gnu -- prefix =/uer/local/PhP5 -- without-iconv -- disable-all -- with-apxs2 =/usr /local/apache2/bin/apxs
-- With-apxs2 =/usr/local/apache2/bin/apxs indicates that PhP5 is installed for the Apache shared Module

2. Compile and install
Make;
Make install;
If you install it as a dynamic library, you only need to copy libphp5.so to/usr/local/apache2/modules. If you use CLI or CGI Mode, you may also need PHP and PHP-CGI.

3. Modify the/usr/local/apache2/CONF/apache2.conf file.
After # loadmodule foo_module modules/mod_foo.so, add
Loadmodule php5_module modules/libphp5.so

In Add
Addtype application/X-httpd-PHP. php

4. Add index. php under htdocs/and enter

5. Restart apache2. It will support vphp

6. View index. php In the browser

7. Errors:
1) error: Impossible constraint in 'asm'
The cross-compilation environment is incorrect. Set the include header to the host path (for example,-I/usr/include), which should be the header of the Cross-compiler (for example,-I/opt/gcc342/include ); use -- With-iconv = shared,/opt/gcc342/
2) undefined reference to 'php _ load_extension'
In configure, if it is cross-compiling, she sets dlopen to no found and only needs to remove found = No.
3) syntax error on line 53 of/usr/local/apache2/CONF/apache2.conf: cannot load/usr/local/apache2/modules/libphp5.so into server: file not found
A. The loadmodule php5_module modules/libphp5.so directory path in/usr/local/apache2/CONF/apache2.conf is incorrect.
B. Caused by 2)

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.