Webserver (Apache2/Mysql5/PHP5/FTPd) on Suse Linux 9.1
 
I made an installation of the latest webserver components on a Suse Linux 9.1 system. Here is my manual:

1. Operating system installation: SUSE Linux 9.1
Installation with DVD1 / CD1.
Installation- is the minimal system. Additionally, I installed the following packages / components:
- links (textbased webbrowser)
- make (makefiles)
- gcc (compiler)
- wget (tool to download from HTTP or FTP servers)
- flex
- pure-ftpd (FTP server)
- whois
- webalizer (Create website statistics)
- libidn
- curl-devel
The libs which are added automatically because of the above components have to be installed also.

1.1 Copy of the installation DVD / CDs (optional)
The DVD or CDs can be copied to the local filesystem (if enough free space is available).
They can be added as a installation source using yast.

2. Remote login (SSH)
an SSH server application is available on the system automaticly. It allows you to login remotely (from another computer).
To connect to your webserver via a windows computer, download the tool "Putty" (available on download and shareware sites (www.versiontracker.com)).

3. Installation Apache / MySQL / PHP / Libraries

3.1 Download packages
Download the following packages (or later versions) to /usr/local/src/:
- zlib-1.2.3.tar.gz from http://www.gzip.org/zlib/
- libxml2-2.6.22.tar.gz from http://xmlsoft.org/
- php-5.0.5.tar.bz2 from http://www.php.net/downloads.php
- httpd-2.0.55.tar.gz from http://httpd.apache.org/
- libpng-1.2.8-config.tar.gz from http://www.libpng.org/

3.2 Extract packages
cd /usr/local/src
gunzip zlib-1.2.3.tar.gz
tar -xf zlib-1.2.3.tar
gunzip libxml2-2.6.22.tar.gz
tar -xf libxml2-2.6.22.tar
gunzip httpd-2.0.55.tar.gz
tar -xf httpd-2.0.55.tar
bunzip2 php-5.0.5.tar.bz2
tar -xf php-5.0.5.tar
bunzip libpng-1.2.8-config.tar.bz
tar -xf libpng-1.2.8-config.tar

3.3 MySQL Installation
Download the following (or later versions) from http://mysql.com/:
- MySQL-client-5.0.11-0.i386.rpm
- MySQL-devel-5.0.11-0.i386.rpm
- MySQL-server-5.0.11-0.i386.rpm
- MySQL-shared-5.0.11-0.i386.rpm
Installation with "rpm -i MySQL*.rpm"

3.4 compile zlib, install in /usr/local/lib
cd zlib-1.2.3/
./configure
make
make install
cd ..

3.5 compile libxml2, install in /usr/local/lib
cd libxml2-2.6.22
./configure
make
make install
cd ..

3.6 compile libpng, install in /usr/local/lib
cd libpng-1.2.8-config
./configure
make
make install
cd ..

3.7 compile Apache 2, install in /usr/local/apache2
cd httpd-2.0.55
./configure -prefix=/usr/local/apache2 -enable-so
make
make install
cd ..

[i]3.7.1 Apache 2 stuff[/i]
start / stopp Apache2:
/usr/local/apache2/bin/apachectl start
/usr/local/apache2/bin/apachectl stop
Apache 2 config-directory:
/usr/local/apache2/conf/
Apache 2 Htdocs-directory:
/usr/local/apache2/htdocs/

3.8 compile PHP, install in /usr/local/php5
cd php-5.0.5
./configure -prefix=/usr/local/php5 -with-apxs2=/usr/local/apache2/bin/apxs \
--with-libxml-dir=/usr/local/lib -with-zlib-dir=/usr/local/lib \
--with-mysql=/usr \
--with-libpng -with-libpng-dir=/usr/local/lib \
--with-curl --with-gd -enable-soap -enable-sockets -enable-mbstring
make
make install
cd ..
If PHP has to be compiled again later (including new libraries), do the following:
cd php-5.0.5
./configure <the new config parameters here>
make clean
make
make install
cd ..

4. PHP configuration
Copy/create the php.ini file:
cp /usr/local/src/php-5.0.5/php.ini-recommended /usr/local/php5/lib/php.ini
Make changes in the php.ini file (/usr/local/php5/lib/php.ini):
upload_max_filesize = 32M
error_reporting = E_ALL & ~E_NOTICE
register_globals = On
register_long_arrays = On
post_max_size = 32M

5. Apache configuration

5.1 Include PHP into Apache
The php build from above has automaticly added the following line to /usr/local/apache2/conf/httpd.conf:
LoadModule php5_module   modules/libphp5.so
Add another line undner this one into httpd.conf:
AddType application/x-httpd-php   .php

5.2 Changes in /usr/local/apache2/conf/httpd.conf
ServerAdmin your@mail.addr
DirectoryIndex index.html index.html.var index.htm index.php
DocumentRoot /usr/local/apache2/htdocs

[i]5.2.1 Directory[/i]
We configure Apache to host different websites. Therefore, we make one entry for all sites into the httpd.conf:
<Directory "/srv/*">
    AllowOverride All
    Options -Indexes
    <IfModule mod_access.c>
        Order allow,deny
        Allow from all
    </IfModule>
</Directory>

Now, you can create different folders inside /srv/ which can be used for different websites

