Mudanças entre as edições de "Instalação NGINX + Wordpress Ubuntu 22.04"
Ir para navegação
Ir para pesquisar
Linha 27: | Linha 27: | ||
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 | ||
+ | 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; | ||
+ | } | ||
+ | } |
Edição das 19h38min 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; } }