As per the stack definition, there are 3 main components to be installed: nginx, mariadb and php.
Install nginx:
$ sudo apt install nginx -y
Install mariadb:
$ sudo apt install mariadb-server -y
Install php, php-mysql and php-fpm
$ sudo apt install php php-mysql php-fpm -y
Download wordpress code
$ wget https://wordpress.org/latest.tar.gz
Start mariadb
$ sudo systemctl start mariadb
Secure mariadb installation
$ sudo mysql_secure_installation
Create a database for wordpress
$ sudo mariadb -u root
MariaDB [none]> create database wpdb;
MariaDB [none]> grant all on wpdb.* to wpuser@localhost identified by 'wppassword';
MariaDB [none]> flush privileges;
MariaDB [none]> exit
Test the newly created user and db
$ mariadb -u wpuser -p wpdb
MariaDB [wpdb]> exit
Download wordpress
$ wget https://wordpress.org/latest.tar.gz
Extract wordpress
$ tar -xvf latest.tar.gz
Move wordpress directory to /var/www/html
$ sudo mv wordpress /var/www/html
Change ownership of the wordpress directory
$ sudo chown -R www-data /var/www/html/wordpress
Create nginx virtualhost configuration for wordpress
$ sudo nano /etc/nginx/conf.d/wordpress.conf
Add in below code (change the server name to refer to your ip address, since we do not have any domain at the moment)
server {
listen 80;
root /var/www/html/wordpress;
index index.php index.html;
server_name wordpress.10.0.0.5.nip.io;
location / {
try_files $uri $uri/ /index.php?q=$request_uri;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
location ~ .php$ {
try_files $uri =404;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Save the file and exit
Test nginx config for any syntax error
$ sudo nginx -t
Start nginx
$ sudo systemctl start nginx
Start php-fpm
$ sudo systemctl start php7.2-fpm
Open a web browser and put in you server_name address in the address bar, and you should be able to get the wordpress installation wizard. Press "Continue"
Press "Let's go!"
Fill up database details and press "Submit"
If everything is correct, you will get to "Run the installation" page. Click on "Run the installation" button.
Fill up the necessary information for your wordpress blog, and click "Install wordpress" to finish wordpress installation
No comments:
Post a Comment