24 Sep

Install Apache with PHP and MySQL on Fedora

Fedora use yum as it’s repository to handle dependencies and binary install all of the required packages.

1. First we will install Apache (HTTP daemon), with PHP and MySQL, plus the PHP component which allows it to access MySQL.
Open your terminal located in the applications menu on the Fedora desktop and execute:

     yum -y install httpd php mysql mysql-server php-mysql

2. Configure the daemons to start automatically after server restart

     chkconfig httpd on
     chkconfig mysqld on

start them now

     service httpd start
     service mysqld start

3. Very important to set up the MySQL root account password. Without it, anyone on the server can login to MySQL as database root. The MySQL root account is not the same system root account that we know.
From the security perspective it is better to give it a different password from one we have for our system root account.

     mysqladmin -u root password 'new-password'
     // quotes are required

4. Here is an additional security related changes for MySQL.

     mysql -u root -p
     // login

     mysql> DROP DATABASE test;
     // delete the test database, we don't need it at all
     mysql> DELETE FROM mysql.user WHERE user = '';
     // removes anonymous user access
     mysql> FLUSH PRIVILEGES;
     // reset privilegies

5. the HTTP root folder after the default Fedora Apache installation is /var/www/html/
Let’s create a script to make shore that PHP is working.
write the folowing line to the file with any text editor,
save it as index.php and place it in the document root /var/www/html/

     

now open your browser on the server and go to http://localhost to check it out.

6. To create MySQL database and MySQL user for it, that you can use for PHP scripts.
execute the following in the MySQL terminal

     mysql> CREATE DATABASE my_db;
     mysql> GRANT ALL PRIVILEGES ON my_db.* TO 'myuser'@'localhost' IDENTIFIED BY 'password';
     // the GRANT statement will create a new MySQL user account.

Feel free to contact us in case of any support required.
Good Luck

oneroot.ca copyright © 2014 | ONEROOT INC. Linux IT Support in Winnipeg. eMail: support at oneroot.ca