Home‎ > ‎blog‎ > ‎

LAMP installation

posted 10 Jul 2010, 21:19 by Andreas Jostel   [ updated 10 Jul 2010, 22:10 ]

Apache

  • Copy site configuration:
    • sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/mysite
  • Edit mysite:
    • gksudo gedit /etc/apache2/sites-available/mysite
    • Change "DocumentRoot" to point to "/home/<user>/public_html/"
    • Change "Directory" to point to "/home/<user>/public_html/"
  • Deactivate and active sites:
    • sudo a2dissite default
    • sudo a2ensite mysite
  • Restart:
    • sudo /etc/init.d/apache2 restart
  • Create example file and put into public_html:
    • echo '<b>Hello! It is working!</b>' > /home/user/public_html/index.html
  • Access your site via:
    • http://localhost/
  • Run, Stop, Test, Restart Apache: use this:
    • sudo /usr/sbin/apache2ctl {start|stop|configtest|restart}
    • but why not?:
      • sudo /etc/init.d/apache2 {start|stop|configtest|restart}

PHP

  • php5
  • (already enabled:)
    • sudo a2enmod php5

MySQL

Setup

  • sudo gedit /etc/mysql/my.cnf
  • change bind-address to:
    • either (if locally only):
      • bind-address = localhost
    • or to local ip address (check with "ipconfig")
      • bind-address = 192.168.1.20
    • or if dynamic ip address: comment out
      • # bind-address
  • set mysql password
    • mysql -u root
    • mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword')
  • subsequent logins via
    • mysql -u root -p

Databases

  • Create database (may need to be done outside phpmyadmin?)
    • mysql> CREATE DATABASE database1;
  • Grant privileges, eg:
    • mysql> GRANT ALL PRIVILEGES ON *.* TO 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
    • mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON database1.* TO 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword';
  • use phpmyadmin at
    • http://localhost/phpmyadmin
  • Can also install
    • sudo apt-get install mysql-admin

Comments