Instalação Profissional: WordPress na VPS
1. Preparação do Ambiente
Com a VPS limpa e formatada, instale todas as dependências necessárias:
apt update && apt upgrade -y
apt install nginx mariadb-server php-fpm php-mysql php-curl php-gd php-intl php-mbstring php-soap php-xml php-xmlrpc php-zip unzip -y
apt install nginx mariadb-server php-fpm php-mysql php-curl php-gd php-intl php-mbstring php-soap php-xml php-xmlrpc php-zip unzip -y
2. Security: Segurança do Banco de Dados
mysql_secure_installation
Respostas para o terminal:
– Enter current password for root: Aperte ENTER
– Switch to unix_socket authentication? Digite n
– Change the root password? Digite y (Defina sua senha e guarde!)
– Para todas as outras perguntas, digite y e ENTER.
– Enter current password for root: Aperte ENTER
– Switch to unix_socket authentication? Digite n
– Change the root password? Digite y (Defina sua senha e guarde!)
– Para todas as outras perguntas, digite y e ENTER.
3. Criação do Banco de Dados
mysql -u root -p
CREATE DATABASE db_wordpress;
CREATE USER ‘admin_user’@’localhost’ IDENTIFIED BY ‘SenhaForte123@’;
GRANT ALL PRIVILEGES ON db_wordpress.* TO ‘admin_user’@’localhost’;
FLUSH PRIVILEGES;
EXIT;
CREATE DATABASE db_wordpress;
CREATE USER ‘admin_user’@’localhost’ IDENTIFIED BY ‘SenhaForte123@’;
GRANT ALL PRIVILEGES ON db_wordpress.* TO ‘admin_user’@’localhost’;
FLUSH PRIVILEGES;
EXIT;
4. Download na Pasta do Projeto
Para não apagar outros sites, instalaremos na pasta projeto_aula:
mkdir -p /var/www/html/projeto_aula
cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz
cp -R wordpress/* /var/www/html/projeto_aula/
chown -R www-data:www-data /var/www/html/projeto_aula
chmod -R 755 /var/www/html/projeto_aula
cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz
cp -R wordpress/* /var/www/html/projeto_aula/
chown -R www-data:www-data /var/www/html/projeto_aula
chmod -R 755 /var/www/html/projeto_aula
5. Virtual Host (Configurado para a Pasta)
Criando o arquivo de configuração exclusivo do projeto:
nano /etc/nginx/sites-available/projeto_aula
Cole o conteúdo abaixo:
server {
listen 81;
server_name _;
root /var/www/html/projeto_aula;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
listen 81;
server_name _;
root /var/www/html/projeto_aula;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
Ative e reinicie o Nginx:
ln -s /etc/nginx/sites-available/projeto_aula /etc/nginx/sites-enabled/
nginx -t
systemctl restart nginx
nginx -t
systemctl restart nginx
6. Acesso Final
Acesse: http://SEU_IP:81
Suporte Autodidata