[i]5.2.2 Virtual Hosts[/i]
You have to add a Virtual Host entry at the enf of httpd.conf for every website.
Here, we create a host for port 80 and one for port 8080 (if you change port, you have to make a "Listen" entry like done below:
<VirtualHost *:80>
    ServerAdmin your@mail.addr
    DocumentRoot /srv/site1
    ServerName www.site.com
    TransferLog /var/log/httpd/access_site1_log
</VirtualHost>
Listen *:8080
<VirtualHost *:8080>
    ServerAdmin your@mail.addr
    DocumentRoot /srv/site2
    ServerName www.site2.com
    TransferLog /var/log/httpd/access_site2_log
</VirtualHost>

To make it possible for Apache to create the logfiles, create the folder httpd into /var/log:
mkdir /var/log/httpd

[i]5.2.3 Apache Groups / Users[/i]
Apache uses the user "nobody" and the group "#-1" by default. We change that to srvuser and srvgroup. You can change this inside the httpd.conf file:
<IfModule !mpm_winnt.c>
<IfModule !mpm_netware.c>
User srvuser
Group srvgroup
</IfModule>
</IfModule>


5.3 Start Apache automaticly
Now, Apache2 has to be added to the inittab in order to be launched at boot time. Create the following script:
vi /etc/init.d/apache2
with the following content:
#! /bin/sh
. /etc/rc.status
rc_reset
case "$1" in
  start)
echo -n "Starting Apache 2"
/usr/local/apache2/bin/apachectl start
rc_status -v
;;
  stop)
echo -n "Shutting down Apache 2"
/usr/local/apache2/bin/apachectl stop
rc_status -v
;;
  restart)
$0 stop
$0 start
rc_status
;;
  *)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
rc_exit

Add the execute permissions to the script:
chmod +x /etc/init.d/apache2
Now, you can add apache2 to your runlevel(s) using the "Runlevel editor" which is built in in suse's "yast".

6. MySQL configuration

6.1 set root password
MySQL has no password defined for the user "root" by default. Do the following to set the MySQL root password:
/usr/bin/mysqladmin -u root password 'new-password-here'

6.2 create databases and users
First, login into MySQL:
/usr/bin/mysql -u root -h localhost -p
Now you have to enter the root password.
What we do now, is creating the database "db1" and the user "usr1" which has permissions in "db1":
create database db1;
use mysql;
insert into user (Host,User,Password) values (’localhost’,’usr1’,password(’password_here’))\g
insert into db (Host, User, Db, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Grant_priv, References_priv, Index_priv, Alter_priv, Create_tmp_table_priv, Lock_tables_priv) values (’localhost’, ’usr1’, ’db1’, ’Y’ , ’Y’, ’Y’, ’Y’, ’Y’, ’Y’, ’Y’, ’Y’, ’Y’, ’Y’ , ’Y’ , ’Y’)\g
Important: After you have done these things, you have to execute the following command in order to reload everything:
FLUSH PRIVILEGES;
If you prefer, you can also make these entrys directly with phpMyAdmin.

7. FTP server configuration

7.1 start automaticly
You can add the ftp server "pure-ftpd" with the runlevel editor from yast to your runlevel(s).

7.2 configuration file
Change a few things inside /etc/pure-ftpd.conf:
PureDB     /etc/pure-ftpd/puredtpd.pdb
AnonymousOnly     no
NoAnonymous     yes
AntiWarez     no
AutoRename     no
NoRename     no
ProhibitDotFilesWrite     no
UserBandwidth     10000
PerUserLimits     10:20


7.3 users and groups (Permissions for /srv/)
Execute the following commands:
groupadd srvgroup (add system group for srvuser)
useradd -g srvgroup -d /etc/pure-ftpd -s /etc srvuser (add the srvuser)
chown -R srvuser /srv (Make srvuser the owner of /srv/*)
chgrp -R srvgroup /srv (Make srvgroup the owner of /srv/www/*)

7.4 Add users
Now, you can add different virtual ftp users which access your machine as srvuser:
pure-pw useradd ftpuser1 -u srvuser -d /srv/site1 (Adds the ftp user ftpuser1, which has to have a new password)
pure-pw mkdb (Save the changes just made)
pure-pw show ftpuser1 (Show details for the ftp user ftpuser1)

7.5 Directory permissions
The permissions in /srv/ should look like this:
linux:/ # cd srv
linux:/srv # la
total 1
drwxr-xr-x  6 root  root   168 Oct 27 10:42 .
drwxr-xr-x 22 root  root   536 Oct 24 09:21 ..
drwx------  3 srvuser srvgroup 80 Oct 20 11:51 site1
drwx------  2 srvuser srvgroup 80 Oct 27 07:28 site2
drwx------  2 srvuser srvgroup 304 Oct 20 16:38 webalizer
linux:/srv #

You can change permissions using "chmod", owners with "chown" and groups with "chgrp".

8. Webalizer statistics tool
coming soon...
 
admin / Nov 02, 2004
 
Files
 
linux-apache2-mysql4-php5.htm: A LAMP (Linux / Apache2 / Mysql4 / PHP5) manual in german, found on http://www.kofler.cc/
 
   
 
 
Login: 
Pass: 
 
 
     
     
2004 - 2019 / lookass.ch
makememad@lookass.ch