Instalando LEMP no Ubuntu 22.04/24.04
O LEMP usa o Nginx no lugar do Apache, oferecendo melhor performance para sites de alto tráfego.
1. Atualizar o sistema:
sudo apt update && sudo apt upgrade -y
2. Instalar o Nginx:
sudo apt install nginx -y
sudo systemctl enable nginx
sudo systemctl start nginx
3. Instalar o MySQL:
sudo apt install mysql-server -y
sudo mysql_secure_installation
4. Instalar o PHP-FPM:
sudo apt install php-fpm php-mysql php-cli php-curl php-gd php-mbstring php-xml php-zip -y
5. Configurar o Nginx para PHP:
sudo nano /etc/nginx/sites-available/default
Dentro do bloco server, adicione/edite:
index index.php index.html;
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php-fpm.sock;
}
6. Testar e reiniciar:
sudo nginx -t
sudo systemctl restart nginx
Seu servidor LEMP está pronto para uso!