Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Develop locally, deploy globally

DaFED
September 04, 2013

Develop locally, deploy globally

DaFED #14
Speaker: Čaba Pardovicki, Develomon
LAMP, WAMP, MAMP and everything else;

DaFED

September 04, 2013
Tweet

More Decks by DaFED

Other Decks in Programming

Transcript

  1. Develop locally The workflow • local site - each developer

    with their own environment (you are NOT working on the live site, are you?) • development site • staging site (Client: Can I try it out?) • production site + version control system (Git, Subversion, CVS)
  2. *AMP • Apache web server: The world's most popular web

    server • MySQL database server: The world's most popular database server • PHP: server-side scripting language designed for web development
  3. Install? • single application that will install all three •

    install precompiled, ready-to-go binaries of each component. • compile and install each of the three components yourself using their respective source codes
  4. Windows XAMPP (1.8.2) • Apache 2.4.4 • MySQL 5.5.32 •

    PHP 5.4.19 • phpMyAdmin 4.0.4 • FileZilla FTP Server 0.9.41 • Tomcat 7.0.42 (with mod_proxy_ajp) • Strawberry Perl 5.16.3.1 Portable • XAMPP Control Panel 3.2.1 http://www.apachefriends.org/en/xampp.html
  5. XAMPP - Virtual Host <VirtualHost local.example.com> DocumentRoot "C:\path\to\your\site" ServerName local.example.com

    CustomLog "C:\path\to\your\site\logs\local.example.access.log" combined ErrorLog "C:\path\to\your\site\logs\local.example.error.log" <Directory "C:\path\to\your\site"> Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
  6. Local PHP settings (php.ini) Maximum execution time of each script,

    in seconds max_execution_time = 300 Maximum amount of time each script may spend parsing request data max_input_time = 90 Maximum amount of memory a script may consume memory_limit = 256M Maximum size of POST data that PHP will accept. post_max_size = 256M Maximum allowed size for uploaded files upload_max_filesize = 64M
  7. Mac OS (10.8 Mountain Lion) - Apache Start pre-installed Apache

    form terminal: /Applications/Utilities/Terminal sudo apachectl start sudo apachectl stop sudo apachectl restart Check Apache version: httpd -v system wide web root folder: /Library/WebServer/Documents/
  8. Mac OS (10.8 Mountain Lion) - Apache Make new folder

    /Users/username/Sites/ cd /etc/apache2/users sudo nano username.conf <Directory "/Users/username/Sites/"> Options Indexes MultiViews AllowOverride All Order allow,deny Allow from all </Directory> sudo chmod 644 username.conf sudo apachectl restart sudo nano /etc/apache2/httpd.conf LoadModule php5_module libexec/apache2/libphp5.so (uncomment, PHP 5.3.15) sudo apachectl restart
  9. Mac OS (10.8 Mountain Lion) - MySQL http://dev.mysql.com/downloads/mysql/ sudo /usr/local/mysql/support-files/mysql.server

    start cd ; nano .bash_profile export PATH="/usr/local/mysql/bin:$PATH" source ~/.bash_profile /usr/local/mysql/bin/mysqladmin -u root password 'yourpasswordhere' http://tinyurl.com/dafed-mamp-setup
  10. Mac OS (10.8 Mountain Lion) - MAMP, XAMPP http://www.mamp.info/en/index.html (dmg

    package) or http://www.apachefriends.org/en/xampp-macosx.html (dmg package)
  11. Linux - XAMPP $ wget http://www.apachefriends.org/download.php?xampp-linux-1.8.2.tar.gz (as root or use

    sudo) # tar -xzvf xampp-linux-1.8.2.tar.gz -C /opt # /opt/lampp/lampp start # mkdir /opt/lampp/htdocs/www # chmod 777 /opt/lampp/htdocs/www $ ln -s /opt/lampp/htdocs/www /home/www
  12. Linux - XAMPP # /opt/lampp/lampp start - star XAMPP server

    # /opt/lampp/lampp stop - stop XAMPP server # /opt/lampp/lampp restart - restart XAMPP server # /opt/lampp/lampp startapache - start Apache server # /opt/lampp/lampp startssl - start/enable ssl # /opt/lampp/lampp startmysql - start MySQL server # /opt/lampp/lampp startftp - start ProFTPD server # /opt/lampp/lampp stopapache - stop Apache server # /opt/lampp/lampp stopssl - stop/disable ssl # /opt/lampp/lampp stopmysql - stop MySQL server # /opt/lampp/lampp stopftp - stop ProFTPD server # /opt/lampp/lampp security - start security check
  13. Linux - package install Debian/Ubuntu sudo apt-get install apache2 php5

    php5-gd libapache2-mod-php5 mysql-server mysql-client php5-mysql phpmyadmin php-apc php-pear sudo a2enmod rewrite or using tasksel sudo apt-get install tasksel tasksel install lamp-server tasksel --task-packages lamp-server
  14. Linux sudo mkdir /var/www/test sudo nano /etc/apache2/sites-available/001-test <VirtualHost *:80> ServerName

    local.test.com DocumentRoot /var/www/test <Directory /var/www/test/> Options Indexes FollowSymLinks AllowOverride all Order allow,deny allow from all </Directory> </VirtualHost> sudo a2ensite 001-test sudo nano /etc/hosts 127.0.0.1 local.test.com sudo /etc/init.d/apache2 restart / apache2ctl restart sudo sed -i 's/memory_limit = 16M/memory_limit = 64M/' /etc/php5/apache2/php.ini
  15. Deploy globally (or mostly Linux) FTP? SSH? Rsync? Command line

    basics: • List folder’s content: ls  • Change folder: cd [path] • Go one folder back/up: cd .. • New folder: mkdir [folder_name]   • Rename file/folder: mv [file_name] [new_name] • Copy: cp [source] [destination], cp –r for folders   • Remove: rm [file], rm –r [folder]  • Show current folder path: pwd • Change security privileges: sudo
  16. Deploy globally or mostly Linux Linux permissions r = read

    permission (4) w = write permission (2) x = execute permission (1) - = no permission (0) u = user g = group o = other 777 - rwx rwx rwx 755 - rwx r-x r-x 644 - rw- r-- r-- chown - change file owner and group chmod - change file mode bits Hint: fix cPanel permission issue // Directories: find . -type d -exec chmod 755 {} \; // Files: find . -type f -exec chmod 644 {} \;
  17. Virtual machine VirtualBox https://www.virtualbox.org/ • Start Virtualbox • File ->

    Import Appliance -> Choose file... -> (select the downloaded ova file) • Set RAM to 50% of your system ram. (min 1024mb, max 2048mb) • Import -> (wait for import to finish) Turnkey Linux - LAMP Stack http://www.turnkeylinux.org/lampstack
  18. Virtual machine Drupal Quickstart http://drupal.org/project/quickstart Pre-made Development Environment DrupalPro Development

    Desktop (Ubuntu 12.04) https://drupal.org/project/drupalpro Aims to be ready out-of-the-box for building websites, developing, theming, and contributing to Drupal. It's also useful for Trainers looking for a clean stable environment that can be setup in short-order. BitNami http://bitnami.com/ apps and development environments for PHP, Rails, Django, Node.js and Java. Available for Windows, Mac OS X and Linux.