 Good morning everybody. My name is Dastagir. Today's session I am going to take a small introduction on configuring web servers and a programming language called PHP and that is called MySQL. Before entering into say web servers, I am going to explain what is this web server means that. Let me say some example. Consider a hotel web, hotel server. What a hotel server do? When a client comes and asks for tea, the server goes inside and take the tea and gives to this client. Another client comes and asks for Italy or Sambar and the same server goes to take and search Italy, Sambar and give to the client. The same things happens in the software web servers. Client requesting and the server gives. This is a simple concept and idea of a web server. Today sessions we are going to take two web servers. One is Tomcat and another one is Apache 2. First let me start with the Tomcat. So now I am going to install Tomcat in Ubuntu 10.04. I am going to install Tomcat using our app and CD. See after inserting our app and CD, this pop-up menu will come. Cancel and start package manager. So now we are going to start the package manager. Just click on the package manager. Now I am going to install Tomcat 6. In quick search text box, please type Tomcat and press enter. It will display Tomcat 6 related applications. Now I am going to install Tomcat 6. Right click on Tomcat 6 and mark for installation. So it will also install all the dependencies packages. After selecting just click on apply button. It will download the packages from the CD. This Apache Tomcat 6 is used to run Java web applications, servlet and JSP pages. We will see how to run simple JSP page and web application, simple web application. So installation completed. Now how to start this server? Open your terminal. So after installing, we need to start the Tomcat server. sudo slash etc init dot d slash Tomcat 6. Start. It asks for the authentication. So our Tomcat servlet engine is started. So it shows the OK button. If it is not showing the OK, it has some problem. So now I want to test whether our server is working perfectly or not. So open your browser and type local host colon 8080. It will show it works page. So now our web server is working perfectly. Now I want to write a small JSP page and I want to run it. How to do that? Open your terminal. So our Tomcat 6 default root folder is cd slash where live Tomcat 6 web apps. This is our Tomcat 6 default to root folder. If you want to develop applications or if you want to run a web application, you must place your application in this folder only. Now I am going to create a small hello world JSP file. Before that, we need to add one folder to separate package name. For example, create a directory test. Our test directory is created. Change to the test directory. Now I am in test folder. Here I am going to write a simple hello world JSP file. So go g edit hello dot JSP. Here I am going to write a hello world JSP file. HTML, TML, body, hello world. That is it. This is a simple hello world JSP program. This will display hello world in our browser. This is simple HTML tag and body tag. This is very important. This is the syntax of JSP file. So now I created a JSP file. Now I want to run this hello dot JSP. So our test directory is created. Inside that, hello world dot JSP, hello dot JSP file is created. Now we need to restart the web server. How to restart our web server? Already we started our web server by using sudo slash etc slash init dot d slash tomcat start. Now how to restart our web server? Same, sudo slash etc init dot d tomcat 6 restart. This is the command to restart tomcat web server. So stopping tomcat server, engine tomcat 6 is OK. Which means that already started that is stopping now. After stopping, it is starting tomcat server, engine tomcat 6 is OK. So now our server late engine started. I am going to run our hello dot JSP file. Same, open your browser and type localhost colon 8080 slash our project name called test. Inside that, hello dot JSP. It shows, I think I forgot to close double code symbol. So this is, this is a sorrelate engine that shows error. If we made some syntax missing, syntax error. So we need to clear that. Same open, same JSP file and see here I forgot to close hello world. So only it is showing the error. Now I closed it. Again run same hello world. So it delay this space. Now our tomcat server is working fine. Our hello dot JSP file is working. If you have any doubts, please act right now. Because here after we are going to see another web servers called Apache 2 and programming language PHP and MySQL. Before starting that I need to clear you all this tomcat related doubts. Most of the remote centers requesting for, please say one more time. So I am going to explain, I am going to summarize everything related to tomcat. So please listen carefully. Using that up and CD package manager, we installed the tomcat 6. After installing tomcat 6, we need to start the server sudo slash etc init dot d tomcat 6 start. This command will start our tomcat sorrelate engine. After starting our tomcat, we need to test our tomcat. Please type local host colon 8080 in your browser. It will show it works button. If everything is working, everything configured correctly means it will show it works. After that we want to, if we want to run JSP file, go to tomcat's default to root directory cd slash var lib tomcat 6 web apps. This is the default to root directory of tomcat 6. If you want to run any JSP file, any sorrelate, you need to place your web applications here. Here we already created a test application cd test. Here we created a simple hello dot JSP file. This simple hello dot JSP file. Open that hello dot JSP file and type html body. This is the symbol of JSP file. This is the starting tag of JSP and hello world. This will print hello world in browser. After typing please say hello dot JSP file and open your browser slash test local host colon 8080 slash state hello dot JSP. It will show hello world. So, if it works means our tomcat 6 is working perfectly. Now I am going to say how to run var file, WAR file. This hello world dot var already created. So, how to run this var file? Now I am going to explain. Place this hello world dot var file in our default tomcat's default root folder. So, in our our dump our var file is in our desktop. We need to move this hello world dot var file in tomcat default root folder. Move command is used to move one file to one location to another location. Move hello world dot var lib tomcat 6 web apps. Before that we do not have permission in web apps folder. So, we need pseudo permission. So, now our hello world dot var file is moved to web apps. Let me check. See our hello world dot var file is there. So, now I want to run this hello world dot var file. How to run this? After placing var file we need to restart our web server. How to restart? Pseudo slash ptc init dot d tomcat 6 restart. It is stopping tomcat's server engine and again starting tomcat. So, okay, okay. Now I am going to run hello world. Open your browser type localhost a0 a0. Our tomcat is working fine. Orientation. Orientation works up for orcas coordinators. So, it is hello world dot var file is simply printing orientation works up for orcas coordinators. So, our var file is running perfectly right now. In our address bar I have typed localhost call an a0 a0 slash hello h capital h e l l o capital w o r l d. So, our hello world dot var file is running perfectly. Now I am going to install and configure Apache 2 PHP file and MySQL. Let me close everything. Again start package manager. Now I am going to install Apache 2 type Apache 2 in quick search box. It will show the list Apache 2, Apache 2, 2.2 iPhone common. See this Apache is in green which means that already installed. So, I am not going to install again. If those you did not install please click on this and right click mark for installation. It will install over Apache. Okay. After installing Apache 2 now I am going to check whether our Apache is 2 server working perfectly or not. To do that we need to start our Apache 2 server web server same sudo slash etc init dot d Apache 2. So, it shows ok which means that our HTTP web server Apache 2 is working perfectly. Now I am going to test server working. I mean Apache 2 server working or not. Simply type localhost. See it shows it works button. Previously Tomcat shows it works. But in address bar I simply type localhost only. Nothing else. I did not type any a0 a0 because a0 a0 port is only for Tomcat. And a0 only a0 port is for Apache server. So, we no need to type a0 port. Simply type localhost in your browser. It will show it works page which means that your Apache server is working perfectly. So, how to stop the web server? sudo etc init dot d Apache 2 stop. So, we need to start it is ok which means that it stopped. Check again type localhost in your browser. It is some catchy problem. See now unable to connect which means that in localhost Apache is not running because we already stopped. Now again start Apache 2 server. So, we need to start it. Now type in your browser localhost. So, it shows it works button. Now our Apache 2 is working fine. Now I am going to install PHP 5. PHP is a open source programming language which is a widely used programming language nowadays. So, how to configure this PHP file with this Apache and after that we will look at MySQL. Now I am going to install PHP 5. PHP 5. Simply type PHP 5 in your quick search box. It will display PHP 5. Now I am going to install PHP 5. Right click on that mark for installation. See it will display the dependencies all the dependencies. Look at this live Apache 2 iPhone mode iPhone PHP file. This is very important file. Please make sure that this file going to install. Just mark it and click on apply button. It will download the package from our app and Siri and it will install. You can see most of the websites running developed in PHP. For example this Facebook, Twitter, many social networkings are developed in PHP 5. So, PHP 5 is installed. Now after installing PHP we need to restart our Apache server. Flash, PTC. You need that the Apache to restart. So, our Apache server is running. Now I am going to check PHP file is running or not. Tomcat's default to root folder is CD where live Apache 2. Tomcat seeks and web apps, but our Apache 2's default to folder is where www. This is our Apache 2's default to root folder. If you want to run a PHP application or any other web application, you need to place your project in where www folder. So, this is the PHP. So, this is our Apache 2. Here I am going to write a simple hello world PHP 5. So, row g edit hello dot PHP. PHP dot PHP is very important. Less than symbol question mark PHP. This all the PHP coding should be write in between these two tag. Now I am simply I am going to print hello world like echo. This is a simple program, simple PHP file which is simply print hello world in our browser. Save the file and open your browser. Type local host, slash hello dot PHP. It prints hello world. So, now our Apache 2 is working which interprets PHP 5 file. Now I am going to explain how to install MySQL and how to create a simple table, how to create a user, how to create a database, how to give permission to that user. Let me close everything. Now I am going to install MySQL. Type MySQL iPhone server. MySQL iPhone server. List, right click on that. Mark for installation. It will display all the dependency packages. Just click on mark. After that click on apply. Again it will download from our up and CD and it will install MySQL server. So, while installing it ask for our root password. MySQL root password. Default MySQL have a user called root. We must specify password for that root user because this root user is used for all the configuration. Simply give your own password. It ask for repeat password. You can see details what is installing, what not installing in the state mail window. So, now installation is completed. Close our snapping package manager. Now I am going to test my, whether MySQL server running or not. So, open your terminal. So, before the entering to MySQL terminal, we need to start our MySQL server because we already know while installing Tomcat 6 and Apache 2. After installed we started our web server. Same we need to start MySQL server also. sudo slash eetc, you need that d MySQL and start. So, now our MySQL engine is started. Now I am going to enter into MySQL terminal. In same window type MySQL iphone u which specifies the user's password. User of the MySQL. We already have one root user and we already specified root user password at the time of installation. iphone p which is specified the password. Type MySQL space iphone u, space root, space iphone p. So, it ask for the password of the root user. Now, I entered into the MySQL terminal. Welcome to the MySQL monitor. It displays here. In MySQL terminal you can create your database, you can create user, you can create table, whatever you want. So, now we entered into our MySQL terminal. Now I am going to create database. Simple, create database example test. See this create database test which created a database called test. It shows query ok, one row affected. It means that it is created a test database. So, our the written query is executed perfectly. So, it shows query ok. So, now how do we save our test database is created or not. To list out all the database we have a command called show database. See it will display all the databases in our MySQL. Just now we created this test database. This information underscore schema and this MySQL is default is already there in our MySQL. After installation it already created. So, we do not consider about this. We simply consider this our test database ok. I created test database. I want to create a user. See already we have a root user, but root user is only for minimal purpose. Do not use root user for everything. So, please create a separate user for MySQL. To do that write a command create user single code. For example, aakash create user single code. For example, aakash close the single code at the rate local host. Create user single code aakash at the rate single code local host identified by some password. Identified by some password. For example, aak 1, 2, 3. See create user aakash at the rate local host identified by password. See this is the simple syntax. Create user command which creates the user called aakash at the server which local host means our default server identified by which means that password 1, 2, 3. So, now you should enter. See query ok. Zero was affected. So, now our user aakash created. So, now we created one database. Now and we created one user called aakash. Now I am going to give some permission to that aakash user to database test. How to do that? Grant. Grant command is used to give permission to the user. Grant all on test.star to aakash. See this grant command which is used to give permission to the user. Grant all. All means all the privileges create, delete, update, insert. There are many privileges are there. So, I simply give all the privileges to the user. I mean all on. On means which database we already created test database dot star. Star means all the tables that test database and all the tables star means all the tables inside the test database to the user aakash. Press enter query is ok. Now we granted all the permission to the aakash user on the database test. Now I want to quit MySQL. How to quit? Simple right backward slash and q by. So, it quit MySQL terminal. Now we created one database test. We created one user called aakash. Now I am going to enter to the MySQL terminal with the user nearly created aakash. MySQL iPhone U which specify the user aakash iPhone P 1 2 3. So, now I entered into the MySQL terminal with the aakash user. Now we already granted permission to the test table. Now you can see whether a test table is available to this user or not. So, databases see here test table is available for this user. Now I am going to this we created test database. Now I am going to create table inside the database. So, now we if you want to create a data table we should use the database then we create a table. So, to use the database simply write a command called use test. So, it will it shows database change which means that we entered into the test database. So, here we are going to create table. So, how to create a table? Create table, table name here some attributes, attribute list. This is the simple syntax to create a new table, create table, table name, attribute list. So, now I am going to give some simple example. Create table for example address book here. This create table address book address book is the name of the table. So, how many attributes are there? We will specify the attributes list inside this bracket symbol id int name where care of size tatty address text and mobile number where care. We create table address book bracket id space integer which means that id is an integer value. So, we should specify this id as an integer. So, give id int name is where care tatty where care is an integer where care bracket tatty tatty means is size of the text and address space text we will specify the address in I mean more than 300 character 400 character. So, simply we give text and mobile number we are going to get. So, where care tatty tatty is not a tatty it is simply we are going to get a 12 number plus 91710 digital number. So, press enter. See it is created a table called address book. After created table we will see the descriptions of the table. To see that see address book see the descriptions of the address book table d e s e address book. So, it shows the field names and the type we specified and the this is a nullable or not it is whether it is a primary care or not default is null extra. See id we created id and we created name we created address and we created mobile fields in the address book table. Now, I created address book I want to insert some data in this address book how to insert some data. So, to insert there is an a command insert into address book id name address mobile values in the address book. Id for example, starts from 1 name address room number 21 from for example, Rajas state Tamil Nadu and mobile number. So, please specify plus 91181942. See insert into address book and the field name id name address mobile and the values which what are the values we are going to insert in into that field. See some errors occurs error 1064. This means that we did some mistake in this. What mistake we did? See open single open code is there single open code is there, but I forgot to close here after Tamil Nadu. So, it shows the syntax error. Now close oh here it is a butter sorry I wrongly a butter again I entering into the MySQL terminal. So, databases use test reading table information for completion of the table database change. See I already we did some mistake. So, it shows you can turn off this feature to get quicker start up. So, we do not worry about that. Now database is changed show tables. See we already created address book. So, show tables which gives all the list of available tables inside that databases. We forget inserting this values insert into a table address book id name address and more field name is a mobile values and for example 10 name is a Raj address Raj or state and mobile number something oh here shows again error. You have an error in SQL syntax oh insert into see I added one more this table. So, it shows error. So, now insert into address book in bracket the field name id name address book mobile. There are the field names already there in the address book in that field name we inserted the values called 10 and Raj and Raj state and some some numbers. So, now we entered now we need to check whether already see inserted data is already inserted or not. So, the command use select start from address book see it displays the value we inserted select start from database oh we can select some specific specific data from the tables. For example suppose if you want only the name from the address book table select name from address book. It will display only the name instead of displaying all the fields it will display only the name. So, there are many queries available in my SQL. See this is very basic commands oh search in the internet and you can find more or more commands and you can learn more. So, now we have a database we have a table we have we inserted some data. So, I want to take dump dump of this database and extract in some other machine. For example, you have inserted table and you have inserted data inside that another was one person wants this database. So, you you can take the dump of database and you can give to them how to do that with the my SQL. So, there is one command a my SQL dump this command is usually to take the dump of my SQL database iPhone U which user going to take the database I am going to take dump of this root using this root user iPhone P the database name we already created one database called test. So, I am going to take dump of this test database this greater than symbol this greater than symbol will take the dump and save in here the file name which we are going to specify. For example, test.sql. So, this this command will take the dump of the test database and save in a test.sql sorry my SQL dump. So, command is I think wrongly I typed before I wrongly give some I think mistake now see now my SQL dump iPhone U root iPhone P our database name test and greater than test.sql. So, it will ask for the root password to take the dump. So, you can see the test.sql file here test.sql. So, now you can send this test.sql to some other person to extract in their my SQL. So, now you taken dump how to revert back you have a dump file and how can you insert into the database. See we taken dump using this command my SQL dump iPhone U the user root iPhone P database name greater than symbol and file name.sql now revert back how to this test.sql again back to the database simply write this command my SQL iPhone U root iPhone P test lesser than symbol test.sql. So, it will ask for the root password everything is now this test.sql again enter again inserted into the databases you can enter into my SQL iphone U root fnp you can show the databases test databases here you can quit how to stop the my SQL server how to stop sudo slash etc init dot d my SQL stop. So, it this command will stop the my SQL server my SQL stop my SQL stop right now anybody have queries please ask the question right now again let me explain everything is once again see to install my SQL server type my SQL iphone server in your quick search box and it will display all the files right click on that my SQL iphone server and mock for installation it will install from your cd app and cd after installing my SQL you can start using the terminal to open your terminal application accessories terminal sudo slash etc init dot d my SQL start this command will start our my SQL database after starting my SQL database we can enter into the terminal by issuing this command my SQL iphone U root iphone p it will ask the password of the root user which already we given while the time of at the time of installation now we entered into the my SQL terminal. So, after entering we can create a user using this command called create user single code the user name at the rate single code the server name which means that local host identified by 1 2 3 which means the password 1 2 3 is our password. So, this will create a kosh user for the my SQL now create database test this command will create a database called test this command grant all on test dot star to occurs this command will give all the permission which means that create delete update insert there are many pre-legislation I given grant all pre-legislation to the database name called the test dot star which means that all the tables inside the database to the user called a kosh this command create table address book id space int comma name worker bracket tatty address net text mobile worker 12 this command will create address book with the field called id name address and mobile only four fields this table will create with the four field and this worker tatty which means that it is a size of name size of the name text and address this address and the data type is text this is the mobile field and which has 12 characters d e s c address this d e s c command will show the description we mean this use test see this error use description address which shows error 1046 no database selected which means that we did not select the data we just entered into the MySQL terminal now we entered into the database now we can see address book descriptions see this which has four field id name address book mobile we can create many fields and types there are many types integer flow worker text we can also specify whether this field has nullable or not whether this key is primary key or foreign key there are many things are there you can please find the documentation in MySQL websites and this command MySQL dump if you root if and p test greater than test dot sql this command will take the dump of the test database and which gives names and test dot sql file after taking test dot sql file this this sql file we can we can give to any other persons if you want to again re send to the database this test dot sql this command this less than symbol this is very important MySQL if you root if and p this is the database name and test dot sql this will again extract the tables inside the test database if you have any doubts regarding this you can ask our Moodle and you can ask right now also now I am going to explain Apache 2 installation again open your snap tick package manager after inserting our up and cd type Apache type Apache 2 in quick search box and press enter it will display the list Apache 2 all the list so this is our Apache 2 server right click on that and click mark for installation after clicking mark for installation it will display all the dependencies packages you just click on mark after clicking mark button you click apply button here the play button is here it will install the Apache 2 web server after installing Apache 2 you can start the Apache server by sudo slash etc init dot d Apache to start this command will start Apache server you can test our Apache server whether running or not open your browser and type local host simply local host it will show it works button it works page now our observer is working perfectly the difference between Apache and Tomcat see this Tomcat is developed in Java so it is specifically used for running Java serverlates and JSP pages Tomcat Apache 2 is developed in C languages it is only serves HTTP pages for example this PHP, Python and one more languages Ruby we can run this programming language in Apache 2 but we cannot run PHP and Tomcat Tomcat is developed in Java so Tomcat is specifically designed to run Java serverlates and JSP pages how to use Warfiles I have one example Warfile hello world this Warfile will display a hello world so I am going to I am going to deploy this hello world dot Warfile in Tomcat server see our file is in desktop so I am going to move this hello world dot Warfile in where live Tomcat 6 web apps so please place your hello world dot Warfile in slash where live Tomcat 6 and web apps so you can see CD slash where live Tomcat 6 web as hello world dot Warfile is hello world dot Warfile is in where live Tomcat and web apps after placing hello world dot War we need to restart our Tomcat server so to restart our Tomcat server sudoetc our Tomcat serverlates engine is started now you can see there are one more folder called hello world this is extracted from hello world dot Warfile after restarting our Tomcat server so we can see hello world this in desktop JSP file and meta enough and web I am enough this is enough web applications developed to using net beans now I am going to run this hello world we extracted I mean we placed a hello world dot War and we started we restarted our Tomcat server I am going to run type in your browser local host colon 8080 slash hello world so I just typed hello world only the folder name which is in this folder name hello world after issuing that our Tomcat looks the file called index dot JSP see it automatically runs index pages see please look at this index dot JSP file it simply has printing it is simply printing orientations workshop for Aukash co-ordinators nothing else this is a simple index at JSP file which displays this is orientation workshop for Aukash co-ordinators so you please place your Warfile War folder in Warlib Tomcat 6 web apps place your Warfile here after placing Warfile here please restart our Tomcat server it will automatically extract your project and it will run in browser yeah cut and paste is possible before that we need to see this web apps folder default does not have permission so only we need to give some root permission for that if you want to create a file and place this we given sudo if you do not want that every time I do not want to give this sudo you can change the permission of this folder how to change the permission sudo go to this I will explain sudo change mode if an capital R 777 I given this 777 means all the permission to all the users all the groups slash where the folder live Tomcat and web apps so this will this command will give permission to that web apps folder now you can directly go for example place file system where live Tomcat 6 and web apps so you can see our hello world dot war file our test project this hello world dot war after extracting this hello world so you you can use this GUI to place your Warfile and you can create your test HTML pages jsp pages or you can configure in vmware also see apache Tomcat is already available in our Uptan CD if you want to download you can download from web website and you can directly install the vmware file is in vmware file our root file system slash where slash where is there default root file system where file is here there is no default to user and password for the Tomcat user if you want to manage your Tomcats I will show you enter say localize colon 8080 it shows Tomcat iPhone 6 admin this package install 2 web public that can help managing this Tomcat in so this manager web web app see this this package I did not install because I do not want to manage this Tomcat I do not want a specific user for this manager I mean a specific user for this Tomcats if you want to manage your Tomcat you can install one more application called Tomcat iPhone 6 iPhone user and Tomcat 6 iPhone admin Tomcat 6 iPhone user Tomcat 6 admin you can you can install this administration packages and you can things I think dependency packages is missed here but you can download you can install from your internet and you can manage your Tomcat 6 using this admin Tomcat I Tomcat 6 iPhone admin packages thank you.