WordPress
WordPress deployment on server
These instructions will be for MicroOS. Adjust for Tumbleweed or Leap as required. Instead of the official WordPress, Bedrock by Roots will be used.
A LEMP Stack will be used. Alternatively, a LAMP Stack can be used. Follow the instructions on that page to use it instead.
Web Server
WordPress requires a Web Server. The most common ones are Apache and Nginx. Nginx will be used as an example.
First install Nginx:
sudo transactional-update pkg in nginx
After the installation, a reboot is required:
sudo reboot
Second, enable and start Nginx service:
sudo systemctl enable --now nginx
To test if Nginx is running, go to the IP address of the host in a web browser.
PHP and FPM
Nginx doesn't run PHP on his own, so FPM is needed.
Install PHP and FPM:
sudo transactional-update pkg in php7 php7-fpm
Install required PHP modules:
sudo transactional-update --continue pkg in php7-gd
Install optional PHP modules:
sudo transactional-update --continue pkg in php7-dom php7-exif php7-fileinfo php7-imagick
Install optional fallback PHP modules:
sudo transactional-update --continue pkg in php7-iconv php7-intl
After the installation, a reboot is required:
sudo reboot
Enable and start FPM service:
sudo systemctl enable --now php-fpm
Configure SELinux:
sudo setsebool -P httpd_graceful_shutdown 1
MariaDB
For the database MariaDB will be used.
Install MariaDB and php-mysql(required by WordPress):
sudo transactional-update pkg in mariadb php7-mysql
After the installation, a reboot is required:
sudo reboot
Enable and start MariaDB service:
sudo systemctl enable --now mariadb
Configure SELinux
sudo setsebool -P httpd_can_network_connect_db 1
Secure MariaDB:
sudo mysql_secure_installation
Log in into the server client by executing:
mysql -p -u root
Create a user for WordPress (replace user and password):
CREATE USER 'user'@localhost IDENTIFIED BY 'password';
Flush privileges:
flush privileges;
Exit by typing exit or by pressing ctrl+d.
WordPress Database
To create a database for WordPress, first log in into the server client by executing:
mysql -p -u root
Create the database:
create database wordpress;
Grant database privileges to the user created above:
GRANT ALL PRIVILEGES ON wordpress.* TO 'user'@'localhost';
Flush privileges:
flush privileges;
Exit by typing exit or by pressing ctrl+d and reboot.
Composer
Bedrock requires Composer.
Install Composer and other required tools:
sudo transactional-update pkg in php7-cli php7-tokenizer php7-xmlreader php7-xmlwriter php-composer2 unzip
After the installation, a reboot is required:
sudo reboot
WordPress
Bedrock will be installed in the bedrock directory in /srv/www to keep it separate and isolated of other sites.
Create a new project:
sudo composer create-project roots/bedrock example.com -d /srv/www/
Configure Bedrock
Update environment variables in the .env file:
sudo vi /srv/www/example.com/.env
For the database:
DB_NAME='wordpress' DB_USER='user' DB_PASSWORD='password' DB_HOST='127.0.0.1'
Set the environment (development, staging, production)
WP_ENV='production' WP_HOME='http://example.com' WP_SITEURL="${WP_HOME}/wp"
Go to https://roots.io/salts.html to generate keys and insert them:
AUTH_KEY='generateme' SECURE_AUTH_KEY='generateme' LOGGED_IN_KEY='generateme' NONCE_KEY='generateme' AUTH_SALT='generateme' SECURE_AUTH_SALT='generateme' LOGGED_IN_SALT='generateme' NONCE_SALT='generateme'
Configure Server Block
Create a new file in /etc/nginx/vhosts.d/ to prevent overrides. Replace example and example.com with your domain.
Create the file /etc/nginx/vhosts.d/example.conf
sudo vi /etc/nginx/vhosts.d/example.conf
With the contens:
server { listen 80 default_server;#Use default_server to override the default configuration server_name .example.com; root /srv/www/example.com/web; index index.php index.htm index.html; #Use FPM to server php files location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # Prevent PHP scripts from being executed inside the uploads folder. location ~* /app/uploads/.*.php$ { deny all; } location / { try_files $uri $uri/ /index.php?$args; } }
Restart Nginx service:
sudo systemctl restart nginx
To initialize WordPress, go to the IP address of the host in a web browser.
WordPress development on desktop
wp-env
wp-env is a nodejs tool to help you develop and test WordPress plugins. In openSUSE, you need some extra steps to make it work.
First, you need to install some RPM packages:
sudo zypper install docker nodejs openssl-devel
Second, you need to start and enable Docker service:
sudo systemctl start docker sudo systemctl enable docker
Then, you can install wp-env:
sudo npm -g install @wordpress/env