Simple Apache + PHP support on your VPS

T

his tutorial works for CentOS only. For your specific OS tutorial use the tags or serach function in the sidebar area.

Now let's do the main puprpose of having VPS done - HTTP Server. For our needs (and for now) the choose will be Apache (obviously). The Apache+PHP and MySQL comes pre-installed on Hostinger VPS template. You have to do nothing if you're using a Hostinger VPS Template.

Apache for single user

Note: This tutorial assumes a scenario which only single-user on our VPS hosts multiple websites. So NO messing with shared environment at this early point. 

 

Confirm that you have Apache already installed:

Type: yum list installed | grep httpd

[root@server][~]
$ yum list installed | grep httpd
httpd.i686 2.2.15-28.el6.centos installed
httpd-tools.i686
 

Type: type: httpd -v

[root@server][/]
$ httpd -v
Server version: Apache/2.2.15 (Unix)
Server built: May 13 2013 22:08:57
 

if you have - you may skip the install part

if not, type: yum install httpd

after that:

[root@server][~]
$ service httpd start
Starting httpd: [ OK ]

[root@server][~]
$ chkconfig httpd on
 

Once again, check if you have PHP support installed:

Type: yum list installed php-*

[root@server][/]
$ yum list installed php-*
Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
* base: mirrors.advancedhosters.com
* extras: mirror.atlanticmetro.net
* rpmforge: mirror.teklinks.com
* updates: centosa5.centos.org
15 packages excluded due to repository priority protections
Installed Packages
php.i686 5.3.3-23.el6_4 @updates
php-cli.i686 5.3.3-23.el6_4 @updates
php-common.i686 5.3.3-23.el6_4 @updates
php-imap.i686 5.3.3-23.el6_4 @updates
php-mbstring.i686 5.3.3-23.el6_4 @updates
php-mysql.i686 5.3.3-23.el6_4 @updates
php-pdo.i686 5.3.3-23.el6_4 @updates
php-pear.noarch 1:1.9.4-4.el6 @base
php-pear-db.noarch 1.7.13-2.el6.rf @rpmforge
php-xml.i686 5.3.3-23.el6_4 @updates
 

if none above shows up, type:

yum install php php-cli php-common php-imap php-mbstring php-mysql php-pdo php-pear php-pear-db php-xml
 

Now, you have default apache setup runing, you can access a welcome webpage in web browser using your VPS domain which you set @ the VPS order & configure process or via your VPS IP address.

Wait, what's your VPS IP address?

Check:

Type: ifconfig venet0:0 | grep inet | awk '{ print $2 }'

[root@server][~]
$ ifconfig venet0:0 | grep inet | awk '{ print $2 }'
addr:212.1.209.xxx
 

or if the above won't work for any reason type 'ifconfig' hit 'Enter' , this will output any installed interfaces (NIC) ad look for the "inet addr:" which is not 127.0.0.1

Enter the IP in your browser address bar and you will also see a Apache welcome page.

Now, create a file info.php in /var/www/html/

$ cd /var/www/html/

[root@server][/var/www/html]
$ nano info.php
 
 

and paste this text:

Save and exit.

Now access this page in the web browser:

http://yourdomain.com/info.php OR http://yourIP/info.php

You can now see a complete info about PHP.

 

Next tutorial, we will set-up to host our first webpage.