How to Install Craft CMS with a LEMP Stack
There are many PHP based Content Management Systems (CMS) that you can run on an Alibaba Cloud ECS Instance with a LEMP stack. Of these, Craft CMS is probably one of the slickest.
As Craft is built using the Yii high performance PHP framework, and adheres to modern PHP standards, it is also a very scalable and stable platform.
- Nginx installed
- MariaDB installed and secured
The final part of the LEMP stack we need to run Craft CMS is PHP. Although Craft will run on PHP5.3 and upwards, it is not advisable to use old and unsupported versions. PHP7 is much more secure and provides incredibly superior performance.
As Nginx doesn’t natively process dynamic content, such as PHP scripts, we will need to install PHP-FPM. This will install all the core PHP packages we need to run with an NGINX server. Let’s also install the PHP extension for MySQL at the same time:
# apt-get install php-fpm php-mysql
Craft CMS requires a few other PHP packages that aren’t included in PHP-FPM, so we need to install them separately:
# apt-get install php7.0-curl php7.0-mbstring php7.0-mcrypt php-imagick php7.0-xml
You will need to enter yes to continue when prompted:
And since CraftCMS is a modern PHP application, as such its workflow uses both ‘git’ and the ‘composer’ php package manager during development.
Install these next:
# apt-get install composer git
We will need a root directory for the CraftCMS files and sub-directories. We will create this in the ‘/var/www/’ directory:
# mkdir /var/www/example.com
Change directory to your newly created route directory:
# cd /var/www/example.com
Download and Prepare the CraftCMS files
Now download the latest zip archive containing the CraftCMS files:
# wget -O craft.zip https://buildwithcraft.com/latest.zip?accept_license=yes --no-check-certificate
We will need to unzip the archive, but first we need to install a package to do that:
# apt-get install unzip
We can now unzip the archive:
# unzip craft.zip
When you unzip the archive it will create two directories within your root directory, ‘craft’ and ‘public’, you can see them if you list out the directory:
Craft has a very modern directory structure, its public directory only includes the ‘index.php’ file required to run the application, this is the file our Nginx virtual host points to in order to serve the site. All of the nuts and bolts of the CraftCMS are run securely from a directory one level above the index.php file.
When you listed out the root directory contents, you will see that the ‘craft.zip’ archive is still there, we need to delete it:
# rm craft.zip
We also need to check ownerships of our directories:
# ls -l
Make the server user ‘www-data’ the owner of both directories, then recheck:
# chown -R www-data:www-data /var/www/example.com
# ls -l
You should now be able to confirm that ‘www-data’ user and group owns both directories. After you have set the files successfully, you can configure domain and DNS, and then create Nginx virtual host files, add a Let’s Encrypt SSL certificate, create a Database and finalize the installation and configuration of CraftCMS. For details, you can go to Install Craft CMS on a LEMP Stack on Alibaba Cloud.
Related Blog Posts
How to Install Redis Object Caching on WordPress
Caching allows us to store data in RAM so that any future request for that data can be served faster, without any needing to query the database or process any PHP. In this tutorial, we will install a Redis server as an object cache for DB queries, and configure WordPress to use it.
How to Install LibreNMS on Ubuntu 16.04
LibreNMS is a free and open source auto-discovering network monitoring tool for servers and network hardware. It supports wide range of network hardware and operating systems including Cisco, Linux, Juniper, Foundry, Windows, Brocade and many more.
LibreNMS runs on the web server, written in PHP and uses MariaDB for database. So you will need to install Apache, PHP and MariaDB to your system.
Related Market Products
LEMP on Ubuntu 14.04 64bits powered by IGS
Ubuntu 14.04 integrated with the lightweight yet powerful Nginx web server. We, IGS, provide a list of images pre-integrated with most popular software for web solution. It includes ready-to-run versions of Apache/Nginx, MySQL, PHP, phpMyAdmin and all of the other software required to run each of those components. IGS image greatly simplifies the development and deployment of web applications.
Unable to access the websites running on ECS Instances
If any error occurs while you access your website, we recommend searching for the error code and view the description first. A list of error codes is provided, at the end of this document.
Elastic Compute Service
Alibaba Cloud Elastic Compute Service (ECS) provides fast memory and the latest Intel CPUs to help you to power your cloud applications and achieve faster results with low latency. All ECS instances come with Anti-DDoS protection to safeguard your data and applications from DDoS and Trojan attacks.
ApsaraDB RDS for MySQL
MySQL is one of the most popular open-source databases in the world. As a key component of the open-source software bundle LAMP (Linux, Apache, MySQL, and Perl/PHP/Python), MySQL has been widely applied to different scenarios.
Mysql Database Concepts and Operations
After learning this MySQL series courses, the trainees will master the MySQL relevant basic concept, deployment procedure, HA solution, commonly used backup and recovery method and daily inspection skills, thus having a comprehensive understanding of MySQL database.