Privex
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # The Privex Debian WebBox™ ## Fully functioning web server + PHP ready out of the box <a href="https://cdn.privex.io/privex.io/img/privex-php-test-page.png" target="_BLANK"><img src="https://cdn.privex.io/privex.io/img/privex-php-test-page.png" width="100%" /></a> When you first get your Privex WebBox™, you can browse to it's IP address in your browser with standard HTTP. For example if your server's IP is `185.130.44.10`, you would type `http://185.130.44.10` into your browser's URL bar. If you have an IPv6-only VPS, you'll need to put the IPv6 address in square brackets, for example if your VPS's IPv6 address is `2a07:e00::abc`, you would type into your browser's URL bar: `http://[2a07:e00::abc]` **NOTE:** To be able to connect to an IPv6 address such as `2a07:e00::abc`, your **internet provider must support IPv6**, or you must be **using a VPN** <a href="https://www.azirevpn.com" target="_BLANK">such as AzireVPN</a> which supports IPv6 to be able to connect to an IPv6 address. You can use <a href="https://myip.privex.io" target="_BLANK">Privex's What Is My IPv4 / v6 address service</a> to check if you have working IPv6 or not. You'll be greeted by our custom PHP test page (pictured above), which is a very simple HTML + PHP page that runs a small amount of PHP code to obtain **your IP address that you're connecting to the page from**, the **version of PHP** which is running on the server, and the **folder where the PHP test page script** is contained. This test page confirms both that the web server (Caddy) is running correctly on your server, and that it's properly configured to work with standard PHP scripts. ## What's included - Caddy web server pre-configured for use with PHP + automatic SSL (enabled by default) - Nginx preconfigured for use with PHP (disabled by default, you can easily switch from caddy to nginx if you prefer) - MySQL database server + client (server is disabled by default as it consumes a lot of RAM, and might not be needed) - PostgreSQL database server + client (again, server disabled by default to avoid unnecessary default RAM usage) - Certbot (letsencrypt) for getting SSL certificates when using nginx - PHP 7.3, with `php7.3-fpm` and `php7.3-cli` - ready to use - NVM (Node Version Manager) installed into 'debian' + 'root' with NodeJS v12.17 LTS ready to go - Python 3.7.3 with some packages to kickstart deploying apps: - `Django` Web Framework - `Flask` Web Micro-framework - `SQLAlchemy` + `Flask-SQLAlchemy` (common database ORM used with Flask and small python apps) - `Psycopg2` (PostgreSQL Python Library) - `mysqlclient` (MySQL Python Library) - `beem` - for the hive/steem audience, the main python library for hive/steem - `redis` - the official python Redis library - `privex-helpers` + various extra packages related to it - useful "kitchen sink" Python library - Various other random useful things # Setting up a website on your new Privex WebBox™ <!-- <a href="" target="_BLANK"> --> ## How to transfer files to/from your WebBox™, and managing files (SFTP clients) ### Graphical User Interface (GUI) SFTP Clients There are a variety of easy to use SFTP clients (Secure FTP, not to be confused with FTPS which is different), any of the clients listed below will work just fine for managing files on your new WebBox™ - the only real difference between each of them are in the different extra (not important) features they each have, the platforms they support, and their user interfaces. Pick whichever one you prefer - if you're not sure, **FileZilla** is one of the oldest and most well known clients, so there's plenty of guides on the internet on how to use it, troubleshooting issues, etc. - (OSX / WINDOWS) **Cyberduck** <a href="https://cyberduck.io/" target="_BLANK">https://cyberduck.io/</a> - (WINDOWS ONLY) **WinSCP** <a href="https://winscp.net/eng/index.php" target="_BLANK">https://winscp.net/eng/index.php</a> - (WINDOWS/OSX/LINUX) **Filezilla** <a href="https://filezilla-project.org" target="_BLANK">https://filezilla-project.org/</a> ### Connecting to SFTP using FileZilla and navigating to the default website folder <center> <a href="https://cdn.privex.io/privex.io/img/privex-filezilla-connect-sftp.png" target="_BLANK"> <img src="https://cdn.privex.io/privex.io/img/privex-filezilla-connect-sftp.png" width="50%" /> </a> </center> With <a href="https://filezilla-project.org" target="_BLANK">**FileZilla**</a> open, enter into the **Host** box `sftp://`, then, if your VPS has an IPv4 address, you can enter that normally, like so: `sftp://185.130.44.10` If your VPS is IPv6-only, you'll need to surround the IPv6 address with square brackets `[ ]` like so: `sftp://[2a07:e00::abc]` Enter the username for your VPS into the **Username** box (by default the username for our WebBox™ VPS's is `debian`) Now enter the password for your VPS into the **Password** box. If you haven't yet changed your VPS password, then your password should be the one which was emailed to you with the rest of your server details. You can leave the port blank, then press **Quickconnect**. You should now be connected to your server, and should see that you're in the `/home/debian` folder. <center> <a href="https://cdn.privex.io/privex.io/img/privex-filezilla-browse-www.png" target="_BLANK"> <img src="https://cdn.privex.io/privex.io/img/privex-filezilla-browse-www.png" width="50%" /> </a> </center> Now that you're connected, you'll want to navigate to the folder `/var/www/mainsite`, which is the default folder for the main website. You can do this either by navigating with the mouse through the visual folder tree on the right, or simply entering `/var/www/mainsite` into the `Remote Site` text box and pressing enter. You should see `index.php` and `style.css` (there may be additional files if our template has been updated since this article was last updated). You can delete those two files if you want, or open them up and edit them if you want to use our minimalistic layout for your website :) - it's completely fine to use our PHP test page layout as a base for your own web page, as long as there are no claims on your modified page that we're in anyway responsible for whatever content is on your website. If you want to give us credit however, you can do that, for example `The layout / design of this website was based on an example web page made by Privex.io who we are not affiliated with.` You can use the left panes of FileZilla to browse your local PC and locate the files that you'd like to upload to the web server. Once you've found the file(s) you'd like to upload, simply drag them with your mouse from the left browser pane into the right browser pane (the one with index.php and style.css). You can also right click on the files on the local browser pane and click "Upload". ## Using a domain that you own with your WebBox™ Server ### Point your domain at the server First, log into your domain registrar (or if you use an "anti-DDoS" / "web firewall" service like Cloudflare, log into that). Find the page for managing your domain's DNS records. Create a new record. If you want to point your base domain, e.g. `example.com` at your server, on most registrars you'll need to enter `@` into the **Name** or **Subdomain** field. This varies by domain registrar, so please contact your registrar for more guidance on how to use their specific system. If your VPS has an IPv4 address, create a new record with the type `A` and in the "content" or "value", enter your VPS's IPv4 address (looks like `185.130.44.10`). Save the record. If your VPS has an IPv6 address, create a new record with the type `AAAA` and in the "content" or "value", enter your VPS's IPv6 address (looks like `2a07:e00::abc`). Save the record. **NOTE:** If you have a Swedish WebBox™ which has an IPv4 address, it very likely has an IPv6 address too. If you have both IPv4 and IPv6, then you should add both an `A` and `AAAA` record. ### Test that your domain works correctly **NOTE:** It may take anywhere from 30 seconds to 24 hours for your newly added domain records to work. If your domain doesn't seem to be working, wait 5-10 minutes and try again after that. If it's still not working after 10 minutes, you should contact your domain registrar for clarification on how long it will take, or whether something is wrong. Open up your domain in your browser by typing it into the URL bar, for example if you've pointed the domain `example.com` at your server, type `http://example.com` into your URL bar and hit enter. You should now see the PHP test page, just like when you visit the IP address of your server directly (unless you've edited / replaced the test page with something else). If you get a browser error such as "Server not found", it's usually due to the new domain records not being propagated yet. If your domain still isn't working after about 10 minutes, please contact your domain registrar for assistance. Once you've confirmed your domain is working correctly, you can move on to the next part. ### Add your domain to the Caddy config file Connect to the server via SSH (linux terminal). Enter the following command to open the Caddy config in a simple text editor (nano): ``` sudo nano /etc/caddy/Caddyfile ``` (NOTE: The command is CASE SeNSiTiVe) <a href="https://cdn.privex.io/privex.io/img/caddy2-domain-configs.png" target="_BLANK"> <img src="https://cdn.privex.io/privex.io/img/caddy2-domain-configs.png" width="100%" /> </a> Use your arrow keys to scroll down to the section containing these lines: ``` :80 { # Set this path to your site's directory root * /var/www/mainsite ``` Replace `:80 {` with `yourdomain.com {` - as shown in the above screenshots. Press `CTRL-X` to exit nano, hit `y` to save changes, hit `ENTER` when prompted for the filename (it's already filled out). Now type the command: ``` sudo systemctl restart caddy ``` Wait about 60 seconds before continuing to the next step, to give Caddy time to check your domain and obtain a test SSL certificate. <a href="https://cdn.privex.io/privex.io/img/caddy2-chrome-ssl-error.png" target="_BLANK"> <img src="https://cdn.privex.io/privex.io/img/caddy2-chrome-ssl-error.png" width="100%" /> </a> After you've waited 60 seconds, go to `https://yourdomain.com` (notice the `https` - very important) You should get a warning about the SSL certificate. If you do, then it means that it's working correctly. In most browsers, you can find an option to ignore the warning and continue to the website under "Advanced" or something similar. Go ahead and do that. You should see the PHP test page again (unless you replaced it), showing that SSL is working, as it's properly serving the web page. <a href="https://cdn.privex.io/privex.io/img/caddy2-acme-comment.png" target="_BLANK"> <img src="https://cdn.privex.io/privex.io/img/caddy2-acme-comment.png" width="100%" /> </a> Now that we know the domain was setup correctly, and that Caddy is able to obtain an SSL certificate without any issues, we can change Caddy to use the REAL "ACME server", allowing it to get a normal SSL certificate which browsers won't complain about. Open up the Caddy config again: ``` sudo nano /etc/caddy/Caddyfile ``` Find these lines (see screenshot above), and place a `#` at the start of each of the three lines: ``` { acme_ca https://acme-staging-v02.api.letsencrypt.org/directory } ``` Press `CTRL-X` to exit nano, hit `y` to save changes, hit `ENTER` when prompted for the filename (it's already filled out). Restart Caddy again: ``` sudo systemctl restart caddy ``` As you did earlier, you'll need to wait 60 seconds or so, to give Caddy time to obtain a **real SSL certificate** for your domain. <a href="https://cdn.privex.io/privex.io/img/caddy-chrome-secure.png" target="_BLANK"> <img src="https://cdn.privex.io/privex.io/img/caddy-chrome-secure.png" width="100%" /> </a> Once you've waited 60 seconds, close the previous tab with the "insecure" SSL page open (this is required to make most browsers re-request the SSL certificate). Now, navigate to `https://yourdomain.com` again (remember the `https`), and you should find that your browser no longer complains about SSL issues, you should also see a "lock" icon in your URL bar (usually on the left hand side), indicating that SSL is correctly set up :) **If you've made it this far**, your domain is now correctly pointed at your server, your server is serving PHP-enabled web pages, and your visitors will have a safe and secure connection thanks to fully functional SSL :) Now you can move on to **actually setting up your website or web application**! You're all ready to go :) Phew. # Enabling/disabling/switching between the included services e.g. nginx/caddy/mysql/postgres ## Changing the default server from Caddy to Nginx If you don't feel comfortable with the **Caddy web server**, you can disable it and switch to Nginx, which is also pre-configured to work with PHP out of the box, with our test page. You'll need to connect to your server via SSH, and run these commands: ``` sudo systemctl stop caddy sudo systemctl disable caddy sudo systemctl enable nginx sudo systemclt start nginx ``` You can type the following commands to verify that Caddy has been stopped + disabled, and that Nginx is enabled + running: ``` sudo systemctl status caddy sudo systemctl status nginx ``` If you browse to your server's IP again, you should be greeted with our PHP test page again (or your website, if you replaced the files in `/var/www/mainsite` ## Enabling and starting MySQL (MariaDB) The well known database server **MySQL** is pre-installed on our WebBox™ servers, however it's disabled by default as it consumes a lot of memory. (more specifically, MariaDB - a fork of MySQL which is fully backwards compatible with applications that work with MySQL) It's very easy to enable and start with two simple commands via SSH: ``` sudo systemctl enable mariadb sudo systemctl start mariadb ``` To access the MySQL SQL console so that you can create databases, users, and tables etc., run the following command to connect to MySQL using the default root user with no password: ``` sudo mysql ``` ## Enabling and starting PostgreSQL We also include the other popular database server **PostgreSQL** - it's disabled by default just like MySQL, but is just as easy to enable again. It's very easy to enable and start with two simple commands via SSH: ``` sudo systemctl enable postgresql sudo systemctl start postgresql ``` To access the Postgres SQL account so that you can create databases, users, and tables etc., run the following command to log into the `postgres` Linux user account: ``` sudo su - postgres ``` Once logged into the Postgres account, you can create a postgres database user like so: ``` createuser -SDRl -P someuser ``` To create a database `somedatabase` owned by `someuser`: ``` createdb -O someuser somedatabase ``` To open an SQL console for the database `somedatabase`: ``` psql somedatabase ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully