Wednesday, January 11, 2017

LAMP Server Installation

  1. To set up a LAMP server on a fresh VPS/Dedicated server running CentOS 5.0 with atleast 256mb of RAM. ... 
  2. Install Apache. ... 
  3. Install MySQL Database Server. ... 
  4. Changing MySQL Root Password. ... 
  5. To Create A New MySQL User. ... 
  6. Install PHP5 Scripting Language. ... 
  7. To Test If PHP Is Working Or Not: ... 
  8. Install phpMyAdmin.
________________________________________

1) Install Apache

yum install httpd httpd-devel
/etc/init.d/httpd start


2) Install MySQL Database Server

yum install mysql mysql-server mysql-devel

First start the mysql daemon, then type mysql:

/etc/init.d/mysqld start
2 Way to Change MySQL Root Password

By default the root password is empty for the mysql database. It is a good idea to change the mysql root password to a new one from a security point of view.

1) mysql_secure_installation

2) mysql
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';

mysql> FLUSH PRIVILEGES;

Once done, check by logging in:

mysql -u root -p

Enter Password: <your new password>


To Create A New MySQL User

To create a new mysql user 'harry' with 'all privileges' on the database 'demo':
mysql > create database demo
mysql >GRANT ALL PRIVILEGES ON demo.* TO 'harry'@'localhost' IDENTIFIED BY 'harry' WITH GRANT OPTION;
mysql> UPDATE user SET Password=PASSWORD('harry') WHERE user='harry';

That's it! MySQL is ready! Don't forget to remember the root password as we might be using it with phpmyadmin.
3) Install PHP5 Scripting Language

Installing PHP5 with the necessary modules is so easy and can be configured for both the Apache and mysql environment.
yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml

Don't forget to install php-gd (gd library). It is very important if we plan to run captcha scripts on our server and so as other which are dependent on mysql and other functions.
Restart Apache to load php.

/etc/init.d/httpd restart


To Test If PHP Is Working Or Not:

Create a file named /var/www/html/test.php with the following phpinfo() function inside php quotes.

// test.php
  <?php
  phpinfo();
  ?>

Edit /etc/httpd/conf/httpd.conf

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /var/www/html/test.php
    ServerName  funny.com
    ErrorLog logs/dummy-host.example.com-error_log
    CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>


Then point your browser to http://ip.address/test.php.


4) Install phpMyAdmin

yum install phpmyadmin



Point your browser to: http://ip.address/phpmyadmin.


Edit the /etc/httpd/conf.d/phpmyadmin.conf

# phpMyAdmin - Web based MySQL browser written in php
#
# Allows only localhost by default
#
# But allowing phpMyAdmin to anyone other than localhost should be considered
# dangerous unless properly secured by SSL

Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require all granted
       Require ip ::1
     </RequireAny>
   </IfModule>
#   <IfModule !mod_authz_core.c>
     # Apache 2.2
#     Order Deny,Allow
#     Deny from All
#     Allow from 127.0.0.1
#     Allow from ::1
#   </IfModule>
</Directory>

<Directory /usr/share/phpMyAdmin/setup/>
   <IfModule mod_authz_core.c>
     # Apache 2.4
#     <RequireAny>
#       Require ip 127.0.0.1
#       Require ip ::1
#     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
#     Deny from All
     Allow from All
     Allow from ::1
   </IfModule>
</Directory>

# These directories do not require access over HTTP - taken from the original
# phpMyAdmin upstream tarball
#
<Directory /usr/share/phpMyAdmin/libraries/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

<Directory /usr/share/phpMyAdmin/setup/lib/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

<Directory /usr/share/phpMyAdmin/setup/frames/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

# This configuration prevents mod_security at phpMyAdmin directories from
# filtering SQL etc.  This may break your mod_security implementation.
#
#<IfModule mod_security.c>
#    <Directory /usr/share/phpMyAdmin/>
#        SecRuleInheritance Off
#    </Directory>
#</IfModule>

Point your browser to: http://ip.address/phpmyadmin.

User Name : root
Password : newpassword

chkconfig httpd on
chkconfig mysqld on

No comments:

Post a Comment