7. Installing C/C++ compiler
C compiler comes with default packages in Ubuntu/Mint
We need to install C++ compiler for programming in C++
sudo apt-get install build-essential
sudo apt-get install g++
8. Creating a new file/ c program
Go to your home folder
cd ~/
Then go to your “cprogram” folder
cd programming
cd cprogram
Create a new file or c program
nano hello.c
OR
gedit hello.c
10. Compile and debug c program
Compiling without flags
gcc hello.c -o helloWorld
Compiling with flags
gcc -Wall -W -Werror hello.c -o HelloWorld
Run program
./HelloWorld
11. Creating a c++ program
Go to your home folder
cd ~/
Then go to your “cprogram” folder
cd programming
cd cppprogram
Create a new file or c program
nano new.cpp
OR
gedit new.cpp
12. Compile and debug c++ program
Compiling without flags
g++ new.cpp -o NewWorld
Compiling with flags
g++ -Wall -W -Werror new.cpp -o NewWorld
Run program
./NewWorld
14. Python Interpreter
Python comes with build in package in Ubuntu/Mint
Check python is installed or not
python –version
If not, install python using following command
sudo apt-get install python
Run python interpreter using
python
Type
print “Hello World”
15. Run Python from a separate file
cd ~/
cd programming
cd python
Creating a new python program
nano hello.py
OR
gedit hello.py
16. Things to Remember
Add this line to indicate python interpreter
#! /usr/bin/python
Give proper permission to the file
chmod a+x hello.py
u stands for user.
g stands for group.
o stands for others.
a stands for all. x stand for execute
r stand for read
w stand for right
17. More about permission
# Permission rwx
7 read, write and execute 111
6 read and write 110
5 read and execute 101
4 read only 100
3 write and execute 011
2 write only 010
1 execute only 001
0 none 000
To know more visit: http://en.wikipedia.org/wiki/Chmod
18. Ah!!! Lets run now
To run python program
python hello.py
20. LAMP Stack
LAMP stands for L=Linux , A = Apache , M=MySQL P=PHP
Alternative of LAMP is LEMP
L= Linux , E= nginx (Engine X) , M= MySQL, P=PHP
21. Setting up Apache Server
Update software package source
sudo apt-get update
Installing apache2
sudo apt-get install apache2
Testing Web Server
http://localhost
Web Server default folder
/var/www/html
22. Install and Configure MySQL
First we need to install MySQL Server
sudo apt-get install mysql-server
Configure MySQL server
mysql_secure_installation
23. Creating database and user
First login to mysql
mysql -u root -p // root is default user.
To create a database
create database lollipop; // 'lolipop' is our database name
To create user and give permission
grant all on lollipop.* to 'candy' identified by '5t1ck';
// 'candy' is username. '5t1ck' is password
Update privileges
flush privileges;
To know more about MySQL CLI : http://dev.mysql.com/doc/refman/5.6/en/mysql.html
24. Installing PHP and helper package
Installing PHP5
sudo apt-get install php5
Lib-apache module for php5
sudo apt-get install libapache2-mod-php5
To connect mysql with php
sudo apt-get install php5-mysql
GD module for php
sudo apt-get install php5-gd
PHP CLI
sudo apt-get install php5-cli
25. Creating and Running PHP file
Go to web server folder
cd /var/www/html
Create a new file
nano info.php or gedit info.php
Inside the file , paste this code
<?php phpinfo(); ?>
Run the file from your browser
http://localhost/info.php
26. Change apache, PHP, MySQL configuration
To change apache configuration
sudo gedit /etc/apach2/apache2.conf
To change PHP configuration
sudo gedit /etc/php5/apache2/php.ini
To change MySQL configuration
sudo gedit /etc/mysql/my.cnf
27. Changing Web Server Server Directory
Edit apache2 config file
sudo gedit /etc/apach2/apache2.conf
Change directory to your own directory
<Directory /home/programming/php/>
Options Indexes
FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes
FollowSymLinks
AllowOverride All
Require all granted
</Directory>
28. Restarting apache Server
If we make any change on the server configuration, always
need to restart the server
To restart apache server
sudo service apache2 restart
29. Installing phpmyadmin
To install
sudo apt-get install phpmyadmin
It should automatically configure the phpmyadmin. Can be
run through http://localhost/phpmyadmin
If you need to re-cofigure phpmyadmin run
sudo dpkg-reconfigure -plow phpmyadmin
Then edit apache config file and add this line add the end of
that file.
Include /etc/phpmyadmin/apache.conf
Restart web server
31. Creating Virtual Host
Go to apache sites-available directory
cd /etc/apache2/sites-available/
Create a new file
sudo gedit dev.conf
Paste this code on the file
<VirtualHost *:80>
ServerAdmin webmaster@local.dev
ServerName local.dev
ServerAlias www.local.dev
DocumentRoot /home/programming/php/dev/
ErrorLog /home/programming/php/dev/error.log
</VirtualHost>
32. Configure Virtual host
cd ~/
cd programming
cd php
mkdir dev
chown -R user:user dev
chmod 755 -R dev
33. Enable and Run Virtual host
To enable virtual host
sudo a2ensite dev.conf
Edit host file to assign local IP (Option)
sudo gedit /etc/hosts
Restart apache
sudo service apache2 restart
To run newly created host
http://local.dev