Skript – server setup
/ 1 / LADDA UPP SKRIPT PÅ SERVERN
Förslagsvis i (cd /home)
Ladda ner skriptet: wpsetup.sh
Sätt upp en ny sida: wpnewsite.sh
/ 2 / KÖR SKRIPTET
chmod +x wpsetup.sh
sudo dos2unix /home/ubuntu/namn.sh
sudo -s
sudo ./wpsetup.sh
Steg för steg guide – server setup
/ 1 / FÖRFIX:
Pointa domänen med A record till IP-adressen
Sätt SSL/TLS encryption mode is >>FULL<<
/ 2 / UPPDATERING & PAKET
sudo apt update
sudo apt upgrade
sudo apt install nginx mariadb-server php-mysql php-curl php-gd php-zip php-fpm php-xmlreader
/ 3 / BRANDVÄGGSFIX (Oracle)
sudo iptables -I INPUT 6 -m state –state NEW -p tcp –dport 80 -j ACCEPT
sudo iptables -I INPUT 6 -m state –state NEW -p tcp –dport 443 -j ACCEPT
sudo netfilter-persistent save
/ 4 / DATABAS
sudo mysql
create user ‘USER’@’localhost’ identified by ‘PASSWORD’;
grant all privileges on *.* to ‘USER’@’localhost’;
create database wpdb;
flush privileges;
exit;
/ 5 / INSTALLERA WP
cd /var/www/html
wget https://wordpress.org/latest.tar.gz
rm index.nginx-debian.html
sudo tar xvfz latest.tar.gz
mv wordpress/* .
rm latest.tar.gz
rm -r wordpress
/ 6 / NGINX
nano /etc/nginx/sites-available/default
– Ändra index raden till: index index.php;
– Okommentera under pass PHP scripts to FastCGI server, till raden
fastcgi_pass unix:/run/php/php8.1-fpm.sock <— Viktig rad, ska vara med (definiera versiontyp, detta fallet 8.1)
ls /var/run/php/php8.1-fpm.sock
nginx -t
sudo systemctl restart nginx
/ 7 / BEHÖRIGHETER
sudo chown -R www-data:www-data /var/www/html
sudo usermod -a -G www-data ubuntu
sudo find /var/www/html –type d –exec chmod 775 {} \;
sudo find /var/www/html –type f –exec chmod 664 {} \;
sudo find /var/www/html -type d -exec chmod g+s {} \;
sudo chown -R www-data:www-data /var/www/html
sudo usermod -a -G www-data ubuntu
sudo find /var/www/html –type d –exec chmod 775 {} \;
sudo find /var/www/html –type f –exec chmod 664 {} \;
sudo find /var/www/html -type d -exec chmod g+s {} \;
/ 7.5 / Besök webbplatsen och se så allt stämmer
/ 8 / SSL
apt-get install certbot python3-certbot-nginx
certbot –nginx
fortsätt installationen…
/ 9 / I WordPress:
General > Settings
Ändra båda URL boxarna till https://domän i stället för http://domän.
Klar med grundinstallationen för en sida, nice!
>> En till sida
/ 1 / RIKTA DOMÄNEN
/ 2 / DATABAS
mysql
create user ‘USER’@’localhost’ identified by ‘PASSWORD’;
create user ‘USER’@’localhost’ identified by ‘PASSWORD’;
create database NAMN default character set utf8 collate utf8_unicode_ci;
grant all on NAMN.* to ‘USER’@’localhost’ identified by ‘PASSWORD’;
flush privileges;
exit;
/ 3 / INSTALLERA WP
Navigera till mapp (cd /var/www/html)
Navigera till mapp (cd /var/www/html)
mkdir namn
cd namn
wget https://wordpress.org/latest.tar.gz
sudo tar xvfz latest.tar.gz
mv wordpress/* .
rm latest.tar.gz
rm -r wordpress
cp wp-config-sample.php wp-config.php
nano wp-config.php
(Fixa salts & databaskonfiguration)
(Fixa salts & databaskonfiguration)
/ 4 / NGINX
cd /etc/nginx/sites-available
cp default domän.conf
nano domän.conf
cd /etc/nginx/sites-enabled
try_files $uri $uri/ /index.php?$args;
sudo ln -s /etc/nginx/sites-available/domän /etc/nginx/sites-enabled/
/ 5 / SSL
certbot –nginx
ÖVRIG FAKTA
>>> Ändra i vim:
i = insert text
ESC + :wq spara och stäng