Support #964
Install WordPress on FreeBSD
Start date:
09/11/2021
Due date:
% Done:
100%
Estimated time:
Description
This is a guide on setting up WordPress with Nginx on FreeBSD 12.
Prepare the Environment¶
- Before installation of the components, make sure everything is up to date using the following command:
pkg update -f && pkg upgrade
- Create the wordpress user:
pw user add -n wordpress -s /sbin/nologin -c "WordPress"
Install Nginx¶
- Install Nginx
pkg install nginx
- Create a configuration directory to make managing individual server blocks easier
mkdir /usr/local/etc/nginx/conf.d
- Edit the main nginx config file:
vi /usr/local/etc/nginx/nginx.conf
- And strip down the config file and add the include statement at the end to make it easier to handle various server blocks:
worker_processes 1; error_log /var/log/nginx-error.log; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; # Load config files from the /etc/nginx/conf.d directory include /usr/local/etc/nginx/conf.d/*.conf; }
- And strip down the config file and add the include statement at the end to make it easier to handle various server blocks:
Install MySQL Server¶
- Start by installing the mariadb100-server and mariadb100-client packages:
pkg install mariadb105-{server,client}
- Enable and start mysql at boot:
sysrc mysql_enable=YES service mysql-server start
- Prepare the database for use by running the secure installation:
mysql_secure_installation
- NOTE: Choose a strong root password and answer yes to all questions.
Create Databases and Users¶
- Login to MySQL and create appropriate databases and users.
mysql -u root -p
- and run the following SQL queries to create the wordpressdb database and wordpressuser user:
CREATE DATABASE wordpressdb CHARACTER SET utf8; CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'SuperSecretPassword'; GRANT ALL PRIVILEGES ON wordpressdb.* TO 'wordpressuser'@'localhost'; FLUSH PRIVILEGES; quit
- and run the following SQL queries to create the wordpressdb database and wordpressuser user:
Install WordPress¶
- Install wordpress:
pkg install wordpress
vi /usr/local/etc/php-fpm.d/wordpress.example.com.conf
- And add the following:
[wordpress.example.com] user = wordpress group = www listen = /var/run/wordpress.sock listen.owner = wordpress listen.group = www pm = dynamic pm.max_children = 5 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3 php_admin_value[post_max_size] = 12M php_admin_value[upload_max_filesize] = 10M
- Create an wordpress.example.com server block config file:
vi /usr/local/etc/nginx/conf.d/wordpress.example.com.conf
- Add the following:
server { listen 80; server_name wordpress.example.com; root /usr/local/www/wordpress; index index.php index.html index.htm; client_max_body_size 12m; location / { try_files $uri $uri/ /index.php?q=$uri&$args; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/local/www/nginx-dist; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/wordpress.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $request_filename; include fastcgi_params; } }
- Add the following:
- Change the ownership of the wordpress directory:
chown -R wordpress:www /usr/local/www/wordpress
- Restart nginx and start php-fpm:
sysrc nginx_enable=YES service nginx restart sysrc php_fpm_enable=YES service php-fpm start
- Now open up a web browser and go to http://wordpress.example.com to finish the setup process.
Resources¶
Updated by Daniel Curtis over 3 years ago
- % Done changed from 0 to 100
- Status changed from New to Resolved