Construction of Php+mysql+apache Environment on FEDORA21

Source: Internet
Author: User
Tags php and mysql
Transferred from: http://www.itzgeek.com/how-tos/linux/fedora-how-tos/ Install-apache2-with-php5-and-mysql-on-fedora-21-lamp.html#axzz3ol5qoz16

Resources:

Https://www.howtoforge.com/fedora-21-apache-mysql-php-lamp


LAMP stands for Linux,apache,mysql and PHP. Most of the websites works with the above combination. The main purpose of LAMP is testing the application locally by the programmer before going to the production. Below is the steps to install LAMP (Apache, PHP and MySQL) on Fedora.

Installing Linux:


Here I am isn't going to show how to install Fedora 21. The main purpose of this post are to setup AMP (Apache,mysql and PHP) only.

Installing Apache:


To start off we'll install Apache. Open up the terminal and swicth to root.


$ su


Name of the package was httpd, type following command on the terminal and then press ENTER.


# yum Install httpd


Start the Apache by using the following command.


# Systemctl Start Httpd.service


The Apache to start during the every boot, type the following on terminal and hit Enter.


# Systemctl Enable Httpd.service


Configure firewall to allow HTTP request from the external network.


Firewall-cmd--permanent--zone=public--add-service=http

Firewall-cmd--permanent--zone=public--add-service=https

Firewall-cmd--reload


Testing Apache:


To make sure everything installed correctly we'll now test Apache to ensure it's working properly.


Open up any Web browser and then enter the following into the Web address:


http://localhost/or http://192.168.0.10


You'll get the Web page saying "Fedora Test page". Now the Apache is working fine. Apache ' s default document root is/var/www/html on Fedora, and the configuration file is/etc/httpd/conf/httpd.conf. Additional configurations is stored in the/etc/httpd/conf.d/directory.

Fedora 21-apache Default Pagefedora 21? Apache Default Page

Installing MySQL:


Next is to install the MySQL on the Linux, follow the Steps. Type the following command and then press Enter.


# yum Install mariadb Mariadb-server


Start MySQL Server.


# Systemctl Start Mariadb.service


The MySQL to start during the every boot, type the following on terminal and hit Enter.


# Systemctl Enable Mariadb.service


Nex is to make the MySQL secure by using the Mysql_secure_installation command.


This program enables your improve the security of your MySQL installation in the following ways:


You can set a password for root accounts.

You can remove root accounts that is accessible from outside the local host.

You can remove Anonymous-user accounts.

You can remove the test database (which by default can is accessed by all users, even anonymous users), and privileges tha T permit anyone to access databases with names, start with Test_.


[Root@server1 ~]# Mysql_secure_installation


Note:running all PARTS of this SCRIPT are 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 would be blank,

So, should just press ENTER here.


Enter current password to root (enter for none):

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] Y

New Password:

Re-enter new password:

Password Updated successfully!

Reloading privilege tables.

... success!


By default, a MariaDB installation have an anonymous user, allowing anyone

To log into MariaDB without has to has a user account created for

them. This was intended only for testing, and the installation

Go a bit smoother. You should remove them before moving into a

Production environment.


Remove anonymous users? [y/n]

... success!


Normally, Root should only is allowed to connect from ' localhost '. This

Ensures that someone cannot guess at the root of password from the network.


Disallow Root login remotely? [y/n]

... success!


By default, MariaDB comes with a database named ' test ' that anyone can

Access. This was also intended only for testing, and should be removed

Before moving into a production environment.


Remove test database and access to it? [y/n]

? Dropping test database ...

... success!

? Removing privileges on test database ...

... success!


Reloading the privilege tables would ensure that all changes made so far

would take effect immediately.


Reload privilege tables now? [y/n]

... success!


Cleaning up ...


All done! If you ' ve completed all of the above steps, your MariaDB

Installation should now is secure.


Thanks for using mariadb!

Installing PHP:


By default Apache server supports the HTML language only, not PHP for that we need to install PHP. To install PHP follow the steps. Type following line on the terminal and press ENTER, this command includes the support package for the MySQL.


# Yum Install php php-mysql


You need to restart the Apache service after the installation of the PHP, to-do-type the following on the terminal.


# systemctl Restart Httpd.service


Testing PHP:


For testing the PHP, place one PHP file in to the default directory of the Apache. The document root of the default Web site is/var/www/html. We are now to create a small PHP file (info.php) in this directory and call it in a browser. The file would display lots of useful details about our PHP installation, such as the installed PHP version.


In the terminal copy/paste the following line:


# vi/var/www/html/info.php


This would open up a file called info.php.


Copy/paste this line into the Phpinfo file:



Save and close the file. Use ESC +; Wq for saving the file.


Now open your ' re Web browser and type the following into the Web address:


http://localhost/info.php or http://192.168.0.10/info.php


The page look like below:

Fedora 21-lamp Phpinfofedora 21? LAMP PHPInfo


Scroll down the browser to modules sections to check the support for the MySQL. You'll get the screen like below.

Fedora 21-lamp PHPInfo MySQL supportfedora 21? LAMP PHPInfo MySQL Support


Read more:http://www.itzgeek.com/how-tos/linux/fedora-how-tos/ Install-apache2-with-php5-and-mysql-on-fedora-21-lamp.html#ixzz3omdfncwb

© Itzgeek. All rights reserved.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.