Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Apache 2.x under Unix system

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Apache 2.x under Unix this section includes instructions and tips for installing PHP under Apache 2.x on the Unix platform.

Warning does not recommend using threaded MPM in products that use Apache 2. The default MPM for pre-branching MPM,Apache 2.0 and 2.2 should be used. For this reason, see the related entries in FAQ that use threaded MPM's Apache2.

It is recommended to read the »Apache documentation to learn about the Apache 2.x server and the detailed installation parameters.

You can download the latest version of Apache from the »Apache download site and select the appropriate version of PHP to download according to the above. This wizard contains only the most basic content and only allows Apache 2.x and PHP to work properly. Please read the »Apache documentation for more information. All version numbers are omitted here to ensure the correctness of this article. You need to replace the "NN" of this article with the corresponding version number.

There are currently two popular versions of Apache 2.x-2.0,2.2. Although there are various reasons for choosing a version, we recommend using the latest version of Apache 2.2 if you can consider it. Of course, the following description also applies to Apache 2.0 and 2.2.

Obtain the Apache source code package from the places listed above, and then decompress:

Gzip-d httpd-2_x_NN.tar.gztar-xf httpd-2_x_NN.tar similarly, obtain the PHP source code package and decompress it:

Gunzip php-NN.tar.gztar-xf php-NN.tar compiles and installs Apache. Please refer to the Apache installation documentation for more details on compiling Apache.

Cd httpd-2_x_NN./configure-- enable-somakemake install now has Apache 2.x.NN installed in / usr/local/apache2. This installation supports loadable modules and standard MPM prefork. You can then start the Apache server using the following command:

/ usr/local/apache2/bin/apachectl start if successful, you can stop the Apache server and continue to install PHP:/usr/local/apache2/bin/apachectl stop

Now you need to configure and compile PHP. Here you can customize the PHP with a variety of parameters, such as which extension packs to start support, and so on. Use the. / configure-- help command to list all the currently available parameters. In this example, an example of configuration on Apache 2 with MySQL support is given.

If you compile Apache from source code as described above, the following example will correctly match the path of apxs. If Apache is installed by other means, you need to adjust the path of apxs accordingly. Note that in some distributions, apxs may be renamed to apxs2.

Cd.. / php-NN./configure-- with-apxs2=/usr/local/apache2/bin/apxs-- with-mysqlmakemake install if you decide to change the configuration options after installation, just repeat the last three steps configure,make and make install, and then restart Apache for the new module to take effect. Apache does not need to be recompiled.

Note that unless explicitly prompted, the "make install" command installs PEAR, various PHP tools such as phpize, PHP CLI, and so on.

Configure php.ini

Cp php.ini-development / usr/local/lib/php.ini can edit php.ini to set options for the PHP runtime. If you want to put this file in a different location, you need to add the-- with-config-file-path=/path option in step 5.

If php.ini-production is selected, be sure to read the list of changes that will affect the execution of PHP.

Edit the httpd.conf file to invoke the PHP module. The path to the right of the LoadModule reach must point to the PHP module in the system. The above make install command may have done this, but be sure to check.

LoadModule php5_module modules/libphp5.so tells Apache to resolve a specific extension to PHP, for example, to have Apache parse the extension .php into PHP. To avoid potential dangers, such as uploading or creating exploit.php.jpg-like files that are executed as PHP, we no longer use the Apache AddType directive to set it. With reference to the following example, you can simply interpret the required extension as PHP. We demonstrate to add .php.

SetHandler application/x-httpd-php or, you also want to run .php, .php2, .php3, .php4, .php5, .php6, and .phtml files as PHP, we don't need additional settings, just follow this:

SetHandler application/x-httpd-php, the .phps file can then be processed by the PHP source filter so that it can highlight the source code when displayed, as follows:

SetHandler application/x-httpd-php-sourcemod_rewrite also helps highlight the source code of .php files that you don't need to run without renaming them to .phps files:

RewriteEngine OnRewriteRule (. *\ .php) $$1 [H=application/x-httpd-php-source] do not launch the PHP source filter on a system that is officially in production operation, as this may reveal system secrets or sensitive information embedded in the code.

Start the Apache service as usual:

/ usr/local/apache2/bin/apachectl start or

Service httpd restart follows the steps above to make Apache 2.x use PHP as a SAPI module. Of course, both Apache and PHP have many configuration options, and you can use. / configure-- help in the corresponding source code directory for more information.

If you want to compile a multithreaded version of Apache, you can choose to replace the standard prefork MPM with worker MPM at compile time. Just use it in step 3 above:

-- with-mpm=worker

It is best not to take this step if you are not very clear about the consequences and generally understand what it means. Please refer to the section on »MPM-Modules in the Apache documentation for more information.

Note:

The use of MultiViews in PHP is discussed in Apache MultiViews FAQs.

Note:

To compile a multithreaded version of Apache, the system must support multithreading. This also means that PHP needs to be compiled into Zend Thread Safety (ZTS), which is in the experimental phase, so not all extensions are available. Standard prefork MPM-Module is recommended for compiling Apache.

Apache 1.3.x [edit] Last updated: Fri under Lighttpd 1.4Unix system on Unix platform, Apache 2.x-[16 notes] updown1nmmm at nmmm dot nu4 years agoWhen I upgrade to apache 2.2 under 23 Aug 2013add a noteUser Contributed NotesUnix system, this:

AddType application/x-httpd-php .php5

AddType application/x-httpd-php .php42

AddType application/x-httpd-php .php4

AddType application/x-httpd-php .php3

AddType application/x-httpd-php .php

AddType application/x-httpd-php .phtm

AddType application/x-httpd-php .phtml

AddType application/x-httpd-php .asp

... does not worked for me, so I did this:

SetHandler application/x-httpd-php

Another interesting point with Apache 2.2 is following.

Let suppose we installed PHP as module. But for some directory, we need to use PHP as CGI (probably because of custom configuration). This can be done using:

SetHandler none

AddType application/x-httpd-php-custom .php

Action application/x-httpd-php-custom / cgi-bin/php-huge

Note type must be different than "application/x-httpd-php" and also you need to deactivate the handler on sertain extention. You can do mixed configuration:

SetHandler none

AddType application/x-httpd-php-custom .php

Action application/x-httpd-php-custom / cgi-bin/php-huge

In such case files like * .php5 and so on will be parsed via module, but * .php will go to php-huge executable.updown1chris@gerlt-dot- net6 years agoInstall issues on Redhat, specifically RHEL4 with php4 already installed:

I discovered that there was an issue caused by redhat loading php4 in another file seperate from the httpd.conf file! This took me hours to discover. Make sure you know if the apache config file (httpd.conf) is loading configurations from a directory (or another file (s)) as well. If so, look in there for any php module loading which could conflict with the new module you are compiling/installing.updown1praveen dot k at masconit dot com8 years agoHi too had same problem with multiview like when i execute http://huey/admin/test.php it used to compile but when i use http://huey/admin/test it wouldnt recognise it as php file... I worked it out with the addhandler method and AddType in different line and setting multiview for directive

"multiviews Options Indexes FollowSymLinks MultiViews"

The directives u can set it to root directory so now when u type pn test it will search in precendence for test.php, test.html if any.

Its working for me with apache2.0.47 and php 4.3.9 on solaris

Praveenupdown-1Anonymous4 years agoSolution for fedora is yum install mysql-devel. Then set-with-mysql=/usr/include/mysql/

Monguestoupdown-1Tom420.Duhamel4 years agoI have successfully installed Apache 2.2.11 and PHP 5.2.8 under Red Hat 9.0 on a Pentium 166 with 32 MB of RAM.

While I used RH9, the worst possible case, these notes are probably good for RH-based distributions too (Red Hat Enterprise, Fedora, CentOS...)

If you want to install MySQL, it needs to be installed before PHP because PHP requires some libraries be available.

One think important when picking up a binary distribution of MySQL is to download all four packages: MySQL-server, MySQL-devel, MySQL-client and MySQL-shared. Note: The MySQL was bundled with PHP 4 but is not anymore in PHP 5.

Then you need to install Apache before PHP, because again PHP needs some libraries be available. I installed Apache 2 from source, using the very last version available, which is 2.2.11.

I installed PHP 5.2.8 from source. Here, I had a number of problems, but none which I could not resolve easily, some of them with a little help from different forums I found through Google.

Rembember: When it says you need a package named xyz and you notice there is also one named xyz-devel, grab it.

Most of the packages I got from:

Http://legacy.redhat.com/pub/redhat/linux/9/en/os/i386/RedHat/RPMS/

A similar page exists for other versions of Red Hat

And:

Http://rpmfind.net/

This site has an updated version of some of the packages. Make sure to use only the one labeled for you version (in my case, Red Hat 9.0) or it will not likely work.

You already have glibc and glibc-common installed, but you need to get glibc-devel and glibc-kernheaders. Make sure to match glibc's version (rpm-Q glibc). Note: When it says kernel-header is a required dependency, that's glibc-kernheader (not kernel-source). You will also need binutils (no need to match the version), and gcc and cpp (version must match).

You need zlib-devel (zlib is probably already installed, match the version you have).

If you install the GD extension, the actual library is already bundled with PHP 5 (use that one, they have done some changes in there, so don't upgrade), but you will need to install libpng and libpng-devel (match version, or disable in configure if you don't want) and libjpeg (no-devel with that one).

You will also need libxml2. Now there were a problem, because PHP requires libxml2 be 2.6or greater, but Red Hat only supplied 2.5.4-1 for RH9 (if you have a more recent distro, you might be more lucky). After looking for a while, I decided to grab the source code for the most recent distribution at the official website (http://xmlsoft.org/) and compiled.

Hope my post is useful to someone. Please, share your experience when compiling/installing for your particular platform and setup. Remember how hard it's been for you the very first time. I confess, my very first server installation took me nearly a week and I was glad others helped me.updown0svepa at milestone42 dot com1 year agoOn 64-bit Fedora systems (I'm using Fedora 14), configuring PHP to use the MySQL libraries installed as part of the distribution gives the following error if you follow the default instructions in this manual.

Cannot find libmysqlclient under / usr

Modifying he following invocation of configure as follows:

. / configure-- with-apxs2=/path/to/apxs-- with-libdir=lib64-- with-mysql

Should work.

Note the addition of-with-libdir=lib64

This points the configure script to look for 64-bit mysqlclient libraries.updown0susie916 years agofor slackware 10.2 users with apache2, mysql5, and trying to install php5:

When following the directions above, after this step:

. / configure-with-apxs2=/usr/local/apache2/bin/apxs-with-mysql

I kept getting this error:

"Unable to find MySql header files...."

The only way i could get php5 with mysql support was to compile MySql5 from source, and not use the binary as the mysql site recommends.

Then i was able to. / configure successfully, but for some reason php was configured to compile the CGI version.

So, had to use this. / configure line:

. / configure-- with-apxs2=/usr/local/apache2/bin/apxs-- with-mysql=/usr/local/mysql-- disable-cgi

Alternatively, you could install php4 which does bundle the MySql client files.updown0jaya7 years agoPHP 5.1.4 INSTALLATION on Solaris 9 (Sparc)

Solaris9 Packages Installed:

Verify required package installation:

Root# pkginfo SUNWbtool SUNWsprot SUNWtoo SUNWhea SUNWarc\

SUNWlibm SUNWlibms SUNWdfbh SUNWxglh SUNWcg6h

Uninstall Default Apache Packages:

Root# / etc/init.d/apache stop

Root# pkginfo | grep Apache

Root# pkgrm SUNWaclg SUNWapchd SUNWapchr SUNWapchu

Create installation Directory:

Root# mkdir / phpdata/

Download Required Packages from Sunfreeware:

Install libiconv-1.8 and gcc3.3.2 packages

Root# pkgadd-d. / libiconv-1.8-sol9-sparc-local

Root# pkgadd-d. / gcc-3.3.2-sol9-sparc-local

Set LD_LIBRARY_PATH, CC and PATH variables

Root# LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib/sparcv9/:\

/ usr/lib:/usr/openwin/lib:/opt/local/lib:/usr/local/ssl/lib:\

/ usr/local/apr/lib:/opt/mysql/mysql/lib

Root# CC=gcc

Root# PATH=$PATH:/usr/ucb:/usr/local/bin/

Root# export LD_LIBRARY_PATH CC PATH

Install apr-1.2.2 and aprutil-1.2.2 packages

Root# gzcat apr-1.2.2.tar.gz | tar xvf-

Root# cd apr-1.2.2

Root#. / configure

Root# make

Root# make install

Root# cd..

Root# gzcat aprutil-1.2.2.tar.gz | tar xvf-

Root# cd apr-util-1.2.2/

Root#. / configure-- with-apr=/usr/local/apr/

Root# make

Root# make install

Install gawk-3.1.4, expat-1.95.5, db-4.2.52.NC

Gdbm-1.8.3, libgcc-3.3 and libxml2-2.6.16 packages

Root# cd..

Root# pkgadd-d. / gawk-3.1.4-sol9-sparc-local

Root# pkgadd-d. / expat-1.95.5-sol9-sparc-local

Root# pkgadd-d. / db-4.2.52.NC-sol9-sparc-local

Root# pkgadd-d. / gdbm-1.8.3-sol9-sparc-local

Root# pkgadd-d. / libgcc-3.3-sol9-sparc-local

Root# pkgadd-d. / libxml2-2.6.16-sol9-sparc-local

Install GNU make package

Root# gzcat make-3.81.tar.gz | tar xvf-

Root# cd make-3.81

Root#. / configure

