What Exactly Goes into Application Environment Setup? The Standard Actions for a New Linux Server
2026-10-18 10:16:30
Many owners have been through this scene: a new server arrives, someone is asked to install the OS and a couple of packages, and business is running the same day. It looks like a shortcut, and then over the next year or two strange things keep happening. One day after a reboot the service will not start, and nobody can say what was ever installed on the machine. The database is reachable from the public internet, and weak passwords surviving half a year is pure luck. A certificate expires with nobody noticing, and customers see a page full of red warnings.
None of these is "the software was not installed properly." They are cases of the environment not being set up properly.
With environment setup, the rough version and the careful version look almost identical at delivery time: the business is running either way. The difference only shows on the day something breaks, the day a certificate must be renewed, or the day someone new takes over. This article walks in order through a set of standard actions that we at Moges have repeatedly validated in day-to-day delivery, taking a new server from bare metal to "able to take a hit." It serves both as a checklist for the plant's own technician who wants to do it, and as a ruler for the owner to accept someone else's work.

1. First Be Clear About What This Machine Will Run
When you get a server, do not rush to install the OS. First write down on paper "what will run on this machine."
A typical business server is usually a combination of three kinds of things: the application itself (a web application, an inventory system, a corporate website); the runtime it depends on (a language runtime, a database, a web service entry point); and the auxiliary pieces around them (scheduled tasks, logs, backup jobs).
Listing them serves two purposes. First, it decides what to install and what not to install: the most important principle of environment setup is "install less," because every extra piece of software on the machine is a future source of vulnerabilities and a distraction during troubleshooting. Second, it decides the security boundary: a machine that runs only one internal application and is not exposed to the public internet, and a machine hosting a website plus a database, require completely different firewall and exposure strategies.
Do not keep the list in your head; putting it into a table is more useful. Five columns are enough for a business server plan:
| Column | What to fill in | Who uses it later |
|---|---|---|
| What runs | Application name and purpose | Service list, startup on boot |
| What it depends on | Runtime, database, cache, and so on | Version list, patch tracking |
| Which port it occupies | Port number, public or internal only | Firewall list, reverse proxy configuration |
| Where data lives | Data directory, log directory | Disk partitioning, backup scope |
| How it starts | Manual command, system service, or container orchestration | Startup on boot, reboot drills |
Before the OS is installed, this table is a plan; afterwards, it becomes the skeleton of the delivery document. The port column turns directly into the firewall list, the data directory column determines how disks are partitioned, and the startup column decides how boot autostart is configured. One table carried through to the end is far more reliable than recalling afterwards "how did we set this up at the time."
Once the list is done, answer one more question: if this machine fails, how long can the business afford to be down? That number determines how far the rest of the setup must go. If it is a website where a day of downtime does not matter, the standard process is enough. If it is a production system, backup and recovery plans must be in place from day one; this is part of environment setup, not something to "deal with later."
2. System Layer: What to Do Right After the OS Is Installed
We will not go into OS selection here, but will repeat one conclusion: do not use an old version that is no longer maintained. For new installs, we favor lean distributions: Rocky Linux and AlmaLinux from the RHEL family, and Ubuntu LTS Server from the Debian family, are all mature and reliable choices; where conditions allow, we even use Arch Linux, which is rolling-release and installs as a minimal system by default, naturally fitting the "install on demand" approach.
On installation method, our principle has only ever been one: minimal installation. The simpler the resulting system, the better: keep only what is necessary for the system to run, install nothing else, and add whatever the business needs when it needs it. Ticking "full install" to save trouble amounts to preloading the machine with a pile of packages you will never use in this lifetime, and every one of those extras is a double burden: it occupies disk and memory in normal times, adds attack surface when something goes wrong, and adds a batch of updates to follow when patching. Simplifying the system has another benefit that is often underestimated: with less on the machine, troubleshooting is faster. A service list that fits on one screen makes it obvious which process should be there and which should not; on a machine crammed with clutter, just sorting out "which ones did I install myself" takes half a day.
Installing on demand does not mean installing casually. For every item you install, record two things: why it was installed (which business it serves) and which version it is. These two notes are the raw material for "the environment is the documentation" later on.
Disk partitioning must be done right at the OS installation step. This step matters more than many people think, because changing it afterwards requires downtime and data migration, at much higher cost. A few hard-won rules:
- Separate the system disk from the data disk. If possible, attach two disks: the OS, runtime, and programs on the system disk, and the database and business data on the data disk. When you reinstall the OS, change machines, or expand capacity later, the data disk can simply be detached and remains intact; mix them together, and reinstalling the OS means gambling with your data. - Give /var its own partition. Logs, default database directories, and container images all live under /var. With a separate partition, a log flood at worst fills that partition and will not drag down the root partition; when the root partition is full, the machine can barely even log in normally. - Size for three years from now, not for today. The three fastest-growing things are image attachments, logs, and database backup files. Partition for "enough today," and a year later you will have to cut into it. - Use LVM whenever you can. The value of logical volumes is adding disks and expanding capacity later without downtime, which is especially convenient on virtual machines and cloud hosts. - Size swap according to memory. 16 GB of memory with 4 to 8 GB of swap is insurance that is "unused in normal times, life-saving in a pinch." With no swap at all, when memory fills up processes are killed outright rather than swapped out, and the symptom is services mysteriously disappearing.
Get partitioning right, and the later questions of "where is the data, what do backups cover, and how do we expand" all have clear answers. Get it wrong, and each of those three will require an improvised answer.
Once the OS is installed, the first wave of standard actions goes in order:
Time zone and time sync. Set the time zone to UTC+8 and enable NTP time synchronization. This takes thirty seconds, but skipping it plants mines: log timestamps that do not line up later, certificate validation failing for no apparent reason, scheduled tasks firing at odd hours. Database replication and distributed applications are even more demanding about time.
Repositories and system patches. Update once right after installation. On machines in China, switch repositories to a nearby mirror site; the speed difference is tenfold. After that, keep the rhythm of "apply security updates promptly, and look carefully before touching major version upgrades."
A normal user with sudo. Create an ordinary account for daily use and escalate with sudo when administrative rights are needed; do not use root as your daily account. This is not about style: operating directly as root, one typo is irreversible, whereas sudo at least leaves a buffer requiring confirmation, and every escalated command leaves a trace.
Password policy: machine-generated random passwords, never human-invented ones. Every password on this machine, whether root, sudo accounts, the database, the application admin, or later services, should be generated uniformly by a random password generator, starting at twelve characters, containing at least one character from each of four classes: uppercase letters, lowercase letters, digits, and special characters. A human-invented password, however obscure it feels, follows patterns that are in cracking dictionaries; only machine-generated ones are truly unstructured. Once generated, put them in place immediately: into a password manager or printed into a password envelope, never in chat logs, spreadsheets, or sticky notes. Each machine gets its own passwords; do not reuse them for convenience, because one leak must not drag down all of them. This password discipline is a baseline we at Moges restate with every machine we take over: it looks tedious, but when something goes wrong, it is what keeps the damage confined to one machine.
Hostname and description. Give the machine a recognizable hostname, and take a moment to write in a description file what this machine is for. Once there are many machines, guessing "which one is this and what does it run" is a disaster.
Do a subtraction self-check after installation. Even after a minimal install, a batch of unused services still runs by default (printing, Bluetooth, a local mail transfer agent, and the like). After installation, list the services currently running and stop and disable the ones unrelated to the business. The criterion is one sentence: if this service stopped, would the business be affected? If not, turn it off. Ten minutes of work buys a shorter service list and a smaller attack surface, and the shorter the list, the faster the next troubleshooting session goes.
Confirm a few basic parameters while you are at it. Defaults for things like the file handle limit are "sufficient but not ideal": as soon as business concurrency rises, the service reports "too many open files," a restart helps for a while, and then it recurs. Confirming this at both the system level and the runtime user level during environment setup saves trouble compared with digging through configuration when it breaks. As for kernel network parameters and memory reclaim policies, deep tuning is unnecessary when volume is small; they are easy to change and hard to change back.
One more point deserves separate mention: do not install a graphical interface on a server. A desktop environment easily adds hundreds of packages, consumes memory, runs resident processes, and expands the vulnerability surface, while what server administration actually needs (command line, file transfer, remote execution) is fully covered by a single SSH channel. Choose the minimal install without any desktop and manage everything from a terminal. In the rare cases where the business genuinely requires graphical services (some specific software only offers a graphical configuration interface), install only a lightweight desktop such as XFCE4 to get by, and never a full GNOME or KDE, which amounts to mistakenly moving an office PC's configuration onto a server.
3. Security Baseline: The Part That Cannot Be Skipped in Environment Setup
Once the system layer is clean, comes the security baseline. Detailed hardening was covered separately in Linux Server Security Hardening and Incident Response; here we mention only the four things that must be done during environment setup:
Close down SSH. The real gate consists of two things: disable root password login and switch to keys, then install an anti-brute-force tool (such as fail2ban) that automatically blocks repeated failures. On machines exposed to the public internet, SSH ports are scanned an unimaginable number of times every day, and a weak password with password login is like leaving the door key under the mat. As for "moving the port away from the default 22," it is basically useless: in incident response we have seen machines whose port was changed long ago still get scanned. Modern port scanners can sweep all 65535 ports in seconds, so hiding a port does not hide anything; at best it reduces scan noise in the logs. Do not rest your security on it.
Start the firewall from "all closed" and open as needed. This is a hard rule: a new machine's firewall defaults to all ports closed, not a single one open, and then you open the port the business needs, rather than the reverse of "open everything by default and block one by one." Get the direction backwards, and closing holes will never catch up with the exposure. Every time you open a port, record three things in the port list: which port, which service it serves, and whether the source can be restricted. Apply the principle of least exposure to open ports: do not open what can be left closed; never expose services meant only for the local machine; open services meant only for the intranet to the intranet segment only, and restrict by source IP wherever possible instead of allowing everyone. One point deserves special emphasis: database ports must never be open to the public internet. In many database breach cases, the database was not "hacked" at all; its port was simply exposed directly to the internet, with a weak password on top.
Logs must be retained and searchable. Confirm that both system logs and service logs are being written to disk properly, and configure rotation (logrotate) so that a single log file does not fill the disk. Logs are the only thing that can reconstruct what happened after an incident.
Separate accounts; do not use one account to pass through everything. An environment should have at least three layers of accounts: system layer (a normal user with sudo), database layer (a business-specific account with minimal privileges), and application layer (administrator separated from operator). Using one all-powerful account across all three layers is the least trouble and the least able to withstand an incident: if an operator is phished and loses the password, the application, database, and system are all handed over at once. The cost of separating accounts is remembering a few more passwords, and that is exactly solved by the previous point: passwords go to the generator, and people are not responsible for remembering them. One more note: disable accounts that should be disabled, and do not keep zombie accounts "for convenience later"; accounts left by departing staff, replacements, or temporary contractors are the first thing named in an audit.
Leave traces that can be checked. Environment setup does not require a full audit system, but two things are mandatory: command history with timestamps (otherwise, looking back later gives you commands without times, which is the same as nothing), and logs for sudo operations. When something really goes wrong, "who touched what and when" is the only thing that can reconstruct the process.
Harden at installation time, not "get it running first and add security later." Many environments are "put into use first, secure later," and that "later" usually never comes. Hardening does not have to be complete in one pass, but the items above are the baseline and belong to the workload of the day the environment is built.
4. Runtime Environment: Install from the List, Not Casually
When it comes to installing the application runtime, the core discipline is still the list: install PHP if PHP is needed, install a database if a database is needed, and record the version number for every item on the list. When troubleshooting "a new version was installed and now it will not run" in the future, this version list saves half the time.
A few practical points:
Define the directory convention first, then put things inside. We recommend a fixed structure: the application in its own directory under /opt, containing a few fixed items: orchestration files, environment variable files, a data directory, a backup directory, and an operations script directory. Neatness is only a side benefit; what really pays off is three things: the backup script knows which directories to back up, migration knows what to copy, and whoever takes over half a year later can open the directory and see where things are. Conversely, unpacking an archive wherever it happens to land, throwing files into the home directory, and mixing backups with data are the source of all later chaos.
One unified entry point for web services. Use something like Nginx as a unified entry point, hang different applications behind different ports or paths, and configure certificates centrally there. The practice of letting every service run naked on its own port will sooner or later become a mess.
The first thing after installing a database is to close it down. Change the default or empty password; listen only on the local machine or intranet address, never on the public internet; grant business accounts least privilege, and do not give a query-only account permission to drop tables. With these steps done, the basics at the database level are stable.
For the runtime environment, we strongly recommend packaging with Docker, especially Docker Compose. The return on this is too high: one compose file spells out the application, dependencies, ports, data volumes, and environment variables, and starting the service is one command; migrating to another machine is essentially "copy the compose file and data volumes, then bring it up on the new machine"; upgrading, rolling back, and rebuilding the environment are all minute-level, repeatable actions. Even better, "the environment is the documentation" happens automatically in compose: the file itself is the complete answer to what this machine runs, with no separate write-up needed. A few rules of use: pin image versions to specific tags and do not use latest (otherwise the environment rebuilt half a year later is no longer the original one); always keep data on host volumes or directories so containers can be thrown away at any time while data is never buried with them; and treat compose files like ordinary configuration, included in backups and delivery documents. The only warning is not to mix approaches: once you decide to use containers, do not scatter another set of services on the host machine; with two systems mixed on one machine, in the end nobody can say who manages what.
The environment is the documentation. Write the installation steps as a script or at least as notes. The second time you build an identical machine (migration, disaster recovery, and expansion all need it), you will thank yourself for this document. If the actions are not captured, the environment exists only on this one machine, and if it breaks, it is truly broken.
Plan ports and access paths together. By the third application on one machine, ports almost inevitably collide. Before installing, write port allocation into the planning table from the beginning: who occupies which port, public or intranet only, and whether it goes through a reverse proxy. The recommended structure exposes only 80 and 443 to the outside and keeps everything else on the intranet or local machine: certificates are configured in one place, protection is done in one place, and adding an application just adds a forwarding rule instead of opening a new port. Conversely, if every application opens its own public port, the port list grows longer and longer and firewall rules become harder and harder to explain.
The deployment order for one typical application. Take "one web application with one database" as an example. Installing in dependency order is much less trouble than doing things as they occur to you: system and network (time zone, repositories, hostname), then mounting the data disk and creating directories, then the database (create the database, a dedicated account, confirm it listens only locally), then the application runtime (pin versions), then the application itself (run it manually first), then the reverse proxy and certificate (the external step last), then boot autostart and reboot verification. Behind the order is a simple logic: install what is depended on first, and open external access last. Follow it, and if any step breaks, the scope of troubleshooting is always the layer just touched; scramble the order, and you cannot even tell which layer the problem is in.
5. Domains, Certificates, and Pre-Launch Checks
For machines with web business, domains and certificates are part of the environment and must follow the rules:
Choose free or paid certificates as needed; what matters is automatic renewal plus result notification. HTTPS certificates can be obtained free with acme-series tools (such as certbot) or bought commercially. Free or paid, choose according to business needs; that is not the point. The point is not to apply manually and then "deal with expiry later": configure the automatic renewal script at deployment time, and have the script email the result of every run to a designated mailbox, so whether renewal succeeded and when it happened is visible in email. The value of this email notification is eliminating silent failure: a renewal script that quietly breaks for three months goes unnoticed without notifications, until the certificate expires and the business cannot be opened; with result emails, someone sees the first failure the same day. After configuring, trigger it manually once to verify that both the flow and the email really work. Business downtime caused by an expired certificate is the most unjust kind of operations incident, purely a process problem.
Go through the pre-launch checklist. Finishing the environment does not mean it is ready to go live; verify it from an external perspective: scan the open ports from the public internet and compare with the list. Are all services configured to start on boot? Are logs rotating properly? Have the scheduled tasks been reviewed? The most important item: reboot the machine once. An environment that comes back after a reboot is a real environment. Plenty of machines that have "run for two years" have a pile of services that will not start after a reboot, because some hand-edited configuration was never persisted or some service was never set to autostart. A reboot drill before launch costs the least.
This checklist comes from the delivery acceptance sheet of our Moges environment setup projects. We suggest printing it out and ticking each item, rather than going from memory:
| Check item | Pass criteria |
|---|---|
| Port exposure | The public scan result matches the port list exactly, with no extra port |
| Boot autostart | All business services set to autostart and recover automatically after reboot |
| Full reboot | The whole machine reboots once; business is available, logs are normal, and no error flood appears |
| Data on disk | Database and business data on the data disk, intact after reboot |
| Time sync | System time is accurate and the sync service is running normally |
| Certificate | Automatic renewal configured, manually triggered and verified, and result emails are received |
| Backup | The backup job has succeeded at least once and the recovery steps have been verified |
| Alerting | Minimum alerting for disk usage and key processes, and alerts genuinely reach a person |
| Documentation | A one-page environment description is written, with the port list and password storage location complete |
The value of this table is replacing "I think it is set up" with "I verified each item." What a self-built environment most lacks is exactly this external perspective: because the builder knows the intent of every step, he unconsciously skips the items that are "obviously fine," and incidents tend to hide in the obvious.
Minimum monitoring and alerting. No monitoring platform is required, but three things need minimum watch: disk usage, memory usage, and key process liveness. Even a simple scheduled script that sends a notification to a person when disk exceeds 80% or a key process is gone is enough. A full disk dragging down the database and a process silently dying unnoticed are, in hindsight, the two most "unworthy" kinds of incidents: the threshold for detecting them is low, provided someone gets called.
Build the backup plan together with the environment. This step is often filed under "optimize later," but it is actually the closing part of environment setup: on the day the environment is ready, the backup job, backup destination, and recovery steps should be in place together. How to build a backup system was covered separately in How Should Server Backups Really Be Done? How Far Is It from "Backed Up" to "Restorable"; just configure it accordingly.
6. Delivery and Handover: Making the Machine "Takeover-Ready"
The last step of environment setup is often skipped, yet it determines whether the environment is a real asset or a black box: deliver a one-page environment description.
The content is not complicated: which services run on this machine and at what versions, where the configuration files are; the root, database, and application admin passwords are machine-generated random passwords of at least twelve characters, stored together in one place (a password envelope or password manager, not chat logs); how to restart services and which log to check for common problems; which ports the firewall has open, what each serves, and why. When something goes wrong at midnight, whoever takes over can work from this one page instead of starting with "first figure out what is on this machine."
By the way, one criterion: a server whose "what is on it" cannot be explained is a risk exposure, no matter how important the business it runs. The environment description is not a document for outsiders; it is a way out you leave for yourself, because half a year later even the person who built the environment has forgotten the details, and this page is the only reliable memory.
When we hand over a machine, we hand over four things, not a sentence saying "it is installed." First, that page of environment description. Second, the storage location of the passwords (where the envelope is, who has access to the password manager), note the location, not the passwords themselves. Third, orchestration files or installation scripts, anything that can rebuild the environment. Fourth, the port list and change records. With these four in hand, anyone can take over and work; with only "it is installed," the first thing the new person must do is start from zero.
One more easily overlooked item: keep a change log. It does not need to be complex; a text file is enough: what day, what was changed, why, and what it looked like before. When the environment has a problem, ninety percent of the time it relates to a recent change; with this record, troubleshooting shifts from "search every configuration file" to "first look at what was changed last." Likewise, copying the original to a dated backup before changing any configuration is the lowest-cost regret medicine.
7. Three Common Scenarios with Completely Different Priorities
The same set of standard actions lands differently on different machines. Here are the three most common types in a plant:
| Scenario | Typical configuration | Setup priorities | What can be deferred |
|---|---|---|---|
| Small intranet tool | One machine, one application, one database, intranet access only | Data on disk, backup, reboot verification | Certificate can wait (start with HTTP on the intranet); external protection can be simplified |
| Corporate website or content site | One machine, web entry point plus database, open to the public internet | Automatic certificate renewal, minimal ports, anti-brute-force, static asset caching | The database only needs to listen locally; no external access needed |
| Intranet production system | One or two machines, business cannot stop | Backup and recovery drills, monitoring and alerting, a rapid rebuild plan | Skip every fancy performance optimization |
The criterion for all three lines is still the same question: if this machine is down for a day, how big is the loss? If a small intranet tool is down for a day, people complain and move on; if a production system is down for a day, a batch of goods may not ship and a customer may be lost. Different setup depth means money should not be spent in the same place: giving a small intranet tool dual-machine hot standby is waste, while leaving a production-line system with only "call me if there is a problem" is gambling.
8. A Few Problems That Commonly Appear in the First Month
The following are not theoretical exercises but the most common issues in the first month after environment setup on machines we have taken over. Knowing them in advance saves many late nights reading logs:
Services do not start after a reboot. Eighty percent of the time it is one of two cases: the service was never set to start on boot (it was started by typing a command by hand), or the configuration change was not persisted and the old configuration is loaded on reboot. That is why you must actually reboot before delivery; "I saw it running fine" never replaces a reboot.
The disk mysteriously fills up. The sources are usually three: logs without rotation, database backup files piling up on the same disk, and container images and old layers not cleaned up. First sort directories by size to see what is growing, and do not rush to delete files; confirm what a file is for before deleting, because deleting the wrong one is more trouble than a full disk.
The time is wrong. Symptoms are scrambled log timestamps, certificate validation failures, and scheduled tasks firing at bizarre moments. Most often the time zone was not set or the time sync service is not running, and it takes two minutes to fix; but if discovered late, the causal order in the logs is scrambled, and even "what happened first" cannot be reconstructed when an incident occurs.
Port conflict; the new service will not start. Almost inevitable by the third application on a machine. If ports were recorded in the planning table, there will be no collision; if there is one, first check who is occupying the port, and do not just change the new service's port, because the change may no longer match the forwarding rule in the reverse proxy, and the symptom becomes "the service is running but the page will not open."
Certificate renewal fails silently. The renewal script runs every day, but nobody knows when it fails, until one day the page reports an expired certificate. This is the entire reason for requiring "email the renewal result": turn "did it renew or not" into a line you can see every day, rather than learning about it from a customer on the day it expires.
9. A Few Common Setup Mistakes
Sorted by how often they are stepped into:
Mistake one: running business processes directly as root. A typo has no buffer, and a compromised process gains the highest privileges. Create a normal user and least privilege; it takes ten minutes.
Mistake two: opening the database port to the public internet. Mentioned above, not repeated here; this is a fatal one.
Mistake three: applying for certificates manually and never touching them again. Renewal must be automated and verified at least once.
Mistake four: cramming everything onto one machine with no isolation. Small company, tight budget, running several applications on one machine is understandable, but at least separate the privilege boundaries of the web entry point, applications, and database, so that one compromised application does not mean the whole family falls.
Mistake five: not recording versions and steps after installation. The environment exists only on that machine and in that person's head; when the machine breaks or the person leaves, everything starts over.
Mistake six: thinking about backups only after the environment is done, or not at all. Backup is a component of the environment, not a value-added service.
Mistake seven: changing too much at once. Adjust the environment one thing at a time, record the current state before changing, and be able to roll back if it breaks. "Changed five places at once and do not know which one broke it" is the most expensive unsolved case in troubleshooting.
Mistake eight: installing a desktop to save trouble. Thinking a graphical interface is easier to manage actually moves the burden of an office PC onto the server: hundreds more packages, a larger vulnerability surface, a batch of updates to follow, and no improvement in management efficiency, because command-line work on a server is always faster and more precise. Keeping a lean, desktop-free system is the truly effortless route.
Mistake nine: mixing data and system in one place. A single unpartitioned disk is the least trouble, at the cost that when the system needs reinstalling, the data is gambled along with it. At least separate /var, and add a data disk if possible; the cost is almost zero, yet it may save all your business data.
Mistake ten: editing live configuration directly without a way back. Copy the original to a dated file before changing, so it can be swapped back immediately if the change is wrong: a thirty-second action that saves a whole evening of agonizing over "which version should we roll back to." Editing live without a backup makes every adjustment irreversible.
10. The Complete Order from Bare Metal to Delivery (Checklist Version)
Stringing the actions from the previous sections together in order gives a machine setup checklist that can be followed directly:
1. Planning: list the applications, dependencies, and auxiliary pieces this machine will run, and turn it into a five-column plan (what runs, what it depends on, which port it occupies, where data lives, how it starts); clarify "how long downtime is acceptable," which determines the depth of backup and recovery configuration. 2. System: choose a lean distribution (Rocky/Alma from the RHEL family, Ubuntu Server from the Debian family, Arch if conditions allow), install minimally without a desktop; partition by data disk and /var with ample headroom; after installation change the time zone, enable time sync, switch to a nearby repository, update once, and do a subtraction self-check. 3. Accounts: create a normal user with sudo; generate all passwords with a generator, at least twelve characters with four character classes, store them in a password envelope, and do not reuse across machines; separate the three layers of system, database, and application accounts, and leave no zombie accounts. 4. Security baseline: SSH key login with root password disabled and anti-brute-force installed (changing the port only reduces noise and is not a defense); the firewall starts fully closed, opens on demand and minimally, and records every port; confirm logs are on disk with rotation; command history has timestamps and sudo is logged. 5. Runtime: define the directory convention (orchestration files, environment variables, data, backups, and scripts each in place); package with Docker Compose (pin versions, keep data on host volumes, include compose in backups); close down the database; unify the web entry point, exposing only 80 and 443 externally. 6. External services: domain resolution, HTTPS certificate (free or paid as needed), automatic renewal script configured with result emails, manually triggered and verified once. 7. Pre-launch checks: public port scan against the list, all boot autostart configured, scheduled tasks reviewed, minimum alerting for disk, memory, and processes, and one full reboot verified. 8. Backups in place: backup jobs, destinations, and recovery steps delivered together with the environment on the same day, leaving no "later." 9. Delivery: write the one-page environment description: service list, versions, configuration locations, password storage, port list, and restart method.
Only after these nine steps is the machine truly moved from "able to run" to "able to take a hit." Every extra ten minutes spent at each step is an hour saved on some late night in the future.
11. Handing It to a Professional Also Comes with a One-Page Acceptance Sheet
Environment setup is work you can do yourself; following the order in this article, an ordinary business server can be put in order in a day or two. But if the machine runs a production system that cannot stop, or if nobody in the plant is willing to touch the command line, hiring a professional to set up the environment once and leave the documentation behind is a worthwhile deal. Environment setup is typically a one-off short-term project: set up today, documentation delivered, accepted on the spot, and from then on how the machine is maintained is your own business.
When to bring in an outsider is actually judged by three points: downtime costs real money; only one person in the plant knows how to handle it, and that person also wants to take a vacation; the existing environment is so messy that nobody can say what is on it, and rebuilding is cheaper than fixing. If one of the three applies, it is worth considering; if two apply, there is basically no need to hesitate.
At Moges, we do Linux services, and the deliverables of an environment setup project usually include: a runtime installed according to the list, a closed-down security baseline, certificates that renew automatically, backup jobs in place with the environment, and most importantly, a one-page environment description. Acceptance is equally simple: reboot once on the spot, run a backup recovery drill on the spot, and check the list against the documentation on the spot. Only when all three pass is the environment truly delivered.
A machine is ultimately there to run the business, but whether the business runs steadily is half decided in those two days of environment setup. When a new server arrives, do not stop at installing a piece of software; complete the standard actions that should be done, and the probability of every late-night alert in the future will be much lower.
Turning a bare machine into an environment that "can take a hit" comes down to nine steps: be clear about what will run, keep the system minimal and the foundation solid, give passwords to the generator, start the security baseline fully closed, install the runtime from the list, manage certificate renewal, run a reboot drill before launch, put backups in place with the environment, and leave a one-page document at delivery. None of the steps is hard; what is hard is doing every one of them and leaving a trace for everything.
A server does not automatically become secure because the business is running, and an environment does not become orderly on its own over time. The leaner the system, the more machine-generated the passwords, and the fewer ports open, the fewer late-night alerts there will be in the future. Doing it to standard the first time is the lowest-cost moment.
To fill in the surrounding knowledge: for why production systems deserve to run on Linux, see Why Systems Should Run on Linux from Day One; for how to bring a production line back up in minutes after a midnight crash, see How to Bring a Production Line System Back Up in Minutes After a Midnight Crash; for how to harden the security layer above the environment, see Linux Server Security Hardening and Incident Response; for how to configure insurance for the environment, see How Should Server Backups Really Be Done? How Far Is It from "Backed Up" to "Restorable". For the service scope of one-off short-term projects such as application environment setup, see Moges Linux Server Services.
>