Install WordPress on Raspberry Pi: Difference between revisions

From WickyWiki
Created page with "Category:202411 Category:Raspberry Pi Category:WordPress Category:Linux = Links = * https://reyestechtips.com/install-wordpress-on-raspberry-pi-using-nginx/ * ... = Install WordPress = This configuration will assume LEMP-stack: Linux, Nginx (engine-x), MariaDB, PHP Install webserver, PHP and database: <source lang=bash> #LEMP sudo apt install nginx php-fpm mariadb-server php-mysql #Optional modules: sudo apt install php8.2-curl php8.2-xml php8.2-im..."
 
mNo edit summary
Line 5: Line 5:


= Links =
= Links =
* https://reyestechtips.com/install-wordpress-on-raspberry-pi-using-nginx/
* https://reyestechtips.com/install-wordpress-on-raspberry-pi-using-nginx/
* ...
* ...


= Install WordPress =
= Install WordPress =
This configuration will assume LEMP-stack: Linux, Nginx (engine-x), MariaDB, PHP
This configuration will assume LEMP-stack: Linux, Nginx (engine-x), MariaDB, PHP


Line 68: Line 66:


= Database secure configuration =
= Database secure configuration =
If you just installed the database, execute this script:
If you just installed the database, execute this script:


Line 103: Line 100:
sudo nano /var/www/wordpress/wp-config.php  
sudo nano /var/www/wordpress/wp-config.php  
</source>
</source>


= Trouble shooting and questions =
= Trouble shooting and questions =
== Nginx message: 413 Request Entity Too Large ==
== Nginx message: 413 Request Entity Too Large ==


Line 129: Line 124:
sudo service nginx restart
sudo service nginx restart
</source>
</source>


== PHP message: The uploaded file exceeds the upload_max_filesize directive in php.ini ==
== PHP message: The uploaded file exceeds the upload_max_filesize directive in php.ini ==
If you are uploading a biggish file, like an image, PHP might complain.
If you are uploading a biggish file, like an image, PHP might complain.


Line 155: Line 148:
sudo service nginx restart
sudo service nginx restart
</source>
</source>


== Stick with simple "perma links" ==
== Stick with simple "perma links" ==
While building the website some links become hardcoded in your Website data. My advice is to stick with Permalink "<HOST>?p=<page-id>" in the WordPress settings. It is a lot easier to find these and search/replace. For example:
While building the website some links become hardcoded in your Website data. My advice is to stick with Permalink "<HOST>?p=<page-id>" in the WordPress settings. It is a lot easier to find these and search/replace. For example:
URL:  //192.168.1.33/?p=123 --> //192.168.1.33/wordpress/?p=123
URL:  //192.168.1.33/?p=123 --> //192.168.1.33/wordpress/?p=123


== Wordpress Site icon: There has been an error cropping your image ==
== Wordpress Site icon: There has been an error cropping your image ==
Needed to install missing modules, they are included in the installation section.
Needed to install missing modules, they are included in the installation section.


= WordPress Learning =
== WordPress Learning ==
 
* https://www.youtube.com/watch?v=oIECtxoTa0s (35min)
* https://www.youtube.com/watch?v=oIECtxoTa0s (35min)
* https://learn.wordpress.org/courses/ (needs account)
* https://learn.wordpress.org/courses/ (needs account)


== How can you see if a theme is block or classical? ==
== How can you see if a theme is block or classical? ==
If you have a block theme, you will see the 'Editor' option in the Appearance menu. A classic theme, will only have the 'Customise' option. The Pages overview in the top-level menu is for editing the site text, if you go via appearance menu you can do that as well but you will also see headers and footers and will be notified when you start editing templates.
If you have a block theme, you will see the 'Editor' option in the Appearance menu. A classic theme, will only have the 'Customise' option. The Pages overview in the top-level menu is for editing the site text, if you go via appearance menu you can do that as well but you will also see headers and footers and will be notified when you start editing templates.


== What is SEO? ==
== What is SEO? ==
Search Engine Optimization. Practices and methods used to optimize the ranking of a site in search engine results.
Search Engine Optimization. Practices and methods used to optimize the ranking of a site in search engine results.


== How to export/import complete website? ==
== How to export/import complete website? ==
Go to Tools > Export/Import in your WordPress admin. You get an XML file but it is limited to website text data.
Go to Tools > Export/Import in your WordPress admin. You get an XML file but it is limited to website text data.


