← Joe Huang

Joomla-Apache-MySQL-PHP-CentOS6

2016-01-07

How To Install Linux, Apache, MySQL, PHP (LAMP) stack On CentOS 6

May 22, 2012   CentOS rn

About LAMP

LAMP stack is a group of open source software used to get web servers up and running. The acronym stands for Linux, Apache, MySQL, and PHP. Since the server is already running CentOS, the linux part is taken care of. Here is how to install the rest.

Set Up

The steps in this tutorial require the user on the virtual private server to have root privileges. You can see how to set that up in the Initial Server Setup Tutorial in steps 3 and 4.

Step One—Install Apache

Apache is a free open source software which runs over 50% of the world’s web servers. rnTo install apache, open terminal and type in this command:
sudo yum install httpd
Once it installs, you can start apache running on your VPS:
sudo service httpd start
That’s it. To check if Apache is installed, direct your browser to your server’s IP address (eg. http://12.34.56.789). The page should display the words “It works!" like this.

How to find your Server’s IP address

You can run the following command to reveal your server’s IP address.
ifconfig eth0 | grep inet | awk '{ print $2 }'

Step Two—Install MySQL

MySQL is a powerful database management system used for organizing and retrieving data on a virtual serverrnrnTo install MySQL, open terminal and type in these commands:
sudo yum install mysql-serverrnsudo service mysqld start
During the installation, MySQL will ask you for your permission twice. After you say Yes to both, MySQL will install. rnOnce it is done installing, you can set a root MySQL password:
sudo /usr/bin/mysql_secure_installation
The prompt will ask you for your current root password. rnSince you just installed MySQL, you most likely won’t have one, so leave it blank by pressing enter.
Enter current password for root (enter for none): 
OK, successfully used password, moving on...
Then the prompt will ask you if you want to set a root password. Go ahead and choose Y and follow the instructions. rnCentOS automates the process of setting up MySQL, asking you a series of yes or no questions. rnIt’s easiest just to say Yes to all the options. At the end, MySQL will reload and implement the new changes.
By default, a MySQL installation has an anonymous user, allowing anyonernto log into MySQL without having to have a user account created forrnthem.  This is intended only for testing, and to make the installationrngo a bit smoother.  You should remove them before moving into arnproduction environment.
rnRemove anonymous users? [Y/n] y                                            
 ... Success!
rnNormally, root should only be allowed to connect from 'localhost'.  Thisrnensures that someone cannot guess at the root password from the network.
rnDisallow root login remotely? [Y/n] yrn... Success!
rnBy default, MySQL comes with a database named 'test' that anyone canrnaccess.  This is also intended only for testing, and should be removedrnbefore moving into a production environment.
rnRemove test database and access to it? [Y/n] yrn - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
rnReloading the privilege tables will ensure that all changes made so farrnwill take effect immediately.
rnReload privilege tables now? [Y/n] yrn ... Success!
rnCleaning up...
rnAll done!  If you've completed all of the above steps, your MySQLrninstallation should now be secure.
rnThanks for using MySQL!

Step Three—Install PHP

PHP is an open source web scripting language that is widely used to build dynamic webpages. rnTo install PHP on your virtual private server, open terminal and type in this command:
sudo yum install php php-mysql
Once you answer yes to the PHP prompt, PHP will be installed.

PHP Modules

PHP also has a variety of useful libraries and modules that you can add onto your server. You can see the libraries that are available by typing:
yum search php-
Terminal then will display the list of possible modules. The beginning looks like this:
php-bcmath.x86_64 : A module for PHP applications for using the bcmath libraryrnphp-cli.x86_64 : Command-line interface for PHPrnphp-common.x86_64 : Common files for PHPrnphp-dba.x86_64 : A database abstraction layer module for PHP applicationsrnphp-devel.x86_64 : Files needed for building PHP extensionsrnphp-embedded.x86_64 : PHP library for embedding in applicationsrnphp-enchant.x86_64 : Human Language and Character Encoding Supportrnphp-gd.x86_64 : A module for PHP applications for using the gd graphics libraryrnphp-imap.x86_64 : A module for PHP applications that use IMAP
To see more details about what each module does, type the following command into terminal, replacing the name of the module with whatever library you want to learn about.
yum info name of the module
Once you decide to install the module, type:
sudo yum install name of the module
You can install multiple libraries at once by separating the name of each module with a space. rnCongratulations! You now have LAMP stack on your droplet! rnWe should also set the processes to run automatically when the server boots (php will run automatically once Apache starts):
sudo chkconfig httpd onrnsudo chkconfig mysqld on

Step Four—RESULTS: See PHP on your Server

Although LAMP is installed on your virtual server, we can still take a look and see the components online by creating a quick php info pagernrnTo set this up, first create a new file:
sudo nano /var/www/html/info.php
Add in the following line:
<?phprnphpinfo();
?>
Then Save and Exit. rnRestart apache so that all of the changes take effect on your virtual server:
sudo service httpd restart
Finish up by visiting your php info page (make sure you replace the example ip address with your correct one): http://12.34.56.789/info.phprnrnIt should look similar to this.

See More

After installing LAMP, you can go on to do more with MySQL (A Basic MySQL Tutorial), Create an SSL Certificate, or Install an FTP Server. rn

How To Install Joomla on a Virtual Server Running CentOS 6

Sep 27, 2012  Joomla CentOS rn

About Joomla

Joomla is a free and open source content management that uses a PHP and a backend database, such as MySQL. It offers a wide variety of features that make it an incredibly flexible content management system right out of the box. It was created in 2005 and is currently the 2nd most popular content management site online. It now has over 10,000 addons to customize its functionality.

Setup

The steps in this tutorial require the user to have root privileges on their virtual private server. You can see how to set that up in steps 3 and 4 of the Initial Server Setup rnBefore working with Joomla, you need to have LAMP installed on your virtual server. If you don't have the Linux, Apache, MySQL, PHP stack on your VPS, you can find the tutorial for setting it up here: How to Install LAMP on CentOS 6. rnOnce you have the user and required software, you can start installing Joomla!

Step One—Download Joomla

To start, create a directory where you will keep your Joomla files temporarily:
mkdir temp
Switch into that directory:
cd temp
Then you can go ahead and download the most recent version of Joomla straight from their website. Currently, the latest version is 2.5.7.
wget http://joomlacode.org/gf/download/frsrelease/17410/76021/Joomla_2.5.7-Stable-Full_Package.tar.gzrn
This command will download the zipped Joomla package straight to your user's home directory on the virtual server. You can untar it with the following command, moving it straight into the default apache directory, /var/www :
sudo tar zxvf Joomla_2.5.7-Stable-Full_Package.tar.gz  -C /var/www/html

Step Two—Configure the Settings

Once the Joomla files are in the web directory, we alter a couple of permissions to give access to the Joomla installer. rnFirst create a Joomla configuration file and make it temporarily world-writeable:
sudo touch /var/www/html/configuration.phprnsudo chmod 777 /var/www/html/configuration.php
After the installation is complete, we will change the permissions back down to 755, which will make it only writeable by the owner.

Step Three—Create the Joomla Database and User

Now we need to switch gears for a moment and create a new MySQL directory for Joomla. rnGo ahead and log into the MySQL Shell:
mysql -u root -p
Login using your MySQL root password. We then need to create the Joomla database, a user in that database, and give that user a new password. Keep in mind that all MySQL commands must end with semi-colon. rnFirst, let's make the database (I'm calling mine Joomla for simplicity's sake—for a real server, however, this name is not very secure). Feel free to give it whatever name you choose:
CREATE DATABASE joomla;
Query OK, 1 row affected (0.00 sec)
Then we need to create the new user. You can replace the database, name, and password, with whatever you prefer:
CREATE USER juser@localhost;
Query OK, 0 rows affected (0.00 sec)
Set the password for your new user:
SET PASSWORD FOR juser@localhost= PASSWORD("password");
Query OK, 0 rows affected (0.00 sec)
Finish up by granting all privileges to the new user. Without this command, the Joomla installer will be able to harness the new mysql user to create the required tables:
GRANT ALL PRIVILEGES ON joomla.* TO juser@localhost IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)
Then refresh MySQL:
FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
Exit out of the MySQL shell:
exit
Restart apache:
sudo service httpd restart

Step Four—Access the Joomla Installer

Once you have placed the Joomla files in the correct location on your VPS, assigned the proper permissions, and set up the MySQL database and username, you can complete the remaining steps in your browser. rnAccess the Joomla installer going to your domain name or IP address. (eg. Example.com) rnOnce you have finished going through the installer, delete the installation folder per Joomla’s instructions and change the permissions on the config file:
sudo rm -rf /var/www/html/installation/
sudo chmod 755 /var/www/html/configuration.php
Visit your domain or IP address to see your new Joomla page. rn