setting up lamp for linux newbies

16
Setting up LAMP for Linux Newbies Shabir Ahmad

Upload: shabir-ahmad

Post on 16-Jul-2015

78 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Setting up LAMP for Linux newbies

Setting up LAMP for Linux Newbies

Shabir Ahmad

Page 2: Setting up LAMP for Linux newbies

Agenda

● What is LAMP● Setting up LAMP using tasksel● Introduction to apache2● Enabling/Disabling service● Phpmyadmin installation● Useful Commands

Page 3: Setting up LAMP for Linux newbies

What is LAMP

● L = Linux● A = Apache● M = Mysql, SQLite● P = php, python, perl

Page 4: Setting up LAMP for Linux newbies

Setting up LAMP

● Tasksel aka Task select – Is a software utility used to install various softwars like

LAMP, OpenSSH, Samba Server

– Installation: sudo apt-get install tasksel

– Once it is installed enter sudo tasksel, tasksel utility will opened

– Select LAMP from the list press space to select and then press tab to select ok. Press enter to continue

– During the installation it will ask you mysql root password

Page 5: Setting up LAMP for Linux newbies

Apache2 configuration● apache2.conf: the main Apache2 configuration file. Contains settings that are global

to Apache2.

● httpd.conf: historically the main Apache2 configuration file, named after the httpd daemon. Now the file does not exist. In older versions of Ubuntu the file might be present, but empty, as all configuration options have been moved to the below referenced directories.

● conf-available: this directory contains available configuration files. All files that were previously in /etc/apache2/conf.d should be moved to /etc/apache2/conf-available.

● conf-enabled: holds symlinks to the files in /etc/apache2/conf-available. When a configuration file is symlinked, it will be enabled the next time apache2 is restarted.

● envvars: file where Apache2 environment variables are set.

Page 6: Setting up LAMP for Linux newbies

● mods-available: this directory contains configuration files to both load modules and configure them. Not all modules will have specific configuration files, however.

● mods-enabled: holds symlinks to the files in /etc/apache2/mods-available. When a module configuration file is symlinked it will be enabled the next time apache2 is restarted.

● ports.conf: houses the directives that determine which TCP ports Apache2 is listening on.

● sites-available: this directory has configuration files for Apache2 Virtual Hosts. Virtual Hosts allow Apache2 to be configured for multiple sites that have separate configurations.

● sites-enabled: like mods-enabled, sites-enabled contains symlinks to the /etc/apache2/sites-available directory. Similarly when a configuration file in sites-available is symlinked, the site configured by it will be active once Apache2 is restarted.

● magic: instructions for determining MIME type based on the first few bytes of a file.

https://help.ubuntu.com/lts/serverguide/httpd.html

Page 7: Setting up LAMP for Linux newbies

Project directory

● By default when apache is installed the file should go in /var/www/html/

● It can be changed though● Most apache related configuration lies in

/etc/apache2 – modules

– Error logs

– Virtual hosts

Page 8: Setting up LAMP for Linux newbies

Apache problems

● After installing apache sometime you want index.php as default rather than index.html

● Type sudo vi /etc/apache2/mods-enabled/dir.conf

● Move index.php at the very beginning

Page 9: Setting up LAMP for Linux newbies

Setting up Virtual host

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf

● ServerAdmin : The address of website admininistrator

● ServerName: The name of server in our case example.com

● ServerAlias: The aliase of server name eg www.example.com

● DocumentRoot: Document root eg /var/www/html/example.com/public_html

● Enabling virtual host● sudo a2ensite mynewsite

● sudo service apache2 restart

● Disabling virtual host ????

For detail follow the link

https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts

Page 10: Setting up LAMP for Linux newbies

Apache – Frequently used commands

● Enabling module (sudo a2enmod <modname>)

● Disabling module(sudo a2dismod <modname>)

● Enabling virtual host (sudo a2ensite <site-name>)

● Disabling virtual host (sudo a2dissite <site-name>)

● Showing apache error log (tail -f /var/log/apache2/error.log)

● Restarting apache (sudp service apache2 restart)

● Alternative (sudo /etc/init.d/apache2 restart)

Page 11: Setting up LAMP for Linux newbies

PHP Configuration

● /etc/php5/apache2/php.ini● /etc/php5/cli/php.ini● Browser based configuration lies in first ini file● Second ini file is about command line scripts

php

Page 12: Setting up LAMP for Linux newbies

Phpmyadmin

● Phpmyadmin Is a database manager for managing various databases

● It is not installed by default, to Install it– Sudo apt-get install phpmyadmin

Page 13: Setting up LAMP for Linux newbies

Useful Commands

● Listing file – Ls for listing only

– Ls -h list all including hidden file

– Ls -ah list all file with detail

– Type man ls for all switches

● Changing directory– Cd <dri-name>

– Cd .. change to parent directory

– Cd ~ move to home directory

– Cd / move to root directory

● Permission and ownership– Sudo chmod -R 777 <file-or-dir-name>

– Sudo chown $USER:$USER <file-or-dirname>

Page 14: Setting up LAMP for Linux newbies

Useful Commands

● Moving and copying files– Sudo cp -r <source> <disrination>

– Sudo mv -r <source> <destination>

● Creating files and directories– Files: Sudo touch <file-name>

– Directory: sudo mkdir <dir-name>

● Removing file (Danger)– Rm -r <dir-name>, rm <file-name>

● Pattern search with grep– Used with pipe most of the time to pipeline two commands

– History | grep scp (Search in history those commands having the word scp)

Page 16: Setting up LAMP for Linux newbies

Q&A

Thank you for your patience