Install Apache+PHP on CentOS4.4
On the current AMD x64 platform, I install CentOS4.4 and related development packages. This article is How-To set up Apache + PHP in Linux box. It takes me about two hours in fixing this issue. So it seems in pretty good.
1. Download the latest Apache and PHP distributions
httpd-2.2.4.tar.bz2
php-4.4.6.tar.gz
2. Install Apache
Un-compress the install file:
# bunzip httpd-2.2.4.tar.bz2
# tar xvf httpd-2.2.4.tar
# cd httpd-2.2.4
For our Web GUI needs the httpd to be owned by supervisor “root”, the following environment parameter must be added before compiling and building.
# env CFLAGS=”-Wall -DBIG_SECURITY_HOLE” ./configure –prefix=/usr/local/apache –enable-so
–predix indicates the installing path. –enable-so means compiling in DSO mode.
If the configure scripts completes successfully, you can then proceed:
# make && make install
Apache show compile without any hitches.
3. Install PHP
Unpack the PHP distribution, change to the PHP directory and run the configure script, you need to pass certains options to the script.
# tar zxvf php-4.4.6.tar.gz
# cd php-4.4.6
Here’s a complete configure script with Apache-support options.
#./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache/bin/apxs
–with-apxs2 means it supports Apache2.0, this option must be appended.
# make && make install
After it has installed, we need to install the PHP.ini file:
# cp php.ini-optimized /usr/local/lib/php.ini
Note, the above copying step is not always required.
If the installation completes successfully, there will be a file named “libphp4.so” in /usr/local/apache/modules:
# ls /usr/local/apache/modules/
httpd.exp libphp4.so
4. Modify the /usr/local/apache/conf/httpd.conf to enable PHP options. Here’s an example from BA880:
# vi /usr/local/apache/conf/httpd.conf
————————————————–
ServerRoot “/usr/local/apache”
Listen 80
LoadModule php4_module modules/libphp4.so
User root
Group root
ServerAdmin you@example.com
ServerName barcelona
DocumentRoot “/opt/work/httpd/html/”
Options Indexes MultiViews
AllowOverride None
DirectoryIndex index.html index.php default.php
Order allow,deny
Allow from all
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
DirectoryIndex index.html index.php default.php
AllowOverride AuthConfig
Order allow,deny
Allow from all
DirectoryIndex index.html
Order allow,deny
Deny from all
Satisfy All
ErrorLog logs/error_log
LogLevel warn
LogFormat “%h %l %u %t “%r” %>s %b “%{Referer}i” “%{User-Agent}i”” combined
LogFormat “%h %l %u %t “%r” %>s %b” common
LogFormat “%h %l %u %t “%r” %>s %b “%{Referer}i” “%{User-Agent}i” %I %O” combinedio
CustomLog logs/access_log common
ScriptAlias /cgi-bin/ “/usr/local/apache/cgi-bin/”
AllowOverride None
Options None
Order allow,deny
Allow from all
DefaultType text/plain
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
————————————————–
I’ve marked the modified texts by blue font. Note, this special httpd’s owner is “root”.
5. Install Web GUI for BA880:
# mkdir -p /opt/work/httpd
# scp -rf 192.168.3.246:/os/httpd/* /opt/work/httpd
# mv /etc/export /etc/exports.bak
# mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
# ln -s /opt/work/httpd/related/var/etc/exports /etc/exports
# ln -s /opt/work/httpd/related/var/etc/smb.conf /etc/samba/smb.conf
6. Start up Apache:
# /usr/local/apache/bin/apachectl -k start
7. Verify its working status:
# ps -x | grep httpd
6156 ? S 0:00 /usr/local/apache/bin/httpd -k start
6157 ? S 0:00 /usr/local/apache/bin/httpd -k start
6158 ? S 0:00 /usr/local/apache/bin/httpd -k start
6160 ? S 0:00 /usr/local/apache/bin/httpd -k start
If see the above lines, it measn everything runs well.
Open Web Browser, and input the IP address, it would be accessed by http.