This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

ඉර හඳ තරු

කළුවර අහසට ආලෝකය දෙන්න තරු රැසක් මළානික ආලෝකයක් දෙද්දි ආවාට පිරුණු වටකුරු දෙයක් ඒ එළියට වඩා හැමෝම ආස...

සිව්වන වසර ආරම්භය

දැන් මගෙ අතින් බ්ලොග් ලියවෙන්නෙ නැති ද මන්දා.ඒත් ඉතින් සංවත්සරයක් නිසා ලියන්නත් එපැයි.. මාසෙකට පෝස්ට් එකක් දැම්මාට ඕක...

Root නොකර Android එකට සිංහල උගන්වමු

අද කියන්න යන්නේ Android ධාවනය වන ඒවට root නොකර සිංහල දාගන්න විදිය. මුලින්ම කියන්න ඕන මේ ක්‍රමය...

2015-06-19

Labeling files for writing with SELinux (fopen failed to write file)

Warning: fopen(newfile.txt): failed to open stream: Permission denied in /var/www/public_html/test.php on line 2
Unable to open file!

fopen gives above  error while opening stream for following code

<?php $myfile = fopen("newfile2.txt", "w") or die("Unable to open file!"); $txt = "John Doe\n"; fwrite($myfile, $txt); $txt = "Jane Doe\n"; fwrite($myfile, $txt); fclose($myfile); ?>

solution was labeling the file using following command.

chcon -t httpd_sys_rw_content_t filename


2015-05-26

How to Change keyboard Language in CentOS 7 (Keymap)

check current keyboard map information use following command
recently i installed CentOS 7 and accidentally installed en_gb by default loadkeys us
localectl status # to display locale settings
localectl set-locale LANG=en_GB.utf8 # to set the Language
localectl list-locales # to lists locales
localectl list-keymaps # list keyboard mappings
localectl set-keymap uk # sets the key map

empty a file in linux

use following command to empty file named sample.txt

#truncate -s 0 sample.txt

2015-05-14

Install mod_security in Centos 7

In Fedora Core, CentOS, and Red Hat Enterprise Linux you just need to run following
# yum install mod_security
when installation complete we can see mod_security.conf file in apache folder
# ls -l /etc/httpd/conf.d
include this line to httpd.conf file
LoadModule security2_module modules/mod_security2.so
restart apache
# service httpd restart 



2015-05-04

Install LAMP stack on CentOS 7

first need to install epel-release repo on centos 7 just run following command to install epel

yum install epel*

after that we can start install LAMP stack on CentOS7
LAMP stand for followings

L - Linux (CentOS)
A - Apache(httpd)
M - Mysql(mysqld)
P - PHP

now we can install httpd server using following
yum install httpd

this will install Apache server as httpd service

start the httpd service using following command

service httpd start

start httpd with system bootup use following command

chkconfig httpd on

add following firewall rules
firewall-cmd --permanent --zone=public --add-service=http 
firewall-cmd --permanent --zone=public --add-service=https 
firewall-cmd --reload

now install mysql using following command

yum -y install mariadb-server mariadb

start mariadb service

service mariadb start

enable with system boot

chkconfig maradb on

set mysql root password

mysql_secure_installation

[root@server1 ~]# mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): <--ENTER
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] 
New password: <--yourmariadbpassword
Re-enter new password: <--yourmariadbpassword
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] <--ENTER
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] <--ENTER
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] <--ENTER
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] <--ENTER
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[root@server1 ~]#



now test http://localhost or http://ip_of_server/ on browser it gives you a page like following

Testing 123..

This page is used to test the proper operation of the Apache HTTP server after it has been installed. If you can read this page it means that this site is working properly. This server is powered by CentOS.
that page saying httpd is working fine

now we can install PHP on centos

just run
yum -y install php

after installing php httpd requires restart

restart httpd using follwoing

service httpd restart

for test php
create a file including followings

<?php
phpinfo();
?>

and save it in /var/www/html folder as phpinfo.php

check with browser http://localhost/phpinfo.php or http://ip_of_server/phpinfo.php

now install php-mysql using following command to get mysql support in php

yum install php-mysql

then other modules also well

yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
don't forget to restart apache again

service httpd restart


if you need to access mysql using webrowser install phpMyAdmin using following

yum install phpMyAdmin


Linux Networking on terminal and Back with CentOS 7

recently i installed centos 7 and happy to say back to play with linux. so as first step after installation was the configure network. first need to check what are the available interfaces in current system. to check that we can use ifconfing -a command

[root@tecmint ~]# ifconfig -a

eth0      Link encap:Ethernet  HWaddr 00:0B:CD:1C:18:5A
          inet addr:172.16.25.126  Bcast:172.16.25.63  Mask:255.255.255.224
          inet6 addr: fe80::20b:cdff:fe1c:185a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2344927 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2220777 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:293839516 (280.2 MiB)  TX bytes:1043722206 (995.3 MiB)
          Interrupt:185 Memory:f7fe0000-f7ff0000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:5022927 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5022927 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2175739488 (2.0 GiB)  TX bytes:2175739488 (2.0 GiB)

then select the interface you need to active and give following command. mostly with ethernet it will be eth0

ifconfig eth0 up 
or
ifup eth0


[root@tecmint ~]# ifconfig eth0 up
OR
[root@tecmint ~]# ifup eth0

it will try to make connection with dhcp server and request ip and assign that ip to interface
or else we can assign ip to that interface
[root@tecmint ~]# ifconfig eth0 192.168.1.10


Related Posts Plugin for WordPress, Blogger...