Sunday, April 24, 2016

HOWTO: Setup and configure a Web Server on Linux


A web server is software to make accessible to many computers (clients) of web pages stored on disk. This fact sheet explains how to install the Apache web server on a UNIX system (typically a Linux distribution such as Red Hat, Mandrake or any other).

This is why some knowledge about Linux or UNIX is ​​necessary. The purpose of this record is going to be being able to recover the sources of different necessary elements and to compile them (a C compiler is necessary, it is usually installed by default on most Linux distributions) in order to have a system operational.



The following installation includes installation of the PHP interpreter, a programming language for creating dynamic pages.
Let’s get started by downloading necessary Packages (Apache and PHP).

Apache sources can be downloaded from the https://httpd.apache.org/download.cgi



PHP may be downloaded on the site http://php.net/downloads.php


I will not show you how to download it because it is pretty easy ^_^
After downloading Packages we got 2 files: php-7.0.5.tar.bz2 and httpd-2.4.20.tar.gz (You may get other names that related with version you had downloaded).

Decompress the archives by typing the following commands on your Terminal:
tar -xvjf php-7.0.5.tar.bz2
tar -zxvf httpd-2.4.20.tar.gz

Now let’s do a small configuration for Apache and PHP just type the following commands:
cd httpd-2.4.20
./configure --prefix=/www

cd ../php-7.0.5

./configure --with-mysql --with-apache=../apache_1.3.x --enable-track-vars

Let’s move to installation steps:

We are in php-7.0.5 folder, right? Now let’s get started: Type the following in your terminal
make  

make install

Wait it until finish, and move to apache folder 

cd httpd-2.4.20
./configure --prefix=/www --activate-module=src/modules/php3/libphp3.a 

make  

make install

To link to this step, you can also copy the httpd binary again generated and overwrite the old. Remember in this case to restart your web server.
Next we need to modify PHP3.ini file, you can read more about this file .

 cd ../php-7.0.5
 cp php3.ini-dist /usr/local/lib/php3.ini
Edit your httpd.conf or srm.conf file and add this line:

AddType application/x-httpd-php3 .php3 

Now let’s restart our server by typing the following commands=:
systemctl restart httpd
Or you can stop it and start it again
systemctl stop httpd
systemctl start httpd
Or you can use apachectl stop and apachectl start


Now and after install is finished let us Test, if it is working well:
To verify it lets move to the root folder of Apache which is /var/www and create a simple PHP File:
<html>  
<head><title>PHP Infos</title></head>  
<body>  

<?php  
phpinfo();
?> 
</body>
</html>

Save it as MyLinuxyTricks.php


Now let’s check it:
Open up your browser and type one of the following:



http://IpAddressOfYourServer/MyLinuxyTricks.php (eg:http://192.168.1.15/MyLinuxyTricks.php)

If you got a page like this that mean it is working well, else try to verify your installation:



 That's it!
Thank you For visiting us on our Blog. Enjoy other Articles and Happy to see you here!





No comments:

Post a Comment

author
My Linux Tricks
MyLinuxTricks's a Blog That intersted in Linux Operating Systems and it try to share some tricks with visitors, and Help who needs help..