How to install a Web server Apache + MySQL + PHP = LAMP | MySQL and PHP

Almost every website uses the MySQL database.

How to install MySQL on CentOS


Thanks to Yum install the MySQL database server is limited toone team, and the package manager will install all necessarydependencies:


Start the MySQL daemon:

In the console, should see a green button [OK]


Configure the MySQL server to run at startup (when you turn onthe server):


Reload the server:

And we will make sure that the MySQL server is restarted:

How to set up MySQL on CentOS


Before using for the first time, you must configure the MySQL server. And primarily for security reasons. So by default, theROOT user is MySQL has a blank password, as well as for ROOTaccess from outside. That is, we will set the password for ROOT and allow him access only from our local server. To do so, executethe script:


At the password prompt, press [Enter], then answer Yes to all questions and enter (twice), the new ROOT password MySQL user (not user root with putal′ Server CentOS). Now our MySQL database server meets the basic safety requirements.
How to install PHP on CentOS


Installing PHP still boils down to one team:


Restart the Apache Web server:

Create a test file with a text editor nano, to make sure that PHP is working, and will check the installed modules:

With the following content:

Then type in the browser address http://website/info.php and we will see something like the following picture:

Depending on the number of programs installed and configured the server can take several screens.

Installing additional modules for PHP on CentOS


If necessary, install additional PHP modules. For example phpmysql for MySQL database:


Do not forget to restart Apache after each installation of additional modules for PHP as indicated above:

For a complete list of available modules can be found on the team:

The Basic setting of the popular set of LAMP to our Web server is finished.