$ sudo -i
$ whoami
root
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
# Install dependencies
$ apt update -y
$ apt install -y nginx php-curl php-gd php-intl php-mbstring php-soap php-xml php-xmlrpc php-zip php8.1-fpm php8.1-mysql
# Setup Nginx configuration
$ cat <<EOT > /etc/nginx/sites-available/mysite.example.com.conf
server {
listen 80;
server_name mysite.example.com www.mysite.example.com;
root /var/www/mysite.example.com;
index index.php index.html index.htm;
client_max_body_size 100m;
location / {
try_files \$uri \$uri/ /index.php?\$args;
}
location ~ \.php\$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
include fastcgi_params;
fastcgi_param PHP_VALUE "upload_max_filesize=100M; \n post_max_size=100M; \n post_max_size=128M; \n memory_limit=256M;";
}
location ~ /\.ht {
deny all;
}
}
EOT
$ ln -s /etc/nginx/sites-available/mysite.example.com.conf /etc/nginx/sites-enabled/mysite.example.com.conf
$ nginx -t
$ nginx -s reload
# Install WordPress (latest version)
$ cd /tmp
$ curl -LO https://wordpress.org/latest.tar.gz
$ tar xzvf latest.tar.gz
$ cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
$ cp -a /tmp/wordpress/. /var/www/mysite.example.com
$ chown -R www-data:www-data /var/www/mysite.example.com
# Generate WordPress keys
$ curl -s https://api.wordpress.org/secret-key/1.1/salt/ > /var/www/mysite.example.com/salt.txt && cat /var/www/mysite.example.com/salt.txt
# Setup WordPress keys
$ vim /var/www/mysite.example.com/wp-config.php
< Update with the values from /var/www/mysite.example.com/salt.txt >
# Update WordPress database connection
$ vim /var/www/mysite.example.com/wp-config.php
define( 'DB_NAME', 'mydb' );
define( 'DB_USER', 'myuser' );
define( 'DB_PASSWORD', 'mypassword' );
define( 'DB_HOST', 'localhost' );
# Setup WordPress Plugin to offload media files to AWS S3 Bucket
$ vim /var/www/mysite.example.com/wp-config.php
/* Add any custom values between this line and the "stop editing" line. */
// WP Offload to S3 Plugin. More at https://wordpress.org/plugins/amazon-s3-and-cloudfront/
define( 'AS3CF_SETTINGS', serialize( array(
'provider' => 'aws',
'access-key-id' => 'AKIA2JN7X********',
'secret-access-key' => '4tQrWUzkUX*************',
) ) );
# Setup SSL/TLS
$ snap install --classic certbot
$ ln -s /snap/bin/certbot /usr/bin/certbot
$ certbot --nginx
# Complete the WordPress installation by going to https://www.mysite.example.com
# and Install this Plugin https://wordpress.org/plugins/amazon-s3-and-cloudfront/
Created
July 3, 2024 09:33
-
-
Save lnxph-devops-sareno/1f99a242330a66b2702ffdbf0c4835ac to your computer and use it in GitHub Desktop.
Instaling WordPress+Nginx on Ubuntu 22.04
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment