Many people know from their own experience that it's not easy to install an Apache web server and it gets harder if you want to add MySQL, PHP and Perl.XAMPP is an easy to install Apache distribution containing MySQL, PHP and Perl. XAMPP is really very easy to install and to use - just download, extract and start.The philosophy behind XAMPP is to build an easy to install distribution for developers to get into the world of Apache. To make it convenient for developers XAMPP is configured with all features turned on. The default configuration is not good from a security point of view and it's not secure enough for a production environment - please don't use XAMPP in such environment.
Here are few steps to install and configure LAMP(Linux Apache MySQL PHP) server on RHEL6 for a production environment.
Apache is the most popular Web HTTP server for a Linux servers.
#yum install httpd httpd-devel
We might need the httpd-devel libraries to compile and install other modules from the sources, just to be on the safer side. /etc/httpd/conf/httpd.conf is the Apache configuration file location
#service httpd start
#chkconfig httpd on
Install MySQL Database Server
MySQL is a widely used open source database server on most Linux servers and can very well integrate to PHP and Apache server on CentOS/RHEL.
#yum install mysql mysql-server mysql-devel
If you attempt to type mysql in command prompt, you will be getting this nasty error.
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’
This is because you are not running the mysqld daemon before launching the mysql client. The file /var/lib/mysql/mysql.sock will be automatically created upon running the first instance of mysql.
First start the mysql daemon, then type mysql:
#service mysqld start
#chkconfig mysqld on
Changing MySQL Root Password
By default the root password is empty for the mysql database. It is a good idea to change the mysql root password to a new one from a security point of view.
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
mysql> FLUSH PRIVILEGES;
Once done, check by logging in:
#mysql -u root -p
Enter Password: <your new password>
To Create A New MySQL User
To create a new mysql user 'guest' with 'all privileges' on the database 'demo':
mysql > create database demo
mysql >GRANT ALL PRIVILEGES ON demo.* TO 'guest'@'localhost' IDENTIFIED BY 'guest' WITH GRANT OPTION;
mysql> UPDATE user SET Password=PASSWORD('guest') WHERE user='guest';
That's it! MySQL is ready! Don't forget to remember the root password as we might be using it with phpmyadmin.
To improve the MySQL security (Optional)Use the following command
This will help you to change MySQL default security settings in an interactive manner.
Install PHP5 Scripting LanguageInstalling PHP5 with the necessary modules is so easy and can be configured for both the Apache and mysql environment.
#yum install php php-mysql php-common php-mbstring php-mcrypt php-devel php-xml
Note: If we plan to run captcha scripts on our server which are dependent on mysql and other functions don't forget to install php-gd (gd library).
Restart Apache to load php.#service httpd restart
To Test If PHP Is Working Or Not:Create a file named /var/www/html/test.php with the following phpinfo() function inside php quotes.
Then point your browser to http://ip.address/test.php.
That's it! You should see a php configuration file displaying all kind of paths and installed modules.
Closely observe the installed configuration on your server.
* PHP Paths (php.ini path)
* Apache paths and Loaded Modules (mod_security, mod_evasive if installed_)
* PHP GD Library
* MySQL paths and other information
phpMyAdmin is a free web based MySQL database Administration Tool. Without phpMyAdmin it is almost impossible to mysql db operations in the command line. phpMyAdmin has become so convenient and it is absolutely sought by most webmasters to be present along with the mysql server.
#yum install phpmyadmin
Point your browser to: http://ip.address/phpmyadmin.
Common ErrorsYou might encounter the following errors while configuring phpmyadmin.
You don't have permission to access /phpmyadmin/ on this server.
Edit the /etc/httpd/conf.d/phpmyadmin.conf and uncomment the line deny from all.
# Deny from all
Allow from 127.0.0.1
The configuration file now needs a secret passphrase (blowfish_secret)
Look for a line and enter any password. Just dont leave it empty!
$cfg['blowfish_secret'] = 'mydemopass'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
Cannot load mcrypt extension. Please check your PHP configuration.
# vim /etc/php.d/mcrypt.ini
Look for a line and enter replace module.so with mcrypt.so
Restart the httpd service gracefully
#service httpd graceful
It worked for me using the above methods!
Log into the phpmyadmin with the mysql root password we changed while installing the mysql database