<\/span><\/h2>\nFirst, we’re going to need to log into our server using SSH. You can do that by entering this command:<\/p>\n
ssh root@IP_Address -p Port_Number<\/pre>\nRemember to replace “root” with your username if you are not using the root user. Change “IP_Address” and “Port_Number” according to your server’s IP address and port.<\/p>\n
Once you are logged in, you should update all of your packages to their latest available versions, that way we can maximize compatibility and avoid potential version discrepancies:<\/p>\n
# yum update<\/pre>\n<\/span>Step 2: Install Development Tools<\/span><\/h2>\nThe “Development Tools” bundle is required for building Python modules. we can install it by using this command:<\/p>\n
# yum groupinstall 'Development Tools'<\/pre>\n<\/span>Step 3: Install Python 3.6<\/span><\/h2>\nIn order to install Python version 3.6, we need the centos-release-scl<\/code> and epel-release<\/code> repositories. You can install them with this command:<\/p>\n# yum install centos-release-scl epel-release<\/pre>\nOnce that is done, you can then install Python 3.6. Additionally, we will be installing nano<\/code>, a versatile text editor (optional), and Nginx<\/code>, a highly-customizable web server:<\/p>\n# yum install rh-python36 nano nginx<\/pre>\n<\/span>Step 4: Install MariaDB Server<\/span><\/h2>\nInstalling the MariaDB database server is easy, and only requires one command:<\/p>\n
# yum install mariadb-server<\/pre>\nOnce it has finished installing, let’s enable it to run on boot and then start the service.<\/p>\n
# systemctl enable mariadb\r\n# systemctl start mariadb<\/pre>\nAt this point, MariaDB is running, and we are now going to create a password for the root user. Run the following command to create a root password, remove the test database, remove the anonymous user, before finally reloading the privileges.<\/p>\n
# mysql_secure_installation<\/pre>\nWhen prompted, answer the questions below by following the guide.<\/p>\n
Enter current password for root (enter for none): Just press the [Enter] key, since no password is currently set.<\/strong>\r\nSet root password? [Y\/n]: Y<\/strong>\r\nNew password: Enter a new password<\/strong>\r\nRe-enter new password: Repeat the new password<\/strong>\r\nRemove anonymous users? [Y\/n]: Y<\/strong>\r\nDisallow root login remotely? [Y\/n]: Y<\/strong>\r\nRemove test database and access to it? [Y\/n]: Y<\/strong>\r\nReload privilege tables now? [Y\/n]: Y<\/strong><\/pre>\n<\/span>Step 5: Create a Database for Mezzanine<\/span><\/h2>\nLet\u2019s create one using the following commands. First, we need to log into the MariaDB command line interface:<\/p>\n
# mysql -u root -p<\/pre>\nFrom there, we can create our database:<\/p>\n
mysql> create database mezzanine;\r\nQuery OK, 1 row affected (0.00 sec)<\/pre>\nOnce the database has been created, we’ll create a user and provide it with full access to the Mezzanine database:<\/p>\n
mysql> grant all on mezzanine.* to mezzanine@localhost identified by 'Password<\/span>';\r\nQuery OK, 0 rows affected, 1 warning (0.00 sec)<\/pre>\nRemember to flush all privileges so that the changes take effect:<\/p>\n
mysql> flush privileges;\r\nQuery OK, 0 rows affected (0.00 sec)<\/pre>\nThen quit the command line interface.<\/p>\n
mysql> quit<\/pre>\nNOTE:<\/strong>\u00a0You will need to change the password \u2018Password<\/span>\u2019 above to a strong password.<\/p>\n<\/span>Step 6: Create a Mezzanine System User<\/span><\/h2>\nBefore we proceed, let\u2019s create a new user for our Mezzanine installation:<\/p>\n
# adduser mezzanine<\/pre>\nNext, we’ll add this new user to the sudo group:<\/p>\n
# usermod -aG wheel mezzanine<\/pre>\n<\/span>Step 7: Create a Virtual Environment<\/span><\/h2>\nWe will create a virtual environment under the system user that we created earlier:<\/p>\n
# su - mezzanine<\/pre>\nTo enable python3.6 in this shell session, we need to run this command:<\/p>\n
$ scl enable rh-python36 bash<\/pre>\nYou can check the python version now.<\/p>\n
$ python -V<\/pre>\n <\/p>\n
We can now create a virtual environment. The following command will create a virtual environment called “mezzanine”:<\/p>\n
$ python -m venv mezzanine<\/pre>\nTo use the virtual environment, we’ll first need to activate it by issuing this command:<\/p>\n
$ source mezzanine\/bin\/activate<\/pre>\nOnce activated, the shell prompt will look like this:<\/p>\n
<\/p>\n
<\/span>Step 8: Install and Create a Mezzanine Project<\/span><\/h2>\nFirst, we’ll install a Python package called “mezzanine”. This is required for Mezzanine to function properly.<\/p>\n
$ pip install mezzanine<\/pre>\nAfter that, we can create our first Mezzanine project.<\/p>\n
$ mezzanine-project first_project<\/pre>\nThe command above will add a new directory named “first_project”. On your server, you can choose any project name you want. Please remember to follow along with the name change throughout the rest of the tutorial.<\/p>\n
<\/span>Step 9: Configure the Mezzanine Project<\/span><\/h2>\nAt this step, we need to edit the settings.py<\/code> file within our first project directory. We will be using MySQL for our database storage:<\/p>\n$ cd first_project<\/pre>\n$ nano first_project\/settings.py<\/pre>\nLocate the DATABASES block and add the following information about the database we have created earlier.<\/p>\n
DATABASES = {\r\n \"default\": {\r\n \"ENGINE\": \"django.db.backends.mysql\",\r\n \"NAME\": \"mezzanine\",\r\n \"USER\": \"mezzanine\",\r\n \"PASSWORD\": \"Password\",\r\n \"HOST\": \"\",\r\n \"PORT\": \"\",\r\n }\r\n}\r\n<\/pre>\nSave the changes and exit.<\/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\u2019s migrate the database by running the following commands:<\/p>\n
$ python manage.py makemigrations\r\n$ python manage.py migrate\r\n<\/pre>\n <\/p>\n
Once the database is migrated, we can create a new administrative user with the following:<\/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'):\r\nEmail address: me@mydomain.com\r\nPassword:\r\nPassword (again):\r\nSuperuser created successfully.\r\n<\/pre>\nNext, open the following file to edit it:<\/p>\n
$ nano first_project\/local_settings.py<\/pre>\nFind the ALLOWED_HOSTS line and then add the IP address of your server and\/or your domain name.<\/p>\n
ALLOWED_HOSTS = [\"localhost\", \"127.0.0.1\", \"::1\", \"your-server-IP\", \"your-domain-name\"]<\/pre>\nSave the file and exit the nano text editor.<\/p>\n
<\/span>Step 10: Start the Mezzanine Server<\/span><\/h2>\nTo start up and run the Mezzanine server, run the following command:<\/p>\n
$ python manage.py runserver 0.0.0.0:8000<\/pre>\n \nYou will now be able to access the application using your preferred browser at http:\/\/your_server_ip:8000\/<\/code>.<\/p>\n <\/p>\n
You can then access the Mezzanine admin page and log in with your admin user at http:\/\/your_server_ip:8000\/admin<\/code><\/p>\n <\/p>\n
To stop the server from running, you can simply do Ctrl+C.<\/b><\/p>\n<\/span>Step 11: Configure a Reverse Proxy<\/span><\/h2>\nTo manage the Mezzanine CMS application better, we need to install Gunicorn. Gunicorn is a python web server gateway interface HTTP server. It is a pre-fork worker model, ported from Ruby’s Unicorn project. The Gunicorn server is compatible with a broad number of web frameworks, its implementation is simple, it’s light on server resources, and it’s fairly fast. To install it, just run these next few commands.<\/p>\n
$ pip install gunicorn\r\n$ python manage.py collectstatic\r\n$ deactivate\r\n$ exit<\/pre>\nOnce the install has completed, use nano (or your preferred text editor) to create the service file.<\/p>\n
# nano \/etc\/systemd\/system\/gunicorn.service<\/pre>\nWhen the file has opened, set the following values by copying and pasting the following:<\/p>\n
[Unit]\r\nDescription=gunicorn daemon\r\nAfter=network.target\r\n\r\n[Service]\r\nUser=mezzanine\r\nGroup=nginx\r\nWorkingDirectory=\/home\/mezzanine\/first_project\r\nExecStart=\/home\/mezzanine\/mezzanine\/bin\/gunicorn --access-logfile - --workers 3 --bind unix:\/home\/mezzanine\/first_project.sock first_project.wsgi:application\r\n\r\n[Install]\r\nWantedBy=multi-user.target<\/pre>\nRemember to change “first_project” to the name of your Mezzanine project! Close and file and run the next command to reload the services list.<\/p>\n
# systemctl daemon-reload<\/pre>\nNow, we can start-stop-restart Mezzanine CMS application using the systemctl command:<\/p>\n
# systemctl start gunicorn<\/pre>\nIf you want it to run on boot, we’ll need to enable it.<\/p>\n
systemctl enable gunicorn<\/pre>\nGunicorn has now been successfully configured. Now, to access it using your domain name in the web browser, we will install and configure Nginx to proxy pass to Gunicorn.<\/p>\n
Let’s create an Nginx server block file. Make sure that you change your_domain.com<\/span> to your actual domain name.<\/p>\n# nano \/etc\/nginx\/conf.d\/your_domain.com<\/span>.conf<\/pre>\nThen paste the following into the file:<\/p>\n
server {\r\n listen 80;\r\n server_name your_domain.com<\/span>;\r\n\r\nlocation = \/favicon.ico { access_log off; log_not_found off; }\r\n\r\nlocation \/static\/ {\r\n root \/home\/mezzanine\/first_project;\r\n}\r\n\r\nlocation \/ {\r\n proxy_set_header Host $http_host;\r\n proxy_set_header X-Real-IP $remote_addr;\r\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n proxy_set_header X-Forwarded-Proto $scheme;\r\n proxy_pass http:\/\/unix:\/home\/mezzanine\/first_project.sock;\r\n}\r\n}\r\n<\/pre>\nSave and exit once finished. Run the next commands to load the changes, start Nginx, and enable it to start on boot.<\/p>\n
# nginx -t\r\n# systemctl start nginx\r\n# systemctl enable nginx\r\n<\/pre>\nTo give permissions to Nginx to access your Mezzanine CMS application, we have to add the Nginx user to the user group that can run the Mezzanine CMS.<\/p>\n
# usermod -aG mezzanine nginx<\/pre>\nThen, we’ll also need to change the directory permissions of the Mezzanine user’s home.<\/p>\n
# chmod 710 \/home\/mezzanine<\/pre>\nRestart Nginx for the changes to take effect.<\/p>\n
# systemctl restart nginx<\/pre>\nThat’s it, you should be able to access your Mezzanine CMS application at http:\/\/yourdomain.com<\/code> now. Congratulations!<\/strong><\/p>\n \n Of course, you don\u2019t have to Install Mezzanine CMS on CentOS 7 if you use one of our Mezzanine CMS VPS Hosting services<\/a>, in which case you can simply ask our expert Linux admins to install Mezzanine CMS on your VPS for you. They are available 24\u00d77 and will take care of your request immediately.<\/p>\nPS<\/strong><\/span>. If you liked this post on how to install Mezzanine CMS on CentOS 7<\/strong>, please share it with your friends on the social networks using the buttons below or simply leave a reply in the comments sections. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":"In this tutorial, we will show you how to install Mezzanine on CentOS 7 Mezzanine is a free and open-source … <\/p>\n
Read More<\/a><\/p>\n","protected":false},"author":4,"featured_media":30486,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1699,1236,13,1712],"tags":[541,1789,863],"yoast_head":"\nHow to Install Mezzanine CMS on CentOS 7 - RoseHosting<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n \n \n \n \n \n\t \n\t \n\t \n