Web Hosting
Web Hosting
Web Hosting
This tutorial shows a quick way of installing a LAMP server (Linux + Apache + MySQL + PHP/Perl together commonly known as LAMP Server.) on CentOS and RHEL server systems.
y y y y y
Apache Web Server 2.0 MySQL Database Server 5.0 PHP Scripting Language 5.0 phpMyAdmin - Web based MySQL Administration Tool Webmin - A free web based hosting control panel
Goal
To set up a LAMP server on a fresh VPS/Dedicated server running CentOS 5.0 with atleast 256mb of RAM. We will also be installing Webmin, a free server control panel for linux. If you are using a Debian/Ubuntu refer to this article.
Install Apache
Apache is the most popular Web HTTP server for a Linux servers.
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 - Apache configuration file location. /etc/init.d/httpd start
If you attempt to type mysql in command prompt, you will be getting this nasty error. ERROR 2002 (HY000): Cant 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. To fix:
mysql> USE mysql; mysql> UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root'; mysql> FLUSH PRIVILEGES; Once done, check by logging in:
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.
yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml
Don't forget to install php-gd (gd library). It is very important if we plan to run captcha scripts on our server and so as other which are dependent on mysql and other functions. Restart Apache to load php.
/etc/init.d/httpd restart
Install phpMyAdmin
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.
Common Errors
You might encounter the following errors while configuring phpmyadmin. Forbidden You don't have permission to access /phpmyadmin/ on this server. To fix: Edit the /etc/httpd/conf.d/phpmyadmin.conf and uncomment the line deny from all. nano /etc/httpd/conf.d/phpmyadmin.conf
<Directory "/usr/share/phpmyadmin">
nano /usr/share/phpmyadmin/conf.inc.php
Look for a line and enter any password. Just dont leave it empty!
Install Webmin
Webmin a free server hosting control panel for Linux. It is a web based hosting administration tool and can be handy to tweak settings in your server if you are a beginner to Linux! You can download webminhere. Since webmin cannot be installed using yum, we can download an RPM package and install it on our server. wget <webmin rpm path> rpm - i webmin-1.410-1.noarch.rpm That should be a pretty easy installation! Remember webmin uses port 10000 and should not be blocked by your firewall. Point your browser to: http://ip.address:10000 You should see a webmin login. But we don't know the login and password yet! To set up the webmin password run the script below...
Log in with the admin username and new webmin password! To uninstall webmin, just run: /etc/webmin/uninstall.sh
Final Steps
We want the Apache and mysql to be loaded at every boot so we switch them on using chkconfig:
chkconfig httpd on chkconfig mysqld on You can also place comments in my blog. I would appreciate any feedbacks as well! This tutorial was written and contributed to HowToForge by Mr.Balakrishnan who currently runs MySQL-Apache-PHP.com. Permission is fully granted to copy/republish this tutorial in any form, provided a source is mentioned with a live link back to the authors site.