Somebody recently asked me how is this done. I knew a bit about it but hit the books again. Finally i learned something new and decided to share it with the comunity.
Introduction
PHP http://www.php.net is a very popular open source server-side embedded scripting language that is especially suited for Web development. In fact out of the roughly 14 million sites running on the Apache Web servers, over half are running PHP, according to the SecuretySpace.com, a consulting group that gathers statistics on Internet online services. PHP allows you to embed PHP code (very similar to C code) into your HTML documents to give your web pages dynamic content. PHP can perform any task that any CGI program can do, but its strength lies in its compatibility with many types of databases and adding database queries to a PHP script is a piece of cake. PHP has a relatively low learning curve, if a developer knows HTML and has some knowledge of the C programming language they can easily start developing impressive PHP scripts. This article will walk you through configuring Apache, PHP, and MySQL on SUSE Linux (NLD, SLES, or Professional). It will also introduce you to a third party product named PhpEd, by NuSphere http://www.nusphere.com that can be used to simplify the development and debugging of PHP scripts.
Enable Apache, PHP, and MySQL
(Note: This section requires root user privileges)
SUSE Linux contains support modules for Apache and PHP that make setting up Apache and PHP a breeze. If these products were not installed as part of the original install you will need to install them using the Yast installer. If you are not sure if they are installed you may want use the runlevel editor under the System option in Yast and see if they are available to start. If you determine they are not installed or you need to install additional products shown below, select Install and Remove Software from the Software option and then search for apache. Select the following packages:
Apache
/etc/init.d/apache {start | stop | restart}
MySQL
/etc/init.d/mysql {start | stop | status | reload | restart | try-restart | force-reload}
In addition to starting the services it is also important to know the directory location of where to put your PHP script files. On SUSE Linux that directory is /srv/www/htdocs. Also another important file to know about is the PHP configuration file /etc/php.ini. Later we will have you modify this file for remote debugging purposes.
For security reason the Apache documentation recommends that you don't grant write permissions to any user or group of users to the /srv/www/htdocs directory. Instead it recommends that you create a subdirectory and grant write permissions to that directory. Using Yast select Edit and create groups under the Security and Users option. Click the Set Filter button and select System Groups. Select the www group from the list of groups and click the Edit button. Select the check box for your <user name> from the Members of this Group list. Click the Next button, and then the Finish button. From a Terminal Window switch to the root user and create a misc directory under the /srv/www/htdocs directory (mkdir /srv/www/htdocs/misc). Change the group ownership of the /srv/www/htdocs/misc directory from root to the www group (chgrp www /srv/www/htdocs/misc). Assign read/write/execute permissions for the owner and group of the misc directory (chmod 775 /srv/www/htdocs/misc).
Introduction
PHP http://www.php.net is a very popular open source server-side embedded scripting language that is especially suited for Web development. In fact out of the roughly 14 million sites running on the Apache Web servers, over half are running PHP, according to the SecuretySpace.com, a consulting group that gathers statistics on Internet online services. PHP allows you to embed PHP code (very similar to C code) into your HTML documents to give your web pages dynamic content. PHP can perform any task that any CGI program can do, but its strength lies in its compatibility with many types of databases and adding database queries to a PHP script is a piece of cake. PHP has a relatively low learning curve, if a developer knows HTML and has some knowledge of the C programming language they can easily start developing impressive PHP scripts. This article will walk you through configuring Apache, PHP, and MySQL on SUSE Linux (NLD, SLES, or Professional). It will also introduce you to a third party product named PhpEd, by NuSphere http://www.nusphere.com that can be used to simplify the development and debugging of PHP scripts.
Enable Apache, PHP, and MySQL
(Note: This section requires root user privileges)
SUSE Linux contains support modules for Apache and PHP that make setting up Apache and PHP a breeze. If these products were not installed as part of the original install you will need to install them using the Yast installer. If you are not sure if they are installed you may want use the runlevel editor under the System option in Yast and see if they are available to start. If you determine they are not installed or you need to install additional products shown below, select Install and Remove Software from the Software option and then search for apache. Select the following packages:
Apache 1.3x Web Server (apache)
PHP4 module for Apache 1.3x (apache-mod_php4)
Also install MySQL by searching for mysql and selecting the following packages.MySQL Database Server (mysql)
MySQL Client (mysql-client)
Using the runlevel editor under the System option enable apache and mysql, or if you prefer you can start them manually by issuing the start command for the following applications.Apache
/etc/init.d/apache {start | stop | restart}
MySQL
/etc/init.d/mysql {start | stop | status | reload | restart | try-restart | force-reload}
In addition to starting the services it is also important to know the directory location of where to put your PHP script files. On SUSE Linux that directory is /srv/www/htdocs. Also another important file to know about is the PHP configuration file /etc/php.ini. Later we will have you modify this file for remote debugging purposes.
For security reason the Apache documentation recommends that you don't grant write permissions to any user or group of users to the /srv/www/htdocs directory. Instead it recommends that you create a subdirectory and grant write permissions to that directory. Using Yast select Edit and create groups under the Security and Users option. Click the Set Filter button and select System Groups. Select the www group from the list of groups and click the Edit button. Select the check box for your <user name> from the Members of this Group list. Click the Next button, and then the Finish button. From a Terminal Window switch to the root user and create a misc directory under the /srv/www/htdocs directory (mkdir /srv/www/htdocs/misc). Change the group ownership of the /srv/www/htdocs/misc directory from root to the www group (chgrp www /srv/www/htdocs/misc). Assign read/write/execute permissions for the owner and group of the misc directory (chmod 775 /srv/www/htdocs/misc).