Thursday, 23 June 2016

thumbnail

How-to-install-and-configure-LAMP-in-CentOS-7

How-to-install-and-configure-LAMP-in-CentOS-7


1.To install and configure lamp start terminal do the following :-

* First of all update your system :-

yum update 

2. Now install and configure Apache :-

yum install httpd -y

For the production environment some of the setting required as below :-

* Edit httpd.conf and add the below to turn off KeepAlive and adjust the resource use settings. The settings shown below are a good starting point for a 2GB virtual dedicated server.

Note :-  Backup your httpd.conf file 

cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.new

File excerpt :- /etc/httpd/conf/httpd.conf

KeepAlive Off


<IfModule prefork.c>
    StartServers        4
    MinSpareServers     20
    MaxSpareServers     40
    MaxClients          200
    MaxRequestsPerChild 4500
</IfModule>

These setting can also be added to a separate file if so desired. The file must be located in the conf.module.d or conf directories, and must end in .conf extension.

* Configure the Name based virtual host :-

There are different ways to set up virtual hosts; however, the method below is recommended.

Within the conf.d directory create vhost.conf to store your virtual host configurations. The example below is a template for website example.com; change the necessary values for your domain:

File excerpt :- /etc/httpd/conf.d/vhost.conf 

NameVirtualHost *:80
        
<VirtualHost *:80>
    ServerAdmin webmaster@example.com
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /home/sarfaraz/public_html
    ErrorLog /home/sarfaraz/public_html/logs/error.log
    CustomLog /home/sarfaraz/public_html/logs/access.log combined
<Directory /home/sarfaraz/public_html>
                Options -Indexes FollowSymLinks -MultiViews
                AllowOverride All
                Require all granted  
 </Directory>
</VirtualHost>

Additional domain can be added to the vhost.conf file.
Log directories must be created before you restart the httpd service.

* Create the directory for virtual host and log


mkdir public_html       <= You need to enable userdir please check how to enable

*. Enable Apache to start at boot time :-


systemctl enable httpd.service
systemctl restart httpd.service


3. Now install Mysql/MariaDB server :-


yum install mariadb-server -y

Now enable it to start at boot time :-

sudo systemctl enable mariadb.service
sudo systemctl start mariadb.service


Now change the mysql root password :-

mysqladmin -u root password 'xyz123'

4. Now install and configure PHP :-

yum install php php-pear php-mysql

Restart the htttpd service to take effect :-

systemctl restart httpd.service

5. Install and configure Phpmyadmin :-

First of all we need enable EPEL repository 

yum install epel-release

Now update and install 

yum check-update
yum -y install phpmyadmin -y

Now configure phpmyadmin so that we can access it from worldwide.


vim /etc/httpd/conf.d/phpMyAdmin.conf


Restart the httpd service once to take effect 

That's it now you enjoy using LAMP
Please Do Likes,Share and Comments!!!!


Subscribe by Email

Follow Updates Articles from This Blog via Email

No Comments