== Disable selection blocks for the whole site ==
== Disable selection blocks for the whole site ==
Disable selection blocks for the whole site.
Disable selection blocks for the whole site.



Revision as of 14:01, 9 November 2024


Links

Install WordPress

This configuration will assume LEMP-stack: Linux, Nginx (engine-x), MariaDB, PHP

Install webserver, PHP and database:

#LEMP
sudo apt install nginx php-fpm mariadb-server php-mysql

#Optional modules:
sudo apt install php8.2-curl php8.2-xml php8.2-imagick php8.2-zip php8.2-gd php8.2-intl

#WordPress
cd /var/www/
sudo wget http://wordpress.org/latest.tar.gz

sudo tar xzf latest.tar.gz
sudo rm -rf latest.tar.gz
sudo chown -vR www-data:www-data /var/www/wordpress

Check PHP location and use it in below configuration:

ls -l /var/run/php/
sudo nano /etc/nginx/sites-available/wordpress
server {
	listen 80;
	server_name _;
	root /var/www/
	index index.php;
	location /wordpress/ {
		try_files $uri $uri/ /index.php?$args;
	}
	location ~ \.php$ {
		include snippets/fastcgi-php.conf;  
		fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
	}
}

Enable the website:

#enable
sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/wordpress

#remove default
sudo rm /etc/nginx/sites-enabled/default 

#restart webserver
sudo service nginx restart

Database secure configuration

If you just installed the database, execute this script:

sudo mysql_secure_installation

Create database and database user:

sudo mysql -u root
create database wordpress default character set utf8 collate utf8_unicode_ci;
-- Replace username and password with your own
create user 'username'@'localhost' identified by 'password'; 
-- Replace username
grant all privileges on wordpress.* TO 'username'@'localhost'; 
flush privileges;
exit

Configure Wordpress database connection. You could use the setup wizard that appears while going to the website URL for the first time. However this may pose problems due to permissions. Instead you can configure the connection in the provided configuration file:

#apply webserver group and user permissions
sudo chown -v www-data:www-data /var/www/wordpress/wp-config.php
#backup
sudo cp /var/www/wordpress/wp-config.php /var/www/wordpress/wp-config.php.BAK
#take sample file
sudo cp /var/www/wordpress/wp-config-sample.php /var/www/wordpress/wp-config.php 
#edit
sudo nano /var/www/wordpress/wp-config.php

Trouble shooting and questions

Nginx message: 413 Request Entity Too Large

If you are uploading a biggish file, like an image, the webserver might complain.

sudo nano /etc/nginx/nginx.conf
http {
	...
	
	# set client body size to 10 MB #
	client_max_body_size 10M;
	
	...
}
sudo service nginx restart

PHP message: The uploaded file exceeds the upload_max_filesize directive in php.ini

If you are uploading a biggish file, like an image, PHP might complain.

#where is php.ini?
ls -l /etc/php

#edit configuration
sudo nano /etc/php/8.2/fpm/php.ini

...

memory_limit = 128M upload_max_filesize = 10M post_max_size = 15M

Restart:

sudo service php8.2-fpm restart
sudo service nginx restart

Stick with simple "perma links"

While building the website some links become hardcoded in your Website data. My advice is to stick with Permalink "<HOST>?p=<page-id>" in the WordPress settings. It is a lot easier to find these and search/replace. For example: URL: //192.168.1.33/?p=123 --> //192.168.1.33/wordpress/?p=123

Wordpress Site icon: There has been an error cropping your image

Needed to install missing modules, they are included in the installation section.

WordPress Learning

How can you see if a theme is block or classical?

If you have a block theme, you will see the 'Editor' option in the Appearance menu. A classic theme, will only have the 'Customise' option. The Pages overview in the top-level menu is for editing the site text, if you go via appearance menu you can do that as well but you will also see headers and footers and will be notified when you start editing templates.

What is SEO?

Search Engine Optimization. Practices and methods used to optimize the ranking of a site in search engine results.

How to export/import complete website?

Go to Tools > Export/Import in your WordPress admin. You get an XML file but it is limited to website text data.

Disable selection blocks for the whole site

Disable selection blocks for the whole site.

Appearance-menu > (enter editor) > (top right) Styles > (right bottom) Additional CSS >

/* disable selection blocks */
:where(.wp-site-blocks *:focus){  
 outline-width:0px;
 outline-style:solid
}