Knowledge Base

How to Install PyroCMS on CentOS 7

  • Last Created On Dec 03, 2024
  • 25
0 0

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 CentOS 7 AKLWEB HOST instance.

Requirements

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

  • 1GB of RAM
  • LEMP/LAMP stack
  • PHP >= 7.0
  • PDO PHP Extension
  • cURL PHP Extension
  • SQLite PHP Extension
  • OpenSSL PHP Extension
  • Mbstring PHP Extension
  • Fileinfo PHP Extension
  • Tokenizer PHP Extension
  • GD Library (>=2.0) OR Imagick PHP extension (>=6.5.7)

Check the CentOS version.

cat /etc/centos-release
# CentOS Linux release 7.4.1708 (Core)

Create a new non-root user account with sudo access and switch to it.

useradd -c "John Doe" johndoe && passwd johndoe
usermod -aG wheel johndoe
su - johndoe

NOTEReplace johndoe with your username.

Set up the timezone.

timedatectl list-timezones
sudo timedatectl set-timezone 'Region/City'

Ensure that your system is up to date.

sudo yum update -y

Install required and useful packages.

sudo yum install -y wget vim unzip bash-completion

Disable SELinux.

sudo setenforce 0

Install PHP and required extensions

CentOS does not provide the latest PHP version in its default software repositories. We’ll need to add a Webtatic YUM repo.

Download and install PHP 7.2 and required PHP extensions.

sudo yum install -y php72w php72w-cli php72w-fpm php72w-mysql php72w-curl php72w-sqlite3 php72w-mbstring php72w-gd php72w-dom

Check PHP version.

php --version
PHP 7.2.2 (cli) (built: Feb  4 2018 10:14:07) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

Install MySQL/MariaDB and create a database

Download and install MariaDB.

sudo vim /etc/yum.repos.d/MariaDB.repo

# Copy/paste this to the /etc/yum.repos.d/MariaDB.repo file

[mariadb]

name = MariaDB baseurl = https://yum.mariadb.org/10.2/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1 sudo yum install -y MariaDB-server MariaDB-client

Check the MariaDB version.

mysql --version
# mysql  Ver 15.1 Distrib 10.2.13-MariaDB, for Linux (x86_64) using readline 5.1

Start and enable MariaDB.

sudo systemctl enable mariadb.service
sudo systemctl start mariadb.service

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

sudo mysql_secure_installation

Log into MariaDB as the root user.

mysql -u root -p
# Enter password:

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

create database dbname;
grant all on dbname.* to 'username' identified by 'password';

Exit MySQL.

exit

Install and configure NGINX

Install NGINX.

sudo vim /etc/yum.repos.d/nginx_mainline.repo

# Copy/paste this to the /etc/yum.repos.d/nginx_mainline.repo file

[nginx]

name=nginx repo baseurl=https://nginx.org/packages/mainline/centos/7/$basearch/ gpgcheck=1 enabled=1 wget https://nginx.org/keys/nginx_signing.key sudo rpm –import nginx_signing.key rm nginx_signing.key sudo yum install -y nginx

Check the NGINX version.

nginx -v

Start and enable NGINX.

sudo systemctl enable nginx.service
sudo systemctl start nginx.service

Configure NGINX as a FastCGI proxy. Run sudo vim /etc/nginx/conf.d/pyro.conf and populate it with the following text.

server {
  listen 80;

  server_name example.com; # Check this
  root /var/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; # Check this
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }
}

NOTEMake sure to point the web root to Pyro’s public directory.

Test the NGINX configuration.

sudo nginx -t

Reload NGINX.

sudo systemctl reload nginx.service

Download and install Composer

Download the Composer dependencies.

sudo yum install -y curl git unzip

Download and install Composer, the dependency manager for PHP.

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { 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 Composer version.

composer --version
# Composer version 1.6.3 2018-01-31 16:28:17

Download and install PyroCMS via Composer

Create a document root directory.

sudo mkdir -p /var/www/pyro

Change the ownership of the /var/www/pyro  directory to johndoe.

sudo chown -R johndoe:johndoe /var/www/pyro

Download the latest stable release of PyroCMS from the command line.

cd /var/www/pyro
composer create-project pyrocms/pyrocms .

NOTEYou may run out of memory when installing Pyro via Composer. It may be wise to stop Nginx, PHP-FPM and MySQL servers with sudo systemctl stop nginx.service php-fpm.service mysql.service to save on memory usage and start them again after this step.

Change the ownership of the /var/www/pyro directory to nginx.

sudo chown -R nginx:nginx /var/www/pyro

Run sudo vim /etc/php-fpm.d/www.conf and set the user and group to nginx.

sudo vim /etc/php-fpm.d/www.conf
# user = nginx
# group = nginx

Restart the php-fpm.service.

sudo systemctl restart php-fpm.service

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, append /admin to your site URL.

Views: 25

Recent Articles

  • How to Install JAX with ROCm Acceleratio...
    87
  • Deploy a PyTorch Workspace on a Vultr Cl...
    68
  • Managing Backup Storage
    77
  • Automating FTP Backups in Windows Server
    69
  • Automating FTP Backups in Linux
    73

Popular Articles

  • Our General Terms & Conditions
    2592
  • Our Privacy Policy
    2442
  • Our Cookies Policy
    269
  • Our Terms of Use
    147
  • How to Install JAX with ROCm Acceleratio...
    87