8

How to Install PyroCMS on FreeBSD 11

 2 years ago
source link: https://www.vultr.com/docs/how-to-install-pyrocms-on-freebsd-11
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
<?xml encoding="utf-8" ??>

PyroCMS is an open source CMS written in PHP. PyroCMS source code is hosted on GitHub. In this guide, we'll walk through the entire PyroCMS installation process on a FreeBSD 11 Vultr instance. The software stack we will use is: PHP, Nginx, MariaDB and Composer.

Requirements

Before you can install PyroCMS on a server, there are a few requirements that need to be met.

  • VPS with at least 1GB of RAM.
  • PyroCMS supports Apache or Nginx, however, we will be using a LEMP stack.
  • PHP version 7.0 or greater.
  • The following PHP extensions:

    • PDO
    • cURL
    • SQLite
    • OpenSSL
    • Mbstring
    • Fileinfo
    • Tokenizer
    • GD Library, (version 2.0 or greater); or Imagick, (version 6.5.7 or greater)

Before you begin

Check the FreeBSD version.

uname -ro
# FreeBSD 11.2-RELEASE

Ensure that your FreeBSD system is up to date.

freebsd-update fetch install
pkg update && pkg upgrade -y

Install sudo, vim, unzip, wget and bash packages if they are not present on your system.

pkg install -y sudo vim unzip wget bash

Create a new user account with your preferred username, we will use johndoe.

adduser

# Username: johndoe
# Full name: John Doe
# Uid (Leave empty for default): <Enter>
# Login group [johndoe]: <Enter>
# Login group is johndoe. Invite johndoe into other groups? []: wheel
# Login class [default]: <Enter>
# Shell (sh csh tcsh nologin) [sh]: bash
# Home directory [/home/johndoe]: <Enter>
# Home directory permissions (Leave empty for default): <Enter>
# Use password-based authentication? [yes]: <Enter>
# Use an empty password? (yes/no) [no]: <Enter>
# Use a random password? (yes/no) [no]: <Enter>
# Enter password: your_secure_password
# Enter password again: your_secure_password
# Lock out the account after creation? [no]: <Enter>
# OK? (yes/no): yes
# Add another user? (yes/no): no
# Goodbye!

Run the visudo command and uncomment the %wheel ALL=(ALL) ALL line, to allow members of the wheel group to execute any command.

# Uncomment by removing the hash (#) sign
%wheel ALL=(ALL) ALL

Now, switch to your newly created user.

su - johndoe

NOTE: Replace johndoe with your username.

Set up the timezone.

sudo tzsetup

Install PHP

Install PHP, as well as the necessary PHP extensions.

sudo pkg install -y php72 php72-pdo php72-curl php72-sqlite3 php72-openssl php72-mbstring php72-fileinfo php72-tokenizer php72-gd php72-pecl-imagick php72-phar php72-zlib php72-json php72-mbstring php72-xml php72-zip php72-ctype php72-dom php72-simplexml php72-hash php72-filter php72-session php72-pdo_sqlite php72-iconv php72-intl php72-pcntl php72-soap php72-posix php72-mysqli php72-pdo_mysql

Check the version.

php --version

# PHP 7.2.10 (cli) (built: Oct  2 2018 01:30:18) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
#     with Zend OPcache v7.2.10, Copyright (c) 1999-2018, by Zend Technologies

Soft-link php.ini-production to php.ini.

sudo ln -s /usr/local/etc/php.ini-production /usr/local/etc/php.ini

Enable and start PHP-FPM.

sudo sysrc php_fpm_enable=yes
sudo service php-fpm start

Install MariaDB

Download and install MariaDB.

sudo pkg install -y mariadb102-client mariadb102-server

Check the version.

mysql --version
# mysql  Ver 15.1 Distrib 10.2.17-MariaDB, for FreeBSD11.2 (amd64) using readline 5.1

Enable and start MariaDB.

sudo sysrc mysql_enable="yes" 
sudo service mysql-server start

Run the mysql_secure_installation script to improve the security of your installation.

sudo mysql_secure_installation

Log in to MariaDB as the root user.

sudo mysql -u root -p
# Enter password:

Create a new database and user, and remember the credentials.

CREATE DATABASE dbname;
GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

Exit MariaDB.

exit

Install Nginx

Install Nginx.

sudo pkg install -y nginx

Check the version.

nginx -v
# nginx version: nginx/1.14.0

Enable and start Nginx.

sudo sysrc nginx_enable=yes
sudo service nginx start

Run sudo vim /usr/local/etc/nginx/pyro.conf and configure Nginx for Pyro CMS.

server {
  listen 80;

  server_name example.com; # Check this
  root /usr/local/www/pyro/public; # Check this

  index index.php index.html;
  charset utf-8;

  location / {
    try_files $uri $uri/ /index.php?$args;
  }

  location ~ \.php$ {
    fastcgi_pass 127.0.0.1:9000; # Run sockstat -4 -6 | grep php-fpm
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }
}

Save the file and exit.

Now we need to include pyro.conf in the main nginx.conf file.

Run sudo vim /usr/local/etc/nginx/nginx.conf and add the following line to http {} block.

include pyro.conf;

Test Nginx configuration.

sudo nginx -t

Reload Nginx.

sudo service nginx reload

Install Composer

Install Composer globally.

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
sudo mv composer.phar /usr/local/bin/composer

Check the version.

composer --version
# Composer version 1.7.2 2018-08-16 16:57:12

Install PyroCMS via Composer

Create a document root directory.

sudo mkdir -p /usr/local/www/pyro

Change ownership of the /usr/local/www/pyro directory to johndoe.

sudo chown -R johndoe:johndoe /usr/local/www/pyro

Navigate to the document root directory.

cd /usr/local/www/pyro

Using composer, download and install PyroCMS.

composer create-project pyrocms/pyrocms .

NOTE: You may run out of memory when installing Pyro via Composer. It may be wise to stop Nginx, PHP-FPM and MariaDB to save on memory usage and start them again after this step. If that doesn't help you to avoid errors with Composer, then you'll need to add sufficient amount of Swap space.

Change ownership of the /usr/local/www/pyro directory to www.

sudo chown -R www:www /usr/local/www/pyro

Using your preferred web browser, open your site and follow the PyroCMS installer. After following the installer, you will have PyroCMS up and running. To access the PyroCMS admin area just append /admin to your site URL.

Want to contribute?

You could earn up to $600 by adding new articles


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK