Sunday, November 4, 2012

Installing Web Server (Apache) on Linux (CentOS) Machine with PHP and MySQL

Installing Operating Server:
  1. Install Cent OS on the Machine (Follow the simple steps as per the OS installation Guide).
  2. (I will update these)
Making the server ready for network access:
  1. Set IP address for your server: (To Setup local Ping and local network access)
    1. cd /etc/sysconfig/network-scripts/
    2. cp ifcfg-eth0 ifcfg-eth0-bak
    3. cp ifcfg-eth1 ifcfg-eth1-bak
    4. vi ifcfg-eth0
    5. Add/Edit (As per requirement):
      1. DEVICE="eth0"
      2. HWADDR="XX:XX:XX:XX:XX:XX"
      3. NM_CONTROLLED="yes"
      4. ONBOOT=yes
      5. BOOTPROTO=none
      6. IPADDR=XXX.XXX.XXX.XXX
      7. NETMASK=XXX.XXX.XXX.XXX
      8. GATEWAY=XXX.XXX.XXX.XXX
    6. Save the file
  2. Set NS Settings:
    1. cd /etc/sysconfig/
    2. vi ./network
    3. Add/Edit:
      1. NETWORKING=yes
      2. HOSTNAME=yourhost.name
      3. GATEWAY=XXX.XXX.XXX.XXX
  3. service network restart
  4. Check the ip address: ifconfig
  5. If works fine go to step 6 or go to step 1 (Or please leave a comment, I will get back to you and try to resolve and update the post).
  6. Reboot the server just to make sure the changes are made.
  7. Ping server from one of the machine on network. Ping from different server and other machines etc. just to make sure everything is configured properly.
Now your server is ready to get pings from your machines, after service restart.

Enabling the Internet Access:
  1. Make sure the IP has the internet access (your firewall settings).
  2. ssh root@XXX.XXX.XXX.XXX to check if login works from other stations (you don't want to go to the machine every-time).
  3. ping an external site (e.g. ping bing.com), and check the results.
  4. Network look-up (e.g. nslookup bing.com).
  5. If not make the following changes:
    1. vi /etc/resolv.conf
      1. Add/Edit: Add the Gateways
        1. nameserver XXX.XXX.XXX.XXX
        2. nameserver XXX.XXX.XXX.XXX
  6. Reboot the server just to make sure the changes are made.
  7. If works fine go to fire wall settings else repeat from step 1 (Or please leave a comment, I will get back to you and try to resolve and update the post).
Firewall Settings:
Setting up Hosts:
Adding Servers: (For inter server communications)
Check Server Setting and Configuration:


  1. Task: Display current active Internet connections (servers and established connection)
    1. $ netstat -nat
  2. Task: Display open ports
    1. $ sudo netstat -tulpOR$ sudo netstat -tulpn
  3. Task: Display network interfaces stats (RX/TX etc)
    1. $ netstat -i
  4. Task: Display output for active/established connections only
    1. $ netstat -e
    2. $ netstat -te
    3. $ netstat -tue


Installing WebServer:
    1. check if yum is installed: ls -l /etc/yum.repos.d/
    2. yum install apache2
    3. yum install php5.3
    4. yum install mysql5
Some of the commands need to upgrade:
yum -y install openssh-server openssh-clients
chkconfig iptables off


yum install mysql mysql-server php-mysql
chkconfig mysqld on
service mysqld start
mysql
use mysql
update user set password for 'root'@'pcvcrm'= password ('AppServerDB');
update user set password for 'root'@'localhost'= password ('AppServerDB');
update user set password for 'root'@'127.0.0.1'= password ('AppServerDB');


yum install httpd
chkconfig httpd on
/etc/init.d/httpd start

yum install php
yum update php


setsebool -P httpd_can_network_connect=1

yum install zip


MSSQL
rpm -ivh http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

cd /etc/yum.repos.d/
wget http://rpms.famillecollet.com/enterprise/remi.repo

yum install freetds
or
freetds-0.82-1.x86_64

yum install freetds-devel
yum install --enablerepo=remi php-mssql


yum install unixODBC unixODBC-devel libtool-ltdl libtool-ltdl-devels

yum install zend-server-ce-php-5.2