Net Config & Utilization.md

Setting Up Your Environment with OneinStack: A Step-by-Step Guide

When it comes to configuring your server environment, OneinStack simplifies the process by offering a lightweight, user-friendly script for deploying LNMP/LAMP stacks. Whether you’re a developer or a sysadmin, OneinStack helps you quickly set up Nginx, Apache, MySQL, PHP, and other essential services. In this guide, we’ll walk you through initializing your environment with OneinStack and provide practical code snippets to get you started.


Why Use OneinStack?

OneinStack is an open-source shell script that automates server configuration. It’s particularly useful for deploying web hosting environments because it:

  • Supports LNMP (Linux, Nginx, MySQL, PHP) and LAMP (Linux, Apache, MySQL, PHP) stacks.
  • Provides flexibility with multiple versions of Nginx, Apache, and PHP.
  • Includes automatic SSL certificate configuration via Let’s Encrypt.

Prerequisites

Before getting started, ensure you have:

  1. A server running a supported Linux distribution (e.g., CentOS, Ubuntu, Debian).
  2. Root or sudo privileges on the server.
  3. Basic knowledge of the command line.

Step 1: Download and Prepare OneinStack

Start by downloading the OneinStack script to your server.

1
2
# Update your system packages
sudo apt update && sudo apt upgrade -y

Download the OneinStack installation script

wget http://mirrors.linuxeye.com/oneinstack-full.tar.gz

Extract the downloaded file

tar xzf oneinstack-full.tar.gz

Navigate to the OneinStack directory

cd oneinstack

Step 2: Configure Your Stack

Run the installation script to configure your stack. OneinStack provides an interactive menu to customize your setup.

1
./install.sh

You’ll be prompted to select components for your environment:

  • Web server: Choose between Nginx, Apache, or both.
  • Database: Select MySQL, MariaDB, or PostgreSQL.
  • PHP version: Choose from multiple PHP versions, such as 7.4 or 8.2.
  • Additional options: Enable Redis, Memcached, or PHP extensions.

Example Configuration:

  • Web server: Nginx
  • Database: MySQL 8.0
  • PHP: 8.1
  • Cache: Redis

Step 3: Start the Installation

Once your selections are complete, OneinStack will begin downloading and installing the chosen components. This process may take several minutes.

1
2
3
4
5
plaintextCopy codeInstallation starts...
[+] Installing Nginx...
[+] Installing MySQL...
[+] Configuring PHP...

After installation, OneinStack provides a summary of your environment, including configuration paths and service statuses.


Step 4: Verify Your Installation

sudo systemctl status nginx
sudo systemctl status mysql

1
2
3
4
echo "<?php phpinfo(); ?>" | sudo tee /usr/share/nginx/html/info.php

# Access the file in your browser
http://your-server-ip/info.php

Step 5: Enable SSL with Let’s Encrypt

OneinStack simplifies SSL configuration using Certbot. Follow these steps to enable HTTPS for your site.

Provide your domain name when prompted, and OneinStack will automatically configure and renew your SSL certificate.

Step 6: Manage Your Services

OneinStack includes convenient management scripts for starting, stopping, and restarting services.
Troubleshooting Tips

  1. Log Files: Check log files for error details.
    • Nginx: /var/log/nginx/error.log
    • MySQL: /var/log/mysql/error.log
  • Reinstall Components: Rerun install.sh to modify your configuration.
  • Check Port Conflicts: Ensure no other services are using ports 80 or 443.

Conclusion

OneinStack is a powerful tool for initializing your server environment, whether you’re hosting a small website or managing a complex application. By following this guide, you can deploy a reliable LNMP/LAMP stack with minimal effort. Have questions or tips about using OneinStack? Share them in the comments below!