Friday, 23 October 2015

How to set up a CentOS 7 server (systemd) with basic services installed

Here is the step by step guide to install and configure CentOS 7 server which uses SystemD for the service management. So the commands are slightly different from what we are used:



1. Install httpd

yum update

sudo yum install httpd

sudo systemctl start httpd.service

sudo systemctl enable httpd.service

2. Install php 5.5.23

wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm

wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

rpm -Uvh remi-release-7*.rpm epel-release-7*.rpm

Enable remi-php55 repo like given below :

vim /etc/yum.repos.d/remi-php55.repo 

[remi]
name=Remi's RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/remi/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/7/remi/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

[remi-php55]
name=Remi's PHP 5.5 RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/php55/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/7/php55/mirror
# WARNING: If you enable this repository, you must also enable "remi"
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

[remi-php56]
name=Remi's PHP 5.6 RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/php56/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/7/php56/mirror
# WARNING: If you enable this repository, you must also enable "remi"
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

Install PHP 5.5

yum install php php-gd php-mysql php-mcrypt php-xml php-gettext php-tcpdf php-opcache php-mbstring php-bcmath php-tidy php-tcpdf-dejavu-sans-fonts

3. Install mysql

sudo yum install http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

Edit /etc/yum.repos.d/mysql-community.repo

change the below lines :

# Enable to use MySQL 5.5
[mysql55-community]
name=MySQL 5.5 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

Then install mysql :

yum install mysql -y

systemctl enable mysqld

systemctl start mysqld


4. Install phpmyadmin

yum install phpmyadmin

Change /etc/httpd/conf.d/phpMyAdmin.conf as below:

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

<Directory /usr/share/phpMyAdmin/>
AllowOverride All
Options None
Require all granted
</Directory>


systemctl restart httpd

vim /usr/share/phpMyAdmin/.htaccess

AuthType Basic
AuthName "Admin Login"
AuthUserFile /etc/httpd/pma_pass
Require valid-user

Set phpmyadmin authentication user and password using below command:

htpasswd -c /etc/httpd/pma_pass phpmyadmin

systemctl restart httpd

5. Install monit

yum install monit

systemctl enable  monit.service

systemctl restart  monit.service

vim /etc/monitrc 

You can follow this link to configure the monitrc 

No comments:

Post a Comment