how to upload php application to ubuntu LAMP droplet and connect app with mysql?

I created a preset droplet call ubuntu LAMP.

I can access to this droplet via ssh. And that’s all. I don’t know what to do with the following steps

Where in the droplet should I upload my PHP app to?

How can I config droplet’s mysql so that my app can connect to mysql?

How can I upload my data to droplet’s mysql ?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

The command:

ssh root@

will log you into a terminal on your server it will not upload any data. The easiest way to upload data is via the SFTP protocol as your server already supports this via the SSH server.

How you do this that depends on what OS you are running on your laptop. If you are running Windows then I recommend WinSCP:

If you are using OSX then Cyberduck:

And if you are running Linux locally, you can either use SCP from the command prompt or use your file manager (Files on Gnome or Dolphin on KDE) to upload the files.

This comment has been deleted

This has happened because /var/www is owned by root and you are attempting to create a new directory as a non-root user.

If you have logged into the server via SSH as a non-root user then you will need to log out and log back in again as root and follow the instructions here to create a sudo user:

If you are attempting to create the directory via an SFTP program like WinSCP then you will need to use your root account to log in.

When I try to copy a file from local to www folder I got this error

cp: cannot create directory ‘/var/www/config’: Permission denied

There is no single correct location. You can put it anywhere you like, however, the standard location for a website or web app is under:


If your app is called SuperApp then:


Would be a good location.

Upload your application and set ownerships on your files

upload to where?

Say I connect to server using this command

ssh root@

Then what should I do next to upload ?

In order to get your php app to work you are going to need to follow a number of steps all on your server’s command line.

  1. Upload your application and set ownerships on your files.

  2. Configure Apache to serve your application. See steps 1,2,4,5 from this tutorial:

  3. Create a database.

  4. Import in your existing db into the new database. See the importing section of this tutorial:

After you have created a new database and imported your data you should create a new mysql user and give them access to the db. You need to log into the mysql server and run the following command:

 GRANT ALL ON database.* TO user@localhost IDENTIFIED BY 'password';

Replace “database” with the name of the db you created. Replace “user” with a new username. Replace “password” with a password.

  1. Configure your php app to use the database. Somewhere in you php app there will be a file where the database access information is held. This will require three pieces of information:
  2. Location
  3. User
  4. Password

The location will be localhost and the username and password will be the ones you set in the “GRANT ALL…” command you ran.