Wednesday, June 17, 2009

Installing PHP with Slackware Linux

Slackware Linux, Apache2, PHP, Build Apache
cd /downloads
Create apache user and group if they don’t already exist:
groupadd apache
useradd -g apache -d /dev/null -s /bin/false apache
wget latest source from
tar zxvf httpd-2.2.3.tar.gz
cd httpd-2.2.3
./configure –prefix=/usr/local/apache –enable-mods-shared=most –enable-deflate –enable-ssl
make install
echo “/usr/local/apache/lib” >> /etc/
cd /usr/local/apache/conf
mkdir ssl.crt ssl.key ssl.csr
openssl req -new -out server.csr
openssl rsa -in privkey.pem -out server.key
openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 365
rm privkey.pem
mv server.crt ssl.crt/
mv server.key ssl.key/
mv server.csr ssl.csr/
edit httpd.conf and do the following:
Change User and Group to “apache”
Uncomment “Include conf/extra/httpd-default.conf”
Uncomment “Include conf/extra/httpd-ssl.conf”
edit extras/httpd-ssl.conf and change the following (the paths don’t have the ssl.* directories by default):
SSLCertificateFile /usr/local/apache/conf/ssl.crt/server.crt
SSLCertificateKeyFile /usr/local/apache/conf/ssl.key/server.key
echo “/usr/local/apache/bin/apachectl start” >> /etc/rc.d/rc.local
/usr/local/apache/bin/apachectl start
go to http://your_server and https://your_server to make sure Apache is working on both ports 80 and 443# chmod +x /etc/rc.d/rc.httpd# /etc/rc.d/rc.httpd start

Build PHP
cd /downloads
wget latest source from
tar zxvf php-5.1.4.tar.gz
cd php-5.1.4
./configure –prefix=/usr/local –with-config-file-path=/etc –with-apxs2=/usr/local/apache/bin/apxs –with-mysql=/usr/local/mysql –with-mysql-sock=/var/run/mysql/mysql.sock –with-mysqli=/usr/local/mysql/bin/mysql_config –with-openssl –enable-ftp –disable-debug –enable-memory-limit –enable-inline-optimization –enable-magic-quotes –enable-mbstring –enable-track-vars –enable-xml –with-dom –with-xml –enable-sockets –with-zlib –with-gettext –with-pear –with-apsell
make install
cp php.ini-recommended /etc/php.ini
Vi /etc/php.ini and do the following:
change “short_open_tag” to On

change include_path to “.:/usr/local/lib/php”
edit /usr/local/apache/conf/httpd.conf and do the following:
make sure install added “LoadModule php5_module modules/”
add “index.php” to DirectoryIndex directive
add “AddType application/x-httpd-php .php .inc .class” to the end of the file
/usr/local/apache/bin/apachectl restart
echo “” > /usr/local/apache/htdocs/test.php
go to http://your_server/test.php and see if your PHP is working

see this

II) Downloading PHP
You can download from one of the PHP
mirrors. (PHP comes in both gzip and bzip2 archives. This document assumes the bzip2 type.)
In bzip2 form, PHP 5.2.x is around 9 MB, so if you're using dial-up this will take a while.
As of the time of this writing, the current PHP is version 5.2.9, so the file you get is called php-5.2.9.tar.bz2 or something similar.
Just store this somewhere that Linux can see it.
III) Installing PHP
cd to wherever you want the PHP source to live and extract it:cd /usr/srctar jxf /where_php_tarfile_is/php-5.2.9.tar.bz2
Change to the PHP top directory:cd /usr/src/php-5.2.9
Configure PHP:(This assumes that Apache is installed in /home/httpd. If it's not there, you'll need to figure out where apxs lives.)./configure --with-mysql --with-apxs2=/home/httpd/bin/apxs
(NOTE: Apache must be installed with mod_so enabled.)
Assuming there are no error messages from configure, it's time to make and install PHP. Just type:make ; make install
Now, we need a php.ini file to tell PHP how to act. I just use php.ini-recommended with one change.
First, put php.ini in the default location:cp php.ini-recommended /usr/local/lib/php.ini
The only change I make is to turn off allow_url_fopen:allow_url_fopen = Off
(NOTE: In the wrong hands, allow_url_fopen can be very dangerous! I write PHP code to avoid its use.)
All that's left to do is modify the Apache configuration file: /home/httpd/conf/httpd.conf by adding the line:AddType application/x-httpd-php .php
While you're there, you may want to add .php indexes to the DirectoryIndex line:DirectoryIndex index.html index.php index.shtml
To make it all work, stop the web server:/etc/rc.d/rc.httpd stop
Then start it again:/etc/rc.d/rc.httpd start

No comments:

Post a Comment