// 
//     Licensed to the Apache Software Foundation (ASF) under one
//     or more contributor license agreements.  See the NOTICE file
//     distributed with this work for additional information
//     regarding copyright ownership.  The ASF licenses this file
//     to you under the Apache License, Version 2.0 (the
//     "License"); you may not use this file except in compliance
//     with the License.  You may obtain a copy of the License at
// 
//       http://www.apache.org/licenses/LICENSE-2.0
// 
//     Unless required by applicable law or agreed to in writing,
//     software distributed under the License is distributed on an
//     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
//     KIND, either express or implied.  See the License for the
//     specific language governing permissions and limitations
//     under the License.
//

= Lesson 9: Deploying the Application on a Remote Web Server
:jbake-type: tutorial
:jbake-tags: tutorials 
:jbake-status: published
:icons: font
:syntax: true
:source-highlighter: pygments
:toc: left
:toc-title:
:description: Lesson 9: Deploying the Application on a Remote Web Server - Apache NetBeans
:keywords: Apache NetBeans, Tutorials, Lesson 9: Deploying the Application on a Remote Web Server

Normally, a real-life PHP application is run on a remote server and is accessed through a File Transfer Protocol (FTP). To deploy your CRUD application on a remote server, you will need to register an account on a hosting provider, register an FTP account, and create a remote database.

You can use any hosting you like. The current document describes the deployment procedure on the X10HOSTING free hosting. This hosting includes a MySQL but not an Oracle database server.

All the user names, passwords, and email addresses are fake and used as examples only. The administration of the hosting blocks an account if the user does not show up on the forum fore more than a week. So you may fail to apply exactly the same user names, passwords, email addresses, and other credentials from the tutorial.

In this lesson you learn how to do the following:

* <<registerHostingAccount,Register a hosting account >>
* <<improveTableEmptyCells,Register an FTP account >>
* <<designStyles,Create a remote MySQL database >>
* <<divs,Set up your project to use the registered remote web hosting >>
* Change your database connection settings to use the remote database

The current document is a part of the Creating a CRUD Application in the NetBeans IDE for PHP tutorial.

== Application Source Code from the Previous Lesson

MySQL users: Click link:https://netbeans.org/files/documents/4/1934/lesson8.zip[+ here+] to download the source code that reflects the project state after the previous lesson is completed.


== Registering an Email Account

Create an email account, if you have not created it before. In this example the email address is phpuser65@googlemail.com.


== Registering a Hosting Account

To create a hosting account on the link:http://x10hosting.com/[+X10HOSTING+] free hosting, follow the steps in their wizard, entering the following settings. You will enter similar information on any other hosting site.

|===
|Account Setting  |Value 

|Email Address |phpuser65@gmail.com 

|Domain name |link:http://x10hosting.com/[+x10Hosting.com+] 

|Subdomain |phpuser 

|Hosting Account Username (also for login to cPanel) |phpuser 

|Hosting Account Password (also for login to cPanel) |qwerty1234 

|Forum Username |phpuser 

|Forum Password |qwerty 

|FTP Account name |uploader 

|FTP User Name |uploader@phpuser.x10hosting.com 

|FTP Server |ftp.phpuser.x10hosting.com 

|Remote Database Host Name |phpuser 

|Remote Database |wishlist 

|Remote Database Username |phpuser 

|Remote Database User Password |phpuserpw 
|===


== Registering an FTP Account

Now that you have a hosting account, you need an FTP account where you will transfer your PHP source and other related files for executing them on the server. For x10Hosting, you opent the cPanel and select New FTP Account, then follow their wizard.


== Creating a Remote Database

Because the CRUD application uses a database you will also need to deploy the  ``wishlist``  MySQL database on the remote server where you have a <<registerHostingAccount,hosting account.>>


== Setting Up a PHP Project with Existing Sources and Remote Web Site Run Configuration

* <<previousLessonSourceCode,Download the source files>> that correspond to the state of the application after the previous lesson is completed. Extract the files.
* Save the source files in the  ``htdocs``  folder.
* Create a link:project-setup.html#importSources[+PHP project with existing sources+]:
** Specify the location of the downloaded sources in the Source folder
** Choose the link:project-setup.html#remiteWebSite[+Remote Web Site+] run configuration and configure the FTP connection
* Complete the project creation.


== Updating the Class WishDB

So far you have developed and run the Wish List application on the local web server and used a local MySQL or Oracle database server. To make your application work with the remote MySQL database, you need to update the connection settings specified through the variables of the class  ``WishDB`` .

1. Open the file  ``db.php`` .
2. Change the variables of the class  ``WishDB`` :

[source,php]
----
var $user = "<the name of the remote database user>";        
var $pass = "<the password of the remote database user>";
var $dbName = "<the name of the remote database>";
var $dbHost = "<the account username specified during the hosting account creation>";
----

In this example the variables will be updated as follows:

[source,php]
----
var $user = "phpuser";        
var $pass = "phpuserpw";
var $dbName = "wishlist";
var $dbHost = "phpuser";
----


== Next Steps

- link:wish-list-lesson8.html[+<< Previous lesson+]
- link:wish-list-tutorial-main-page.html[+Back to the Tutorial main page+]

