Install Apache, MySQL, PHP on CentOs 6
LAMP stack is the most powerful open source solution on the web. LAMP stands for Linux, Apache, MySQL and PHP. In this article we are going to install these on CentOs 6. So We already have Linux running centOs. We will work on the next three in this article.
For installation you have to login on the terminal with root privileges. Otherwise you will need to use sudo with every command.
INSTALL APACHE
To install Apache type this command in terminalYou can skip sudo if you are logged in as root. Above command will install apache and will create a directory /var/www/html Next make Apache to restart on server Reboot
Now start Apache with following command
You can now navigate on the browser with your IP or Domain (If it is mapped to the IP).
You will now see a page running Apache like below. This page will be removed when you upload your index file in /var/www/html
INSTALL PHP
Now Install PHP with following commandAbove command will install php and php-mysql module. You can check its version with php -v command. You can install multiple modules in one command separated by space like we did in the above command. You will need some dependencies to work with php. So install them as well.
Now restart Apache with following command
So as of now we have installed Apache and PHP. Let us proceed further and install MySQL.
INSTALL MYSQL
Install MYSQL with following commandNext make Apache to restart on server Reboot
Now start MySQL with following command
This will display info something like this
123456789101112131415161718192021222324252627282930313233343536
Initializing MySQL database: Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h li1256-197 password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
[ OK ]
Starting mysqld: [ OK ]
As it says above let us now set a root MySQL password. Type the following command in terminal. Above command will display something like this in terminal and will ask some questions to fill in. Fill in what it asks including root password. mypwd@123 is the sample password used below. Choose a secure password for root.
123456789101112131415161718192021222324
Enter current password for root (enter for none):
OK, successfully used password, moving on...
.........
.........
Set root password? [Y/n] Y
New password: mypwd@123
Re-enter new password: mypwd@123
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
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!
Install Apache, MySQL, PHP on CentOs 6
Reviewed by JS Pixels
on
December 22, 2015
Rating:
No comments: