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

De Gigafull
Ir para navegação Ir para pesquisar
Linha 1: Linha 1:
 
Ubuntu Server 22.04<br><br>
 
Ubuntu Server 22.04<br><br>
  
apt install net-tools -y<br><br>
+
apt install net-tools -y
  
sudo apt update -y<br>
+
sudo apt update -y<br>
sudo apt upgrade -y<br><br>
+
sudo apt upgrade -y<br><br>
  
sudo apt install nginx -y<br>
+
sudo apt install nginx -y<br>
sudo systemctl status nginx<br><br>
+
sudo systemctl status nginx<br><br>
  
sudo apt install mysql-server -y<br>
+
sudo apt install mysql-server -y<br>
sudo systemctl status mysql<br><br>
+
sudo systemctl status mysql<br><br>
  
mysql -u root -p<br>
+
mysql -u root -p<br>
CREATE DATABASE WordPress CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;<br>
+
CREATE DATABASE WordPress CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;<br>
CREATE USER 'WordPressUser'@'localhost' IDENTIFIED BY 'UYBR438DE98I3MD43M430IDV34';<br>
+
CREATE USER 'WordPressUser'@'localhost' IDENTIFIED BY 'UYBR438DE98I3MD43M430IDV34';<br>
GRANT ALL PRIVILEGES ON WordPress .* TO 'WordPressUser'@'localhost';<br>
+
GRANT ALL PRIVILEGES ON WordPress .* TO 'WordPressUser'@'localhost';<br>
FLUSH PRIVILEGES;<br>
+
FLUSH PRIVILEGES;<br>
EXIT;<br><br>
+
EXIT;<br><br>
  
sudo apt install php -y<br><br>
+
sudo apt install php -y<br><br>
  
sudo mkdir -p /var/www/html/sample.com<br>
+
sudo mkdir -p /var/www/html/sample.com<br>
cd /tmp<br>
+
cd /tmp<br>
wget https://wordpress.org/latest.tar.gz<br>
+
wget https://wordpress.org/latest.tar.gz<br>
tar xf latest.tar.gz<br>
+
tar xf latest.tar.gz<br>
sudo mv /tmp/wordpress/* /var/www/html/sample.com/<br>
+
sudo mv /tmp/wordpress/* /var/www/html/sample.com/<br>
sudo chown -R www-data: /var/www/html/sample.com<br><br>
+
sudo chown -R www-data: /var/www/html/sample.com<br><br>
  
 
vim /etc/nginx/sites-available/sample.com
 
vim /etc/nginx/sites-available/sample.com
 
  Add this code to the newly created file:
 
  Add this code to the newly created file:
 
 
  # Redirect HTTP -> HTTPS
 
  # Redirect HTTP -> HTTPS
 
  server {
 
  server {
 
  listen 80;
 
  listen 80;
 
  server_name www.sample.com sample.com;
 
  server_name www.sample.com sample.com;
 
 
  include snippets/letsencrypt.conf;
 
  include snippets/letsencrypt.conf;
 
  return 301 https://sample.com$request_uri;
 
  return 301 https://sample.com$request_uri;
 
  }
 
  }
 
 
  # Redirect WWW -> NON-WWW
 
  # Redirect WWW -> NON-WWW
 
  server {
 
  server {
 
  listen 443 ssl http2;
 
  listen 443 ssl http2;
 
  server_name www.sample.com;
 
  server_name www.sample.com;
 
 
  ssl_certificate /etc/letsencrypt/live/sample.com/fullchain.pem;
 
  ssl_certificate /etc/letsencrypt/live/sample.com/fullchain.pem;
 
  ssl_certificate_key /etc/letsencrypt/live/sample.com/privkey.pem;
 
  ssl_certificate_key /etc/letsencrypt/live/sample.com/privkey.pem;
 
  ssl_trusted_certificate /etc/letsencrypt/live/sample.com/chain.pem;
 
  ssl_trusted_certificate /etc/letsencrypt/live/sample.com/chain.pem;
 
  include snippets/ssl.conf;
 
  include snippets/ssl.conf;
 
 
  return 301 https://sample.com$request_uri;
 
  return 301 https://sample.com$request_uri;
 
  }
 
  }
 
 
  server {
 
  server {
 
  listen 443 ssl http2;
 
  listen 443 ssl http2;
 
  server_name sample.com;
 
  server_name sample.com;
 
 
  root /var/www/html/sample.com;
 
  root /var/www/html/sample.com;
 
  index index.php;
 
  index index.php;
 
 
  # SSL parameters
 
  # SSL parameters
 
  ssl_certificate /etc/letsencrypt/live/sample.com/fullchain.pem;
 
  ssl_certificate /etc/letsencrypt/live/sample.com/fullchain.pem;
Linha 66: Linha 58:
 
  include snippets/ssl.conf;
 
  include snippets/ssl.conf;
 
  include snippets/letsencrypt.conf;
 
  include snippets/letsencrypt.conf;
 
 
  # log files
 
  # log files
 
  access_log /var/log/nginx/sample.com.access.log;
 
  access_log /var/log/nginx/sample.com.access.log;
 
  error_log /var/log/nginx/sample.com.error.log;
 
  error_log /var/log/nginx/sample.com.error.log;
 
 
  location = /favicon.ico {
 
  location = /favicon.ico {
 
  log_not_found off;
 
  log_not_found off;
 
  access_log off;
 
  access_log off;
 
  }
 
  }
 
 
  location = /robots.txt {
 
  location = /robots.txt {
 
  allow all;
 
  allow all;
Linha 81: Linha 70:
 
  access_log off;
 
  access_log off;
 
  }
 
  }
 
 
  location / {
 
  location / {
 
  try_files $uri $uri/ /index.php?$args;
 
  try_files $uri $uri/ /index.php?$args;
 
  }
 
  }
 
 
  location ~ \.php$ {
 
  location ~ \.php$ {
 
  include snippets/fastcgi-php.conf;
 
  include snippets/fastcgi-php.conf;
 
  fastcgi_pass unix:/run/php/php7.2-fpm.sock;
 
  fastcgi_pass unix:/run/php/php7.2-fpm.sock;
 
  }
 
  }
 
 
  location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
 
  location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
 
  expires max;
 
  expires max;

Edição das 19h39min de 4 de abril de 2023

Ubuntu Server 22.04

apt install net-tools -y
sudo apt update -y
sudo apt upgrade -y

sudo apt install nginx -y
sudo systemctl status nginx

sudo apt install mysql-server -y
sudo systemctl status mysql

mysql -u root -p
CREATE DATABASE WordPress CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER 'WordPressUser'@'localhost' IDENTIFIED BY 'UYBR438DE98I3MD43M430IDV34';
GRANT ALL PRIVILEGES ON WordPress .* TO 'WordPressUser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

sudo apt install php -y

sudo mkdir -p /var/www/html/sample.com
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

Add this code to the newly created file:
# 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;
}
}