- Part 1 LAMP
- Part 2 Upgrade PHP to 7.3
- Part 3 Apache Enable Mod Rewrite
- Part 4 Virtual Hosts
- Part 5 Lets Encrypt
- Part 6 MySQL
- Part 7 Remote MySQL
- Part 8 Composer
- Part 9 Laravel
Digital Ocean has a marketplace for one-click installs, one of which is a LAMP (https://marketplace.digitalocean.com/apps/lamp) stack it installs:
- PHP 7.2
- Apache2
- Mysql 5.7
During setup install with SSH key, more secure than using a password.
After you create a LAMP One-Click Droplet:
* You can view the LAMP instance immediately by visiting the Droplet’s IP address in your browser.
* You can log into the Droplet as root using either the password emailed to you or with an SSH key, if you added one during creation.
* The MySQL root password is in /root/.digitalocean_password.
* The web root is/var/www/html.
* You can get information about the PHP installation by logging into the Droplet and running php -i.
Users
dave = sample username
How To Add a User
If you are signed in as the root user, you can create a new user at any time by typing:
adduser dave
one step required is to create a user password, keep a note of this as it will be required when running certain commands. The other details are optional.
To delete a user:
deluser dave
By default, a new user is only in their own group, which is created at the time of account creation, and shares a name with the user. In order to add the user to a new group, we can use the usermod command:
usermod -aG sudo dave
The -aG option here tells usermod to add the user to the listed groups.
Setup user permissions
Change username with the name of the user, this gives ownership of the var/www directory and its children
sudo chown -R dave:dave /var/www
Login as user
To log in as user under SSH without a password.
while still logged in as root switch to the new user account.
su dave
Create a new directory called .ssh and restrict its permissions with the following commands:
mkdir ~/.ssh
chmod 700 ~/.ssh
Now open a file in .ssh called authorized_keys with VIM
vi ~/.ssh/authorized_keys
Open a new terminal instance to view the public key on your machine:
cat ~/.ssh/id_rsa.pub
Copy the key then go back to your connected terminal.
paste the key and by pressing I to be in write mode then after pasting press esc and :wq to exit.
You will now be able to login to your server as the user.
Type exit to exit from the user back to root.
Type exit again to disconnect from the server.
You can now ssh in as the user:
ssh dave@ip -p22