Mudanças entre as edições de "Instalação NGINX + Wordpress Ubuntu 22.04"

De Gigafull
Ir para navegação Ir para pesquisar
Linha 6: Linha 6:
 
  sudo apt upgrade -y
 
  sudo apt upgrade -y
  
  sudo apt install nginx -y
+
  sudo apt install apache2 -y
sudo apt install certbot -y-
 
sudo apt-get install nginx-extras -y
 
sudo systemctl status nginx
 
  
 
  sudo apt install mysql-server -y
 
  sudo apt install mysql-server -y
sudo systemctl status mysql
 
  
  mysql -u root -p
+
  sudo apt install php libapache2-mod-php php-mysql php-curl php-gd php-json php-zip -y
  CREATE DATABASE WordPress CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
+
 
  CREATE USER 'WordPressUser'@'localhost' IDENTIFIED BY 'UYBR438DE98I3MD43M430IDV34';
+
vim /etc/apache2/mods-enabled/dir.conf
  GRANT ALL PRIVILEGES ON WordPress .* TO 'WordPressUser'@'localhost';
+
<IfModule mod_dir.c>
 +
        DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
 +
</IfModule>
 +
 
 +
sudo systemctl restart apache2
 +
 
 +
sudo mysql -u root -p
 +
  CREATE DATABASE wordpress;
 +
  CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'senha';
 +
  GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
 
  FLUSH PRIVILEGES;
 
  FLUSH PRIVILEGES;
  EXIT;
+
  exit;
  
  sudo apt install php -y
+
  cd /tmp
 +
curl -O https://wordpress.org/latest.tar.gz
 +
tar xzvf latest.tar.gz
  
  sudo mkdir -p /var/www/html/sample.com
+
  sudo rsync -avP /tmp/wordpress/ /var/www/html/
cd /tmp
 
wget https://wordpress.org/latest.tar.gz
 
tar xf latest.tar.gz
 
sudo mv /tmp/wordpress/* /var/www/html/sample.com/
 
sudo chown -R www-data: /var/www/html/sample.com
 
  
vim /etc/nginx/sites-available/sample.com
+
  sudo chown -R www-data:www-data /var/www/html/
  # Redirect HTTP -> HTTPS
 
server {
 
listen 80;
 
server_name www.sample.com sample.com;
 
include snippets/letsencrypt.conf;
 
return 301 https://sample.com$request_uri;
 
}
 
# Redirect WWW -> NON-WWW
 
server {
 
listen 443 ssl http2;
 
server_name www.sample.com;
 
ssl_certificate /etc/letsencrypt/live/sample.com/fullchain.pem;
 
ssl_certificate_key /etc/letsencrypt/live/sample.com/privkey.pem;
 
ssl_trusted_certificate /etc/letsencrypt/live/sample.com/chain.pem;
 
include snippets/ssl.conf;
 
return 301 https://sample.com$request_uri;
 
}
 
server {
 
listen 443 ssl http2;
 
server_name sample.com;
 
root /var/www/html/sample.com;
 
index index.php;
 
# SSL parameters
 
ssl_certificate /etc/letsencrypt/live/sample.com/fullchain.pem;
 
ssl_certificate_key /etc/letsencrypt/live/sample.com/privkey.pem;
 
ssl_trusted_certificate /etc/letsencrypt/live/sample.com/chain.pem;
 
include snippets/ssl.conf;
 
include snippets/letsencrypt.conf;
 
# log files
 
access_log /var/log/nginx/sample.com.access.log;
 
error_log /var/log/nginx/sample.com.error.log;
 
location = /favicon.ico {
 
log_not_found off;
 
access_log off;
 
}
 
location = /robots.txt {
 
allow all;
 
log_not_found off;
 
access_log off;
 
}
 
location / {
 
try_files $uri $uri/ /index.php?$args;
 
}
 
location ~ \.php$ {
 
include snippets/fastcgi-php.conf;
 
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
 
}
 
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
 
expires max;
 
log_not_found off;
 
}
 
}
 
  
  sudo ln -s /etc/nginx/sites-available/sample.com /etc/nginx/sites-enabled/
+
  Acesse o site do WordPress em um navegador da web através do IP do servidor e siga as instruções para concluir a configuração.
sudo nginx -t
 
sudo systemctl restart nginx
 

Edição das 09h14min de 10 de abril de 2023

Ubuntu Server 22.04

apt install net-tools -y
sudo apt update -y
sudo apt upgrade -y
sudo apt install apache2 -y
sudo apt install mysql-server -y
sudo apt install php libapache2-mod-php php-mysql php-curl php-gd php-json php-zip -y
vim /etc/apache2/mods-enabled/dir.conf
<IfModule mod_dir.c>
       DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>
sudo systemctl restart apache2
sudo mysql -u root -p
CREATE DATABASE wordpress;
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'senha';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;
exit;
cd /tmp
curl -O https://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
sudo rsync -avP /tmp/wordpress/ /var/www/html/
sudo chown -R www-data:www-data /var/www/html/
Acesse o site do WordPress em um navegador da web através do IP do servidor e siga as instruções para concluir a configuração.