Hi there,
I’m trying to set up a secure, high performance server for sites that I can configure in a step-by-step manner. Here’s the goal:
I’ve dabbled in server stuff in the past, but it’s not my forte and I’d rather follow the guidance of a pro than risk missing details or deploying something unstable/unsafe.
Thanks in advance!
Best, Phil
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Heya,
Setting up a secure and high-performance DigitalOcean droplet with LEMP (Linux, Nginx, MariaDB, PHP) stack, HSTS, EV SSL certificate, Drupal 8, and additional performance tools can indeed be a great foundation for your websites. I’ll provide you with a step-by-step guide to achieve this. As a precaution, before following these steps, make sure to have backups of your data, as some of the steps may involve making changes to the server.
Let’s get started:
sudo apt update
sudo apt upgrade
adduser your_username
usermod -aG sudo your_username
su - your_username
sudo apt install nginx
sudo apt install mariadb-server
sudo mysql_secure_installation
sudo apt install php-fpm php-mysql php-curl php-gd php-intl php-mbstring php-xml php-xmlrpc php-zip
sudo nano /etc/nginx/sites-available/your_domain
Add the following configuration (replace “your_domain” with your actual domain/subdomain):
server {
listen 80;
server_name your_domain www.your_domain;
root /var/www/your_domain;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
sudo ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
sudo apt install certbot
sudo certbot certonly --nginx -d your_domain -d www.your_domain
sudo nano /etc/nginx/sites-available/your_domain
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains
sudo nginx -t
sudo systemctl restart nginx
cd /tmp
wget https://www.drupal.org/download-latest/tar.gz
tar -xvzf tar.gz
sudo mv /tmp/drupal-*/* /var/www/your_domain/
sudo chown -R www-data: /var/www/your_domain/
sudo mysql -u root -p
CREATE DATABASE drupaldb;
CREATE USER 'drupaluser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL ON drupaldb.* TO 'drupaluser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Complete the Drupal installation by visiting your domain (e.g., http://your_domain) in your browser.
Additional Performance Tools:
To improve performance, you can consider using Redis for caching, Varnish for HTTP acceleration, and enabling gzip compression in Nginx. Each tool requires additional configuration, so you can implement them one by one, depending on your specific needs and requirements.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.