In this tutorial we will install and setup Apache web server and PHP. There are many newbies out there who are really new to Linux, VPS or Server, so here i am posting easier way to setup a working live server to host websites in it.
Login to your server and make sure you do some basic optimization tasks for a newly created Ubuntu server.
INSTALL APACHE WEB SERVER
Apache is truly a default web server which is license free and opensource. It has been utilized by numerous servers around the globe. There are couple of other web server like Litespeed and Nginx yet Apache is as yet ruling on the grounds because its effectiveness.
Use following command:
sudo apt-get -y update sudo apt-get -y upgrade
Wait for the process to complete then type the following command:
sudo apt-get -y install apache2-prefork-dev apache2-utils apache2.2-bin apache2.2-common apache2
INSTALL PHP5
Use following command to install PHP5 on your Ubuntu server:
sudo apt-get -y install php5 php5-cgi php5-cli php5-common php5-curl php5-dev php5-gd php5-tidy php5-xmlrpc php5-xsl php5-suhosin php5-mcrypt php5-imap php5-imagick libapache2-mod-php5
ADD PHP TO DIRECTORY INDEX (OPTIONAL)
Normally Apache will start looking at index.html document before index.php. You can change that order by altering “dir.conf” record. Use the following command:
sudo nano /etc/apache2/mods-enabled/dir.conf
Now move “index.php” into the beginning part so it will look like this:
<ifmodule mod_dir.c=""> DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm </ifmodule>
Once done, save and exit the editor.
You can test your PHP by simply creating a phpinfo.php file under /var/www
Don’t forget to restart your Apache2 service
service apache2 restart
Then try accessing that phpinfo.php file into your favorite browser by typing your IP in address bar:
http://68.46.2.127/phpinfo.php
Setup CSF Firewall
You can use CSF for managing your firewall. Follow the below steps to install it.
cd /opt wget http://www.configserver.com/free/csf.tgz tar xzf csf.tgz
cd /opt wget http://www.configserver.com/free/csf.tgz tar xzf csf.tgz
cd /opt/csf sh install.sh
Now enable CSF to work as production. By default, it installed in test mode.
nano /etc/csf/csf.conf TESTING=0
Finally restart CSF service using following command.
cd /etc/csf csf -r
That is it. Presently you have a working server to host your PHP-based scripts and run it on your browser.
In the next post,I’ll write about how to install MySQL server .