<\/span><\/h2>\nThe easiest way to install Mezzanine is with Python pip. Pip is a package management system which is used to install and manage packages written in Python.<\/p>\n
In order to use pip, we first need to install Python 3 and pip3 on our server. To do this, run the following command:<\/p>\n
sudo apt install python3 python3-pip python3-dev<\/pre>\nTo verify if Python 3 has been successfully installed, you can run the following command:<\/p>\n
python3 -V<\/pre>\nOutput:<\/p>\n
Python 3.6.7<\/pre>\nAnd to verify if pip3 is installed, you can execute this:<\/p>\n
pip3 -V<\/pre>\nOutput:<\/p>\n
pip 9.0.1 from \/usr\/lib\/python3\/dist-packages (python 3.6)<\/pre>\n<\/span>2. Install MySQL and Create the Mezzanine database<\/span><\/h2>\nMezzanine CMS can work with MySQL, MariaDB, PostgreSQL, Oracle, and SQLite-based databases. In this tutorial, we will be using a MySQL database.<\/p>\n
First, install the MySQL database server with the following command:<\/p>\n
sudo apt install mysql-server<\/pre>\nThe MySQL web server will be started automatically as soon as the installation is completed.<\/p>\n
You can check if the service is running with the following command:<\/p>\n
sudo systemctl status mysql<\/pre>\nTo enable the MySQL service to automatically start up upon server reboot, run the following command:<\/p>\n
sudo systemctl enable mysql<\/pre>\nTo further improve the security of our MySQL installation as well as set up a password for our MySQL root user, we need to run the mysql_secure_installation<\/strong> script and follow the on-screen instructions. Run the command below to configure your system:<\/p>\nsudo mysql_secure_installation<\/pre>\nYou can now log in to your MySQL database server as the root user with this command:<\/p>\n
sudo mysql -u root -p<\/pre>\nTo create a new database and user, run the following commands on the MySQL shell:<\/p>\n
CREATE DATABASE mezzanine CHARACTER SET UTF8;\r\nCREATE USER mezzanine@localhost IDENTIFIED BY 'strong-password';\r\nGRANT ALL PRIVILEGES ON mezzanine.* TO mezzanine@localhost;\r\nFLUSH PRIVILEGES;<\/pre>\nTo exit the MySQL database server command line, type:<\/p>\n
exit<\/pre>\n<\/span>Step 3: Install Python Virtual Environment for Mezzanine<\/span><\/h2>\nThe Python Virtual Environment is a tool that you can use to create isolated Python environments. It creates an environment that has its own installation directories, and it doesn’t share libraries with any other virtual environments that are running on our server.<\/p>\n
To install the Python Virtual Environment, run the following command:<\/p>\n
sudo pip3 install virtualenv<\/pre>\n<\/span>Step 4: Create a Mezzanine User<\/span><\/h2>\nBefore we proceed, let’s create a new user for our Mezzanine installation:<\/p>\n
adduser mezzanine<\/pre>\nNow, let\u2019s add this new user to the sudo group:<\/p>\n
usermod -aG sudo mezzanine<\/pre>\nOnce added, we can log in as the mezzanine<\/code> user with:<\/p>\nsu - mezzanine<\/pre>\n<\/span>Step 5:\u00a0 Create a New Virtual Environment<\/span><\/h2>\nTo create the virtual environment for Mezzanine, run the following command:<\/p>\n
virtualenv mezzanine<\/pre>\nOutput:<\/p>\n
Using base prefix '\/usr'\r\nNew python executable in \/home\/mezzanine\/mezzanine\/bin\/python3\r\nAlso creating executable in \/home\/mezzanine\/mezzanine\/bin\/python\r\nInstalling setuptools, pip, wheel...\r\ndone.<\/pre>\nTo activate the virtual environment run the following:<\/p>\n
source mezzanine\/bin\/activate<\/pre>\nNow you are in the Python virtual environment – you are now ready to begin the installation.<\/p>\n
<\/span>Step 6: Install the Mezzanine CMS<\/span><\/h2>\nTo install the Mezzanine CMS onto our new virtual environment, run the following command:<\/p>\n
pip install mezzanine<\/pre>\nNOTE<\/strong>:<\/span> Pay attention to the command – even if we are using Python 3, when inside the Python virtual environment, you can use the \u2018pip\u2019 command instead of \u2018pip3\u2019 and ‘python’ instead of ‘python3’.<\/p>\n<\/span>Step 7: Create a New Mezzanine Project<\/span><\/h2>\nTo create a new Mezzanine project, run the following command:<\/p>\n
mezzanine-project mezzanine_project<\/pre>\nThis will add a new directory for our project called\u00a0mezzanine_project<\/code>. You can name this according to your needs, but remember to use that name throughout the rest of the tutorial.<\/p>\nTo enter this directory, run:<\/p>\n
cd mezzanine_project<\/pre>\n<\/span>Step 8: Configure the Mezzanine application<\/span><\/h2>\nWe need to define which database server our application is going to use and how to connect to our database – we need to edit the settings.py<\/code> file within our main project directory:<\/p>\nnano mezzanine_project\/settings.py<\/pre>\nNow look for the DATABASES<\/code> block and add the following information about the database we have created in Step 2.<\/p>\nDATABASES = {\r\n \"default\": {\r\n \"ENGINE\": \"django.db.backends.mysql<\/span>\",\r\n \"NAME\": \"mezzanine<\/span>\",\r\n \"USER\": \"mezzanine<\/span>\",\r\n \"PASSWORD\": \"strong-password<\/span>\",\r\n \"HOST\": \"localhost<\/span>\",\r\n \"PORT\": \"\",\r\n }\r\n}<\/pre>\nSave the changes to the file, and exit the nano text editor.<\/p>\n
You will also find the main script for managing projects in this directory, which is called manage.py<\/code>.<\/p>\nWe will use this script to migrate the database and create a new superuser account for our Mezzanine admin interface.<\/p>\n
Let’s migrate the database by running the following commands:<\/p>\n
python manage.py makemigrations\r\npython manage.py migrate<\/pre>\nOutput:<\/p>\n
Operations to perform:\r\nApply all migrations: admin, auth, blog, conf, contenttypes, core, django_comments, forms, galleries, generic, pages, redirects, sessions, sites, twitter\r\nRunning migrations:\r\nApplying contenttypes.0001_initial... OK\r\nApplying auth.0001_initial... OK\r\nApplying admin.0001_initial... OK\r\nApplying admin.0002_logentry_remove_auto_add... OK\r\nApplying contenttypes.0002_remove_content_type_name... OK\r\nApplying auth.0002_alter_permission_name_max_length... OK\r\n.\r\n.\r\n.\r\nApplying redirects.0001_initial... OK\r\nApplying sessions.0001_initial... OK\r\nApplying sites.0002_alter_domain_unique... OK\r\nApplying twitter.0001_initial... OK<\/pre>\nOnce the database is migrated, we can create a new administrative user with this line:<\/p>\n
python manage.py createsuperuser<\/pre>\nEnter the required information in order to create the new admin user:<\/p>\n
Username (leave blank to use 'mezzanine'): admin<\/span>\r\nEmail address: admin@mydomain.com<\/span>\r\nPassword:\r\nPassword (again):\r\nSuperuser created successfully.<\/pre>\nNext, open the following file to edit it:<\/p>\n
nano mezzanine_project\/local_settings.py<\/pre>\nFind the ALLOWED_HOSTS<\/code>\u00a0line and then add the IP address of your server and\/or your domain name.<\/p>\nALLOWED_HOSTS = [\"localhost\", \"127.0.0.1\", \"::1\", \"your-server-IP<\/span><\/strong>\", \"your-domain-name<\/span><\/strong>\"]<\/pre>\nSave the file and exit the nano text editor.<\/p>\n