linux for programmers

Download Linux for programmers

If you can't read please download the document

Upload: md-al-amin

Post on 21-Jun-2015

116 views

Category:

Software


5 download

DESCRIPTION

Creating Linux enviroment for Programmers.

TRANSCRIPT

  • 1. Linux for ProgrammersMd. Al-Amin opuProgrammer and *nix user

2. Essential toolsgeditSublime Text 3. Installing geditsudo apt-get install gedit 4. Installing Sublime Text1. sudo add-apt-repository ppa:webupd8team/sublime-text-32. sudo apt-get update3. sudo apt-get install sublime-text-installerORDownload .deb file http://www.sublimetext.com/3 5. Setting up environmentcd ~/mkdir programmingcd programmingmkdir cprogrammkdir cppprogrammkdir pythonmkdir php 6. C/C++ Programming 7. Installing C/C++ compilerC compiler comes with default packages in Ubuntu/MintWe need to install C++ compiler for programming in C++sudo apt-get install build-essentialsudo apt-get install g++ 8. Creating a new file/ c programGo to your home foldercd ~/Then go to your cprogram foldercd programmingcd cprogramCreate a new file or c programnano hello.cORgedit hello.c 9. View the content of filecat filenamecat hello.c 10. Compile and debug c programCompiling without flagsgcc hello.c -o helloWorldCompiling with flagsgcc -Wall -W -Werror hello.c -o HelloWorldRun program./HelloWorld 11. Creating a c++ programGo to your home foldercd ~/Then go to your cprogram foldercd programmingcd cppprogramCreate a new file or c programnano new.cppORgedit new.cpp 12. Compile and debug c++ programCompiling without flagsg++ new.cpp -o NewWorldCompiling with flagsg++ -Wall -W -Werror new.cpp -o NewWorldRun program./NewWorld 13. Python Programming 14. Python InterpreterPython comes with build in package in Ubuntu/MintCheck python is installed or notpython versionIf not, install python using following commandsudo apt-get install pythonRun python interpreter usingpythonTypeprint Hello World 15. Run Python from a separate filecd ~/cd programmingcd pythonCreating a new python programnano hello.pyORgedit hello.py 16. Things to RememberAdd this line to indicate python interpreter#! /usr/bin/pythonGive proper permission to the filechmod a+x hello.pyu stands for user.g stands for group.o stands for others.a stands for all. x stand for executer stand for readw stand for right 17. More about permission# Permission rwx7 read, write and execute 1116 read and write 1105 read and execute 1014 read only 1003 write and execute 0112 write only 0101 execute only 0010 none 000To know more visit: http://en.wikipedia.org/wiki/Chmod 18. Ah!!! Lets run nowTo run python programpython hello.py 19. PHP-MySQLProgramming 20. LAMP StackLAMP stands for L=Linux , A = Apache , M=MySQL P=PHPAlternative of LAMP is LEMPL= Linux , E= nginx (Engine X) , M= MySQL, P=PHP 21. Setting up Apache ServerUpdate software package sourcesudo apt-get updateInstalling apache2sudo apt-get install apache2Testing Web Serverhttp://localhostWeb Server default folder/var/www/html 22. Install and Configure MySQLFirst we need to install MySQL Serversudo apt-get install mysql-serverConfigure MySQL servermysql_secure_installation 23. Creating database and userFirst login to mysqlmysql -u root -p // root is default user.To create a databasecreate database lollipop; // 'lolipop' is our database nameTo create user and give permissiongrant all on lollipop.* to 'candy' identified by '5t1ck';// 'candy' is username. '5t1ck' is passwordUpdate privilegesflush privileges;To know more about MySQL CLI : http://dev.mysql.com/doc/refman/5.6/en/mysql.html 24. Installing PHP and helper packageInstalling PHP5sudo apt-get install php5Lib-apache module for php5sudo apt-get install libapache2-mod-php5To connect mysql with phpsudo apt-get install php5-mysqlGD module for phpsudo apt-get install php5-gdPHP CLIsudo apt-get install php5-cli 25. Creating and Running PHP fileGo to web server foldercd /var/www/htmlCreate a new filenano info.php or gedit info.phpInside the file , paste this codeRun the file from your browserhttp://localhost/info.php 26. Change apache, PHP, MySQL configurationTo change apache configurationsudo gedit /etc/apach2/apache2.confTo change PHP configurationsudo gedit /etc/php5/apache2/php.iniTo change MySQL configurationsudo gedit /etc/mysql/my.cnf 27. Changing Web Server Server DirectoryEdit apache2 config filesudo gedit /etc/apach2/apache2.confChange directory to your own directoryOptions IndexesFollowSymLinksAllowOverride AllRequire all grantedOptions IndexesFollowSymLinksAllowOverride AllRequire all granted 28. Restarting apache ServerIf we make any change on the server configuration, alwaysneed to restart the serverTo restart apache serversudo service apache2 restart 29. Installing phpmyadminTo installsudo apt-get install phpmyadminIt should automatically configure the phpmyadmin. Can berun through http://localhost/phpmyadminIf you need to re-cofigure phpmyadmin runsudo dpkg-reconfigure -plow phpmyadminThen edit apache config file and add this line add the end ofthat file.Include /etc/phpmyadmin/apache.confRestart web server 30. Virtual Host 31. Creating Virtual HostGo to apache sites-available directorycd /etc/apache2/sites-available/Create a new filesudo gedit dev.confPaste this code on the fileServerAdmin [email protected] local.devServerAlias www.local.devDocumentRoot /home/programming/php/dev/ErrorLog /home/programming/php/dev/error.log 32. Configure Virtual hostcd ~/cd programmingcd phpmkdir devchown -R user:user devchmod 755 -R dev 33. Enable and Run Virtual hostTo enable virtual hostsudo a2ensite dev.confEdit host file to assign local IP (Option)sudo gedit /etc/hostsRestart apachesudo service apache2 restartTo run newly created hosthttp://local.dev 34. Remote Server 35. Login Via SSHssh user@hostnameExample : ssh [email protected] logout useexit or logout 36. Questions??? 37. Thank You