Search

Sunday, January 16, 2011

Install Apache, PHP, and MySQL in Linux Fedora 14

objective : install Apache, PHP and MySQL on Fedora 14, installed from LiveUSB Fedora 14.
note : Apache already installed on Fedora 14 LiveUSB installation.

Apache, PHP, and MySQL can be installed via 2 ways :
  • XAMPP
  • YUM installation (super user)
XAMPP
Download and install XAMPP for linux from xampp official web site. Installation process is also described there.

Problem with SELinux
XAMPP is using some executable stack from Fedora's system, which had been forbid by SELinux since
Fedora 12. This caused an error message appeared in console when running XAMPP. Simple solution is set SELinux policy to allow to execute executable stack. To do so, run below command in console (with super user authorization) :
# setsebool -P allow_execstack on
Start xampp service on more time in console. Apache, PHP and MySQL are ready to use.

Fedora 14's default installation
Apache web server is already installed by default in Fedora 14 's package. If we install XAMPP then we will have 2 Apache instances installed (not started) in our Fedora box. For simplicity I chose to use default installed Apache web server and use yum command to install PHP and MySQL.

yum : PHP installation
To install PHP 5.x.x directly into installed Apache web server, use :
# yum install php
To start, stop, and restart Apache web server (and PHP) use :
# service apache start
# service apache stop
# service apache restart  
Default Apache's DocumentRoot is set to /var/www/html.

yum : MySQL installation
To instal MySQL 5.x.x use command below :
# yum install mysql-server
For  MySQL secure installation use :
# mysql_secure_installation
Then followed by some processes :
  1. System will ask for your root password. If you had already installed MySQL enter your old root password, or else just hit Enter.
  2. Then you will be asked to enter and repeat your new root password twice. You can use a password or just left it blank. For security it is recommended to use password.
  3. Remove anonymous user ? If you enter Yes, anonymous user from user MySQL system will be removed. Anonymous user is automatically created in MySQL installation process.
  4. You will be asked to allow or not Root Remote Login. For you are not sure just enter No for security reason.
  5. Next question will ask whether you want to remove database Test. This database was automatically in MySQL installation for testing purpose.
  6. Enter Yes to flush privileges (user).

To start mysql, type in :
# service mysqld start 
You can login to your mysql server installation using command below, and then type in your root pasword.
# mysql -u root -p

yum : PhpMyAdmin installation
Some would prefer GUI to interact with database. PhpMyAdmin is one among the most popular GUi. To install PhpMyAdmin, use :
# yum install phpmyadmin 

Allow override controls in .htaccess files
AllowOverride controls what directives may be placed in .htaccess files. It can be "All", "None", or any combination of the keywords : Options FileInfo AuthConfig Limit.
By default AllowOverride is set to None. To use the full functionality of .htaccess file AllowOverride is needed to set to All. Edit / comment lines in httpd.conf ( default location is in /etc/httpd/conf directory ) as below :

   #AllowOverride None
AllowOverride All
Note : Apache encourage not to use .htaccess file whenever possible,  read here .
Only use .htaccess file if you could not and need to change existed Apache's configuration (defined in httpd.conf by root access) .

1 comment: