Okay, this time we will try to build LAMP (Linux + Apache + MySQL + PHP/Perl) together in one machine. Assumed that we had VPS with minimum requirement. At least, 1Gb disk space, multiprocessor, and 256Mb RAM. Thats all are minimum requirement for running this system well...
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’
This is because you are not running mysqld daemon before launching the mysql client. The file /var/lib/mysql/mysql.sock will be automatically creating upon running the first instance of mysql.
To fix:
First start the mysql daemon, then type mysql
Restart the apache to load php.
Thats it! you should see a php configuration file displaying all kind of paths and installed modules.
Closely observe the installed configuration in 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
yum install phpmyadmin
Point your browser to: http://ip.address/phpmyadmin
Forbidden
To fix:
Edit the /etc/httpd/conf.d/phpmyadmin.conf and uncomment the line deny from all
Error
To fix:
Login the phpmyadmin with mysql root password we changed while installing the mysql database.
Point your browser to: http://ip.address:10000
You should see a webmin login. But we dont know the login and password yet! To setup webmin password run the script below...
To uninstall webmin, just run /etc/webmin/uninstall.sh
Final Steps
We want the apache and mysql to be loaded every boot so we switch them on using chkconfig
Okay, you can find my entries in bahasa Indonesia at www.agranetonline.com
- Apache Web Server 2.0
- MySQL Database Serve 5.0
- PHP Scripting Language 5.0
- phpMyAdmin - Web based MySQL Administration Tool
- Webmin - A free web based hosting control panel
Install Apache
Apache is a the most popular Web HTTP server for a Linux servers.yum install httpd httpd-devel
We might need httpd-devel libraries, to compile and install other modules from the source, just to be on the safer side. /etc/httpd/conf/httpd.conf - Apache configuration file location/etc/init.d/httpd start
Install MySQL Database Server
MySQL is widely used open source database server on most linux servers and can very well integrated to PHP and Apache server in Centos/RHELyum install mysql mysql-server mysql-devel
If you attempt to type mysql in command prompt, you will be getting this nasty errorERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’
This is because you are not running mysqld daemon before launching the mysql client. The file /var/lib/mysql/mysql.sock will be automatically creating upon running the first instance of mysql.
To fix:
First start the mysql daemon, then type mysql
> /etc/init.d/mysqld start
> mysql
> mysql
Changing MySQL Root Password
By default the root password is empty for mysql database. It is a good idea to change mysql root password to a new one from 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 inmysql> UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
mysql> FLUSH PRIVILEGES;
> mysql -u root -p
Enter Password: <your new password>
Enter Password: <your new password>
To Create New MySQL User
To create a new mysql user 'guest' with 'all previleges' on database 'demo'mysql > create database demo
mysql >GRANT ALL PRIVILEGES ON demo.* TO 'guest'@'localhost' IDENTIFIED BY 'guest' WITH GRANT OPTION;
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('guest') WHERE user='guest';
Thats it! MySQL is ready! Dont forget to remember the root password as we might be using it with phpmyadminmysql >GRANT ALL PRIVILEGES ON demo.* TO 'guest'@'localhost' IDENTIFIED BY 'guest' WITH GRANT OPTION;
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('guest') WHERE user='guest';
Install PHP5 Scripting Language
Installing PHP5 with necessary modules is so easy and can be configured for both apache and mysql environment.yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml
Dont forget to install php-gd (gd library) is very important if we plan to run captcha scripts in our server and so as other which are dependent on mysql and other functions.Restart the apache to load php.
/etc/init.d/httpd restart
To test PHP 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// test.php
<?php
phpinfo();
?>
Thats it! you should see a php configuration file displaying all kind of paths and installed modules.
Closely observe the installed configuration in 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
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 mysql server.yum install phpmyadmin
Point your browser to: http://ip.address/phpmyadmin
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">
Order Deny,Allow
# Deny from all
Allow from 127.0.0.1
</Directory>
Order Deny,Allow
# Deny from all
Allow from 127.0.0.1
</Directory>
Error
The configuration file now needs a secret passphrase (blowfish_secret)
To fix:nano /usr/share/phpmyadmin/conf.inc.php
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! */
It worked for me using the above methods! Login the phpmyadmin with mysql root password we changed while installing the mysql database.
Install Webmin
Webmin a free server hosting control panel for linux servers. It is a web based hosting administration tool and can be handy to tweak settings in your server if you are beginner to linux! You can download webmin here. Since webmin cannot be installed using yum, we can download a RPM package and install in 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 firewall.rpm - i webmin-1.410-1.noarch.rpm
Point your browser to: http://ip.address:10000
You should see a webmin login. But we dont know the login and password yet! To setup webmin password run the script below...
> /usr/libexec/webmin/changepass.pl /etc/webmin admin <newpasswd>
login with 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 every boot so we switch them on using chkconfig
> chkconfig httpd on
> chkconfig mysqld on
> chkconfig mysqld on
Okay, you can find my entries in bahasa Indonesia at www.agranetonline.com
Tidak ada komentar:
Posting Komentar