How to install Apache HTTP server with PHP support

From Salix OS
Jump to: navigation, search

This guide shows how to install the Apache HTTP server with PHP support

Install Apache HTTP server

In order to install the HTTP server you need to become root, update the repositories in order to use up-to-date software, and install the httpd package:

slapt-get -u
slapt-get -i httpd 

Start the www server to test if it is working:

bash /etc/rc.d/rc.httpd start

open the browser and go to http://localhost/. You should see "It works". This means the www server is working. In order to make the server autostart during boot:

chmod a+x  /etc/rc.d/rc.httpd

Web pages should be put in the directory /var/www/htdocs/. Now you can use the server for simple HTML pages.

Install PHP

If you need PHP, then install it:

slapt-get -i php

We have to configure the server in order to handle PHP files. Thus edit /etc/httpd/httpd.conf:

  1. uncomment the following line to enable PHP: Include /etc/httpd/mod_php.conf
  2. add the line: AddType application/x-httpd-php .php
  3. find the DirectoryIndex line and chage it by adding index.php to give something like that:: DirectoryIndex index.php index.html

Restart the web server:

/etc/rc.d/rc.httpd restart

In order to test if the webserwer handles PHP files try to create the file /var/www/htdocs/test.php containing phpinfo() command:

<?php  phpinfo();  ?>

Then point your browser to http://localhost/test.php. If everything is OK you should see a blue table with PHP details.

Sometimes restarting webserver is not enough and computer reboot is necessary in order to make PHP work (ie. phpMyAdmin)