Main Menu

friends

Latest articles

find world writable files
09/01/2010 | mad mad mod

No file on a server should have o+w permissions (at least I can't think of a reason).The command to find all world writable files on system is: # find / -perm -0002  -type f -print
This command will [ ... ]


Installing VirtualBox on Linux (Fedora)
10/10/2009 | mad mad mod

If you want to run windows application on Linux, you have several options:use wineInstall Windows in a XEN VM (with full virtualization) Install Windows on a VMWare VM (Server or Player)Install Windo [ ... ]


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