Installation instructions for LAMP (Linux, Apache, MySQL, PHP) on CentOS 6.4

Because the appearance has long recommended LAMP (which stands for Linux, Apache, MySQL, and PHP) are very popular in the world.
The steps to install LAMP on CentOS

First you need to prepare a new CentOS server does not at all, I use CentOS 64 bit 6.4. Before the operation you need to change the hostname and hosts file editing.
1. install Apache

sudo yum install httpd

Start Apache

sudo service httpd start

Test try by going to http:// you will see the message “Apache 2 Test Page”

The Apache Configuration File:


2. install MySQL

sudo yum install mysql-server
sudo service mysqld start

Proceed to install MySQL using the command


Due to the new install should if be asked your password press Enter

Enter current password for root (enter for none):
OK, successfully used password, moving on …

Then need to set root password by selecting y

Next you will have to answer a series of questions, pick the best medicine

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
… Success!

Normally, root should only be allowed to connect from ‘ localhost ‘. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
… Success!

By default, MySQL comes with a database named ‘test’ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
– Dropping test database…
… Success!
– Removing privileges on test database…
… Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
… Success!

Cleaning up…

All done! If you’ve completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

3. Cài đặt PHP

sudo yum install php php-mysql

PHP Modules

PHP có rất nhiều thư viện module khác nhau, bạn có thể xem bằng cách gõ lệnh sau

yum search php-

php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
php-cli.x86_64 : Command-line interface for PHP
php-common.x86_64 : Common files for PHP
php-dba.x86_64 : A database abstraction layer module for PHP applications
php-devel.x86_64 : Files needed for building PHP extensions
php-embedded.x86_64 : PHP library for embedding in applications
php-enchant.x86_64 : Human Language and Character Encoding Support
php-gd.x86_64 : A module for PHP applications for using the gd graphics library
php-imap.x86_64 : A module for PHP applications that use IMAP

Để cài module nào dùng lệnh sau

sudo yum install name of the module

4. Tự động chạy service khi reboot

sudo chkconfig httpd on
sudo chkconfig mysqld on

Restart Apache

sudo service httpd restart

OK so is the process of installing LAMP on CentOS finished.

Leave a Reply

Your email address will not be published.