Wednesday, 17 October 2012

Installing PHP5 and Apache on Ubuntu

sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo /etc/init.d/apache2 restart

how to install phpMyAdmin [ubantu]

Install phpMyAdmin from the Universe repository see InstallingSoftware for detailed instructions on using repositories and package managers. (Note, however, that installation from a package manager often does not work).
From console:
sudo apt-get install phpmyadmin
  • If you're using Ubuntu 7.10 (Gutsy) or later select Apache2 from the "Configuring phpmyadmin" dialog box.
To set up under Apache all you need to do is include the following line in /etc/apache2/apache2.conf.
Include /etc/phpmyadmin/apache.conf
  • If you are using Ubuntu 9.04 (Jaunty), there is no need to modify /etc/apache2/apache2.conf as the package installer already copied the file phpmyadmin.conf into /etc/apache2/conf.d directory. You can also skip the set up step and go directly to http://<hostname>/phpmyadmin and login with the user and password you set up during install.
Once phpMyAdmin is installed point your browser to http://localhost/phpmyadmin to start using it. You should be able to login using any users you've setup in MySQL. If no users have been setup, use admin with no password to login.
Should you get a 404 "Not Found" error when you point your browser to the location of phpMyAdmin (such as: http://localhost/phpmyadmin) this is likely caused by not checking the 'Apache 2' selection during installation. To redo the installation run the following:
 sudo dpkg-reconfigure -plow phpmyadmin
Then select Apache 2 for the webserver you wish to configure.
If this does not work, then you can do the following to include the phpMyadmin-shipped Apache configuration into Apache:
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf
sudo /etc/init.d/apache2 reload

Installing from source

You may install phpmyadmin from source. This method circumvents the package manager and you will need to install updates yourself. This is not recommended for a production web server. Also, you'll need to have Subversion installed to download the source.
To install it from source open the console and cd to the www directory using:
cd /var/www/
then download it using svn by writing:
sudo svn checkout https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/tags/STABLE/phpMyAdmin phpMyAdmin
then cd to phpMyAdmin
cd phpMyAdmin
and create the folder config
sudo mkdir config
after that chmod it
sudo chmod o+rw config
then open http://localhost/phpmyadmin/scripts/setup.php and follow the instructions.

How can I reset my MySQL password?[ubantu]

To reset your mysqld password just follow these instructions :
  • Stop the mysql demon process using this command :
    •    sudo /etc/init.d/mysql stop
  • Start the mysqld demon process using the --skip-grant-tables option with this command
    •    sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
Because you are not checking user privs at this point, it's safest to disable networking. In Dapper, /usr/bin/mysgld... did not work. However, mysqld --skip-grant-tables did.
  • start the mysql client process using this command
    •    mysql -u root
  • from the mysql prompt execute this command to be able to change any password
    •    FLUSH PRIVILEGES;
  • Then reset/update your password
    •    SET PASSWORD FOR root@'localhost' = PASSWORD('password');
  • If you have a mysql root account that can connect from everywhere, you should also do:
    •    UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
  • Alternate Method:
    •    USE mysql
         UPDATE user SET Password = PASSWORD('newpwd')
         WHERE Host = 'localhost' AND User = 'root';
  • And if you have a root account that can access from everywhere:
    •    USE mysql
         UPDATE user SET Password = PASSWORD('newpwd')
         WHERE Host = '%' AND User = 'root';
For either method, once have received a message indicating a successful query (one or more rows affected), flush privileges:
FLUSH PRIVILEGES;
Then stop the mysqld process and relaunch it with the classical way:
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
When you have completed all this steps ,you can easily access to your mysql server with the password you have set in the step before. An easy way to have a full control of your mysql server is phpmyadmin (www.phpmyadmin.net), software made in php that can give you a web interface that can be very usefull to people that havent got a lot of confidence with bash .To install phpmyadmin on you server you will need to have 4 things:
  • web server apache
  • php
  • mysql server/mysql client installed
  • php_mysql support for apache
All packages can be found browsing synaptic.




Another Way:

USE THIS AS A LAST RESORT METHOD, YOU WILL LOSE ALL YOUR MYSQL DATA
sudo apt-get --purge remove mysql-server mysql-common mysql-client
sudo apt-get install mysql-server mysql-common mysql-client
In the next step be sure to chance the your-new-password with the password you want!
mysqladmin -u root password your-new-password
sudo /etc/init.d/mysql restart
mysql -u root -p
You should now be logged in as root. Make sure to notedown your password