Root# make

Root# make install

Root# cd..

Install mysql-standard-5.0.22 package

Search for user mysql

Root# grep mysql / etc/passwd

Root# grep mysql / etc/group

If not found create user and group mysql

Root# groupadd mysql

Root# useradd-G mysql mysql

Root# pkgadd-d. / mysql-standard-5.0.22-solaris9-sparc.pkg.gz

Install openssl-0.9.7g package

Root# gzcat openssl-0.9.7g.tar.gz | tar xvf-

Root# cd openssl-0.9.7g

Root#. / config shared

Root# make

Root# make install

Root# cd..

Install Apache2 package

Root# gzcat httpd-2.2.0.tar.gz | tar xvf-

Root# cd httpd-2.2.0

Root#. / configure-- enable-so

Root# / usr/local/bin/make

Root# / usr/local/bin/make install

Root# cd..

Install php-5.1.4 package

Root# gzcat php-5.1.4.tar.gz | tar xvf-

Root# cd php-5.1.4

Root#. / configure-- with-apxs2=/usr/local/apache2/bin/apxs\

-with-ldap-with-mysql=/opt/mysql/mysql/

Root# / usr/local/bin/make

Root# / usr/local/bin/make install

Root# cp php.ini-dist / usr/local/lib/php.ini

Edit httpd.conf to load the PHP module

And to parse certain extensions as PHP

Root# vi / usr/local/apache2/conf/httpd.conf

LoadModule php5_module modules/libphp5.so

AddType application/x-httpd-php .php .phtml

Start Apache

Root# / usr/local/apache2/bin/apachectl start

Add environmental variables below HTTPD

Root# vi / usr/local/apache2/bin/apachectl

LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib/sparcv9/:

/ usr/lib:/usr/openwin/lib:/opt/local/lib:/usr/local/ssl/lib:

/ usr/local/apr/lib:/opt/mysql/mysql/lib

PATH=/bin:/sbin:/usr/ccs/bin:/usr/sbin:/usr/openwin/bin:\

/ usr/ucb:/usr/local/bin/

Export LD_LIBRARY_PATH PATH

Create Apache Startup Scriptupdown0felixcca at yahoo dot ca7 years agoI've (painfully) discovered that installing PHP5 with "make install" under SuSe 9.2 is NOT a good idea.

Http://www.aditus.nu/jpgraph/apache2suse.php

This page explains how to install it without breaking everything that's php-related in the Apache2 configuration. Its first purpose, though, is to show how to have php 4 and 5 to cohabit properly.updown0frank@ethisoft7 years agoUsing Apache2 & PHP5 work perfectly fine & safe together.

-all core modules are safe in Zend Engine 2

-third-party-libraries should be avoided

-semaphores and shared memory enables you to ensure yourself that your application/website is thread-safe also with non-thread-safe PHP modulesupdown0happyboy at php dot org8 years agoFILE truncated!

During the make process should u receive an error declaring ext/ctype/ctype.lo (or another file) is truncated then you need to 'make clean' prior to a healthy' make' and 'make install.'

Looking into your ext/ directory you may find the offensive file to be 1 byte long.updown0mihai dot sandu at gtstelecom dot ro8 years agoFor the SuSE9.2 install of PHP5.

First:

If building on a x64 platform, please set LDFLAGS= "- L/usr/lib64" before configure.

As for install, it suffices to go to / etc/apache2 and:

Ln-s sysconfig.d/loadmodule.conf httpd2-prefork.conf

And then make installupdown0neil8 years agoTo install mysql and mysqli with PHP5 do the following:

After doing:

. / configure-with-mysql=/path/to/mysql_config-with-mysqli=/path/to/mysql_config

Do this:

"

If you want to use both the old mysql and the new mysqli interface, load the Makefile into your editor and search for the line beginning with EXTRA_LIBS; it includes-lmysqlclient twice; remove the second instance

"

Then you can:

Make

Make install

.

Pleasse note: you must have mysql-dev installed (RPM or source) or you will not have the mysql_config file at all. The standard, server, and client installations of MySQL do not include it. I read somewhere that the mysql and mysqli paths must be identical.

Quoted from Michael Kofler at the following link:

Http://www.kofler.cc/forum/forumthread.php?rootID=3571updown0Dan Scott (dan dot scott at acm dot org) 8 years agoBuilding PHP 5.x with Apache2 on SuSE Professional 9.1 Universe 9.2

SuSE uses a rather fragmented set of Apache configuration files stored in / etc/apache2/. When you configure PHP 5.x with:

$. / configure-with-apxs2=/usr/sbin/apxs2

$make

Everything builds just fine; but when you issue:

$su-c "make install"

The unconventional Apache conf file layout confuses the install-sapi section of the Makefile and the process halts with the following error:

Apxs:Error: Config file / etc/apache2/httpd2-prefork.conf not found.

Make: * * [install-sapi] Error 1

At this point only the PHP SAPI library has been copied into place; the rest of the files (like PEAR scripts, PHP-CLI, etc) have not been installed. But never fear! You can overcome this problem with the following steps:

1. Edit Makefile and change the following line to remove "install-sapi":

Install_targets = install-sapi install-cli install-pear install-build install-headers install-programs

2. Issue the make install command again:

$su-c "make install"

3. Add the PHP module type instructions to the Apache configuration. As root, create a new file, / etc/apache2/conf.d/php5.conf that contains the following lines:

LoadModule php5_module / usr/lib/apache2/libphp5.so

AddType application/x-httpd-php php

-And that's it. Everything else is just as the documentation suggests it should be.updown-2nabil at world dot com5 years agoI couldn't start Apache2 after installing PHP5 in archlinux, I got this error:

Cannot load /... / libphp5.so into server: /... / libphp5.so: undefined symbol: _ efree

The solution was "make clean" on the PHP5 source directory, then. / configure, make & make install again.updown-3peep at imtarget dot identicloak dot com4 years agoConfiguration notes for cent5.2, April 2009.

Note: I'll walk you through my steps, so you can do it custom yerself. It's possible that I am an idiot and there are much easier ways to do this. But this worked for me. Also, you could just use my configure script and yum command line and probably have it work okay.

Scenario

-

I'm setting this up for a fairly typical drupal install, with a mysql backend. I set up the dev server with the php package from the cent yum repo, and the customer ran Drupal with that for a while, but now wants a more current PHP than the cent package provides.

My approach for determining required modules

-

1. Get the list of the modules

$php- m | grep-v-e Modules]-e ^ $> php-default-modules

2. Create the configure script

$for i in $(cat php-default-modules); do echo-n "--with-$i" > > phpconfigure.sh; done

3. Run the configure script, and iterate through the "Configure script errors" section below until it completes properly

4. At the end of the output, look for a notice of unknown options

Notice: Following unknown configure options were used:

-- with-date

-- with-gum-disease

Check'. / configure-- help' for available options

5. As suggested, execute'. / configure-help' and correct the options. The "for" command above indiscriminately inserts "- with-" for all modules, but bundled modules may require "- enable-" instead, so mostly you'll be changing those. For modules that are enabled by default you'll need to remove the entry.

6. Add anything else you personally want or need. I like to add "--enable-safe-mode".

I configured with the following command line:

Php-5.2.9] $. / configure-- with-mcrypt-- with-mhash-- with-bz2-- enable-calendar-- with-curl-- enable-dbase-- enable-exif-- enable-ftp-- with-gd-- with-gettext-- with-gmp-- with-iconv-- enable-mbstring-- with-mime_magic-- with-mysql-with-mysqli-- with-openssl-- enable-pcntl-- with-pdo_mysql-- with-pdo_sqlite-- With-pspell-enable-shmop-enable-sockets-enable-sysvmsg-enable-sysvsem-enable-sysvshm-enable-wddx-with-zlib-enable-safe-mode

As such, i needed a number of packages installed. Now I haven't tracked additional packages over base--there may be required packages that I happened to have installed for other things. But this is a pretty good list, i reckon:

Php-5.2.9] $sudo yum install mcrypt libmcrypt mhash libmhash libxml2-devel openssl-devel bzip2-devel curl-devel libjpeg-devel libpng-devel gmp-devel mysql-devel aspell-devel zlib zlib-devel

Configure script errors

-

In my experience, these errors have been due (with any software, PHP included) mostly to missing development packages, which contain the libraries and headers needed to compile support for that library's function into the application.

This becomes a process of:

-executing the. / configure script and looking at the error

-installing the devel package providing the resource referenced by the error (google using the error as search term as needed)

-repeat until the. / configure script makes it through without error

Upshot: identify the software referenced by the error, and install it.

Example

-

Example error:

Configure: error: Cannot find OpenSSL's

Example explanation

Configure is looking for a header (and probably a lot of other stuff) from a missing openssl package.

Example solution:

Php-5.2.9] $sudo yum install openssl-devel

Compiling (and testing and submitting)

-

With. / configure working, you're ready to compile. I think it's important to test and submit the tests to the developers, you do what you want.

$make;make test

Installing

-

$sudo make install

(be sure you, heh, have the system php removed before you do this step. Seriously)

Best of luck!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report