Main Menu

friends

Banner

Latest articles

how to copy hidden files from one directory to another
10/03/2010 | mad mad mod

Let's assume that you have a directory "test" containing the following files:  [root@blackmod test]# ls -la
total 8
drwxr-xr-x.  2 root root 4096 2010-03-10 06:11 .
dr-xr-x---. 11 root root 4096 20 [ ... ]


FLOSS weekly
30/09/2009 | mad mad mod

FLOSS weekly FLOSS is an acronym for free/libre/open source software. Floss weekly is a podcast from the TWiT Network. The show contains interviews with prominent developers from the open so [ ... ]


Other Articles
Facebook MySpace Twitter Digg Delicious Stumbleupon Google Bookmarks 

Designed by:
SiteGround web hosting Joomla Templates
Install mysql for Apache (Fedora 12) E-mail
sysadmin

Prerequisites:

Apache and php is already installed 
(see http://www.madmadmod.com/sysadmin/16-setting-up-a-very-simple-apache-webserver-on-linux-fedora.html 
and http://www.madmadmod.com/sysadmin/52-install-php-for-apache-fedora-12.html for more details)
 

Step 1: Install packages

 
run the following command as  root:


# yum install -y mysql mysql-server php-mysql


 

Step 2: start mysqld and restart apache

 

run the following command as root to start mysqld:

 
# service mysqld start

 

If you want mysqld to start at boot time:

 
# chkconfig mysqld on

 

now restart apache:

 

 
# service httpd restart

 

 

Step 3: set mysql-root password

 

set a new mysql-root password:

 
# mysqladmin -u root password 'mypassword'

 

 

Step 4: create a test database

 

Start the mysql command-line tool:



#  mysql -u root -p
Enter password:


and create a new database (e.g. "test"):



mysql> CREATE DATABASE test;
Query OK, 1 row affected (0.00 sec)

mysql>

 

Select the new database:



mysql>use test;

Database changed

mysql>





and create a new table (e.g. example):



mysql> CREATE TABLE example (id INT, data VARCHAR(100));






and insert some values:


mysql> INSERT INTO example VALUES("1","hello world");

 

 

Step 5: Test

go to the "html" directory (default is /var/www/html):

 

# cd /var/www/html/

 

and open a new file called "test.php"

# vi test.php

 

write the following PHP code into that file and save & close the file with ":wq"

 

<?php
    $dbserver="localhost";
    $dbusername="root";
    $dbuserpassword="mypassword";
    $dbname="test";
    $connect=mysql_connect($dbserver, $dbusername, $dbuserpassword) or die("mysql connect is not working! good bye");
    $db=mysql_select_db($dbname, $connect) or die("select-db is not working! good bye");
    $myquery="SELECT data from example";
    $result=mysql_query($myquery) or die("mysql query not working! good bye");
    $row=mysql_fetch_row($result);
    print $row[0];
?>

 

Now open a browser window and go to "http://localhost/test.php" or "http://127.0.0.1/test.php" or whatever your URL is. 

 

SELinux

If You have SELinux enabled you have to make sure the security context of your new file is "httpd_sys_content_t". run "ls -laZ" to check the security context:

# ls -laZ /var/www/html/test.php
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t test.php

 

If it is NOT httpd_sys_content_t you can restore the context with restorecon:

 

# restorecon /var/www/html/test.php

 

Comments (0)
Write comment
Your Contact Details:
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
:D:angry::angry-red::evil::idea::love::x:no-comments::ooo::pirate::?::(
:sleep::););)):0
Security
Please input the anti-spam code that you can read in the image.

!joomlacomment 4.0 Copyright (C) 2009 Compojoom.com . All rights reserved."

 
mad mad mod, Powered by Joomla! and designed by SiteGround web hosting