How to Install Anchor CMS on Ubuntu 18.04 LTS
Anchor CMS is a free, open source, simple, lightweight and powerful content management system. It is specially designed with performance with a focus on simplicity and elegance. Anchor comes with lots of features like, easy installation, the ability to add custom CSS, JavaScript, and HTML and drag and drop functionality.
This guide will explain how to install Anchor CMS on an Ubuntu 18.04 LTS (Bionic Beaver) server.
Requirements
- A server running Ubuntu 18.04.
- A non-root user with sudo privileges.
Install LAMP Server
Anchor CMS runs on the Web server, written in PHP and use MariaDB to store their data. So you will need to install Apache, MariaDB and PHP to your system.
First, install Apache and MariaDB with the following command:
sudo apt-get install apache2 mariadb-server -y
Next, you will need to add ondrej repository to install the latest version of PHP. You can add the repository with the following command:
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php -y
Once the repository is installed, update the repository and install PHP along with all the dependencies with the following command:
sudo apt-get update -y
sudo apt-get install php7.2 libapache2-mod-php7.2 php7.2-common php7.2-mysql php7.2-mcrypt php7.2-mbstring php7.2-xmlrpc php7.2-soap php7.2-gd php7.2-xml php7.2-cli php7.2-curl php7.2-zip -y
Once all the packages are installed, edit the PHP default configuration file:
sudo nano /etc/php/7.2/apache2/php.ini
Make the following changes:
memory_limit = 256M upload_max_filesize = 150M max_execution_time = 360 date.timezone = Asia/Kolkata
Save and close the file, then start Apache and MariaDB service and enable them to start on boot with the following command:
sudo systemctl start apache2
sudo systemctl enable apache2
sudo systemctl start mysql
sudo systemctl enable mysql
Configure MariaDB
Before starting, you will need to secure MariaDB default installation. You can do this by running the following script:
sudo mysql_secure_installation
Answer all the questions as shown below:
Enter current password for root (enter for none): Set root password? [Y/n]: N Remove anonymous users? [Y/n]: Y Disallow root login remotely? [Y/n]: Y Remove test database and access to it? [Y/n]: Y Reload privilege tables now? [Y/n]: Y
Once the MariaDB is secured, log in to MariaDB shell:
mysql -u root -p
Enter your root password and press Enter, then create a database and user with the following command:
MariaDB [(none)]> CREATE DATABASE anchor_db;
MariaDB [(none)]> CREATE USER anchor_user;
Next, grant privileges to the Anchor database with the following command:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON anchor_db.* TO 'anchor_user'@'localhost' IDENTIFIED BY 'password';
Next, you will need to run the FLUSH PRIVILEGES command so that the privileges table will be reloaded by MySQL and we can use new credentia$
MariaDB [(none)]> FLUSH PRIVILEGES;
Next, exit from the MariaDB console with the following command:
MariaDB [(none)]> \q
Install Anchor CMS
Before starting, you will need to install Composer on your system. The Composer is a dependency manager for PHP. You can install it with the following command:
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
Next, download Anchor CMS using the following command:
cd /var/www/html
sudo composer create-project anchorcms/anchor-cms
sudo mv anchor-cms anchor
Next, give proper permissions to the anchor directory:
sudo chown -R www-data:www-data /var/www/html/anchor/
sudo chmod -R 755 /var/www/html/anchor/
Configure Apache for Anchor
First, you will need to create an apache virtual host file for Anchor CMS. You can create it with the following command:
sudo nano /etc/apache2/sites-available/anchor.conf
Add the following lines:
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/html/anchor ServerName example.com <Directory /var/www/html/anchor/> Options FollowSymlinks AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/anchor_error.log CustomLog ${APACHE_LOG_DIR}/anchor_access.log combined </VirtualHost>
Save the file, then enable apache virtual host file with the following command:
sudo a2ensite anchor
Next, enable Apache rewrite module and reload apache service with the following command:
sudo a2enmod rewrite
sudo systemctl restart apache2
Access Anchor Web Interface
Now, open your web browser and type the URL http://example.com. You will be redirected to the following page:
Now, click on the Run the installer button. You should see the following page:
Here, choose Language and Time zone, then click on the Next Step button. You should see the following page:
Provide your database details, then click on the Next Step button. You should see the following page:
Provide your site name and description, then click on the Next Step button. You should see the following page:
Provide your admin username, password and email, then click on the Complete button. You should see the following page:
Now, click on the visit your admin panel button. You should see the following page:
Now, provide your admin username and password, then click on the Login button. You should see the following page: