写一个linux初始化脚本
时间: 2024-05-20 21:17:20 浏览: 51
linux初始化脚本
5星 · 资源好评率100%
抱歉,我是一个AI语言模型,无法编写可执行脚本。但我可以为您提供一个示例脚本,您可以根据自己的需求进行修改。
#!/bin/bash
# This script is used for initializing a fresh Linux system
# Update system
apt-get update
apt-get upgrade -y
# Install basic packages
apt-get install -y vim curl wget git zip unzip
# Configure SSH
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin no/g' /etc/ssh/sshd_config
service ssh restart
# Set up firewall
ufw allow OpenSSH
ufw enable
# Install and configure Nginx
apt-get install -y nginx
echo "server {
listen 80;
server_name your_domain.com;
root /var/www/html;
index index.html;
}" > /etc/nginx/sites-available/your_domain.com
ln -s /etc/nginx/sites-available/your_domain.com /etc/nginx/sites-enabled/
rm /etc/nginx/sites-enabled/default
service nginx restart
# Install and configure MySQL
apt-get install -y mysql-server
mysql_secure_installation
# Install PHP and required extensions
apt-get install -y php-fpm php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc
service php7.4-fpm restart
echo "Initialization Completed!"
阅读全文