Deploy the open-source blog system Blog_mini on Ubuntu

Source: Internet
Author: User

Deploy the open-source blog system Blog_mini on Ubuntu

0. Description

This article is the official deployment document for the open-source blog system Blog_mini. After reading this article, you will be able to fully deploy Blog_mini on a brand new CentOS system, thus successfully setting up your personal blog website.

The operating system used here is Ubuntu 15.10. Theoretically, Blog_mini can be successfully deployed as long as the Python version installed on the operating system is 2.6.x or 2.7.x.

1. Obtain Blog_mini source code

You can obtain the source code of Blog_mini in the following two ways:

Using git

Download from the Blog_mini project Homepage

We will introduce these two methods. In practice, you only need to select one of them. We recommend the first method.

(1) Get the source code through git

First, make sure that your system has installed the git version control system:

[Email protected]: ~ $ The gitversion program "git" has not been installed yet. Run the following command to install sudoapt-getinstallgit:

If no installation is available, install it using apt-get:

[Email protected]: ~ $ Sudoapt-getinstallgit [sudo] xpleaf password:

After the installation is complete, create a project directory in the user directory:

[email protected]:~$mkdirproject[email protected]:~$cdproject/[email protected]:~/project$

Clone the source code from the Blog_mini Project address:

[email protected]:~/project$gitclonehttps://github.com/xpleaf/Blog_mini

If the network condition is good, the code can be cloned soon.

View the Blog_mini source code directory structure:

[email protected]:~/project/Blog_mini$lsappLICENSEmigrationsREADME.mdrequirements.txtconfig.pymanage.pyProcfilerequirements

(2) download the source code from the Blog_mini project homepage.

If you want to obtain the Blog_mini source code in this way, you 'd better perform operations in the operating system on the GUI, for example, you can download it from a Windows, Mac, or Linux operating system with a GUI, and then upload it to our CentOS operating system.

Go to the project homepage:

Https://github.com/xpleaf/Blog_mini

Click Download ZIP.

The downloaded file name should be: Blog_mini-master.zip

After the download is complete, decompress the package and upload it to the Ubuntu operating system. The method (1) Under the source code directory structure of Blog_mini is the same.

2. Install pip

Run the following command to install the SDK:

[email protected]:~/project/Blog_mini$sudoapt-getinstallpython-pip

3. Install virtualenv

Run the following command to install the SDK:

[email protected]:~/project/Blog_mini$sudoapt-getinstallvirtualenv

If the above Command says that virtualenv cannot be found, use the following command:

[email protected]:~/project/Blog_mini$sudoapt-getinstallpython-virtualenv

4. Create a virtual environment venv

Run the following command in the Blog_mini directory:

[email protected]:~/project/Blog_mini$virtualenvvenvRunningvirtualenvwithinterpreter/usr/bin/python2Newpythonexecutableinvenv/bin/python2Alsocreatingexecutableinvenv/bin/pythonInstallingsetuptools,pip...done.

A venv directory is generated under Blog_mini:

[email protected]:~/project/Blog_mini$lsappLICENSEmigrationsREADME.mdrequirements.txtconfig.pymanage.pyProcfilerequirementsvenv

5. Activate the virtual environment venv

In the Blog_mini directory:

[email protected]:~/project/Blog_mini$sourcevenv/bin/activate(venv)[email protected]:~/project/Blog_mini$

Check the prompt changes.

6. Install the Blog_mini requirement File

Run the following command:

(venv)[email protected]:~/project/Blog_mini$pipinstall-rrequirements/common.txt

It takes some time to install some extension packages required by Blog_mini. Of course, if the network is good, the installation can be completed soon.

Let's take a look at this step. In addition to the database configuration, all the Blog_mini requirement environments have been set up. Next we need to complete one of the following two:

Use sqlite as the default database to run Blog_mini

Use MySQL as the default database to run Blog_mini

You only need to use one of the databases.

If you are a newbie or you just want to quickly build a Blog_mini-based blog website, you can choose the first one because you do not need to make any configuration.

If you know more about MySQL installation and use, and want to achieve better performance, you can choose the second one.

Of course, I will also provide detailed usage instructions below.

7. Use sqlite as the default database to run Blog_mini

Python itself comes with the sqlite database. Therefore, if you want to use sqlite as the default database, you do not need to make any configuration.

The next step is to run Blog_mini.

To generate the default system data required by Blog_mini, run the following command in the Blog_mini directory:

(venv)[email protected]:~/project/Blog_mini$pythonmanage.pydeployproductINFO[alembic.runtime.migration]ContextimplSQLiteImpl.INFO[alembic.runtime.migration]Willassumenon-transactionalDDL.INFO[alembic.runtime.migration]Runningupgrade->051691f120e6,fittoMySQL

If the above prompt appears, it means the operation is successful! You don't have to worry about the 'fit to mysql' at the end. This is just a note at the time. It is also useful to indicate that you want to use MySQL later. It doesn't make much sense.

View the generated sqlite database:

(venv)[email protected]:~/project/Blog_mini$lsappconfig.pycLICENSEmigrationsREADME.mdrequirements.txtconfig.pydata.sqlitemanage.pyProcfilerequirementsvenv

You can see an additional data. sqlite file. This file is the sqlite database file!

Run Blog_mini:

(venv)[email protected]:~/project/Blog_mini$gunicornmanage:app[2016-03-0811:49:11+0000][7189][INFO]Startinggunicorn19.4.5[2016-03-0811:49:11+0000][7189][INFO]Listeningat:http://127.0.0.1:8000(7189)[2016-03-0811:49:11+0000][7189][INFO]Usingworker:sync[2016-03-0811:49:11+0000][7194][INFO]Bootingworkerwithpid:7194

The above prompt indicates that Blog_mini has been successfully run! However, this running mode can only be accessed on port 8000 of the Local Machine. If your Ubuntu operating system does not have a GUI, you cannot access it on the local machine, so we can run it in the following way.

Run Blog_mini on port 80:

(venv)[email protected]:~/project/Blog_mini$gunicorn-b0.0.0.0:80manage:app[2016-03-0811:50:43+0000][7202][INFO]Startinggunicorn19.4.5[2016-03-0811:50:43+0000][7202][INFO]Listeningat:http://0.0.0.0:80(7202)[2016-03-0811:50:43+0000][7202][INFO]Usingworker:sync[2016-03-0811:50:43+0000][7207][INFO]Bootingworkerwithpid:7207

In this case:

If you deploy Blog_mini on a server with a public IP address, you only need to enter your public IP address in the browser of any host on the Internet to access Blog_mini.

If you only deploy Blog_mini on the LAN, you can enter the IP address of your host in the browser of any host on the LAN.

However, if the access fails, it may be a firewall problem. You can first turn off the Firewall:

[Email protected]: ~ $ Sudoufwdisable [sudo] xpleaf password:

Since the bloggers first learned about network engineering, if you encounter any problems in network communication, you can reply to me and I will answer them one by one.

In this step, you have successfully deployed the Blog_mini server, and then you can operate your personal blog website! Blog_mini has powerful functions, but it is very easy to use. You can refer to the blog post about Blog_mini to learn about its functions. Of course, you can also explore it on your own, I believe this is very easy for you!

You must note that Blog_mini supports background management (you can click the 'background management' logon link at the bottom of the home page to go To the logon page). below is the default account password for the Blog_mini Management Background:

Account: [email protected]

Password: blog_mini

Tip: After Blog_mini is deployed, there is no data in it. If you need some data to test the Blog_mini function, you can execute the following command after completing the above operation:

(venv)[email protected]:~/project/Blog_mini$pythonmanage.pydeploytest_data

This will generate 100 blog posts and 700 comments, as well as the blog classification and System navigation, so that you can easily verify the Blog_mini function.

8. Use MySQL as the default database to run Blog_mini

(1) install and configure MySQL

This step continues Step 1. We will use the MySQL database. before performing the following steps, make sure that the MySQL database has been installed and configured on your system. If you have not installed it and do not know how to install it, you can use either of the following methods:

Install MySQL using apt-get

Install MySQL through source code

The first method is relatively simple, but the blogger also wrote a blog post to introduce the process of installing MySQL using yum. You can see the address here: Install MySQL + Security optimization with apt-get on Ubuntu

Although there are many steps, the second method is also easy to implement. The blogger wrote a complete blog, including detailed steps for installing and configuring MySQL: install MySQL + installation problem solving + Security Optimization on Ubuntu source code

New users can directly use the first method. Of course, they feel that they can accept the challenge. You can also use the second method!

After installing and configuring MySQL, perform the following operations.

(2) install the MySQL function library of Python

Install the necessary function libraries for python:

(venv)[email protected]:~/project/Blog_mini$sudoapt-getinstallpython-devlibmysqlclient-dev

Install MySQL-python:

(venv)[email protected]:~/project/Blog_mini$pipinstallMySQL-python……SuccessfullyinstalledMySQL-pythonCleaningup...

Check whether the installation is successful.

(3) create a database for Blog_mini

Exit the virtual environment and return to the user's home directory:

(venv)[email protected]:~/project/Blog_mini$deactivate[email protected]:~/project/Blog_mini$cd[email protected]:~$

Log on to the MySQL database (ensure that the MySQL service is enabled first ):

[[email protected]~]#mysql-uroot-pEnterpassword:mysql>

Create a database for Blog_mini:

mysql>createdatabaseblog_minidefaultcharactersetutf8collateutf8_general_ci;QueryOK,1rowaffected(0.04sec)mysql>showdatabases;+--------------------+|Database|+--------------------+|information_schema||blog_mini||mysql||performance_schema|+--------------------+4rowsinset(0.04sec)

Here we have created a database named 'blog _ mini ', and the encoding and character set are utf8 and utf8_general_ic, respectively.

(4) Create Database Path Environment Variables

Blog_mini's source code specifies the database path to be obtained by reading the environment variable DATABASE_URL. Therefore, we need to set an environment variable named DATABASE_URL for the system and specify the value as the path of the MySQL database.

Set system environment variables:

[email protected]:~$exportDATABASE_URL=mysql://root:[email protected]/blog_mini

The database path used here is: mysql: // root: [email protected]/blog_mini. Among them, 123456 is the password, and others are easy to know.

Verify system environment variables:

[email protected]:~$echo$DATABASE_URLmysql://root:[email protected]/blog_mini

The above output indicates that our settings are correct.

(5) initialize Blog_mini system default data

First, we need to initialize the system default data required by Blog_mini to ensure that the subsequent Blog_mini runs correctly.

Enter the project/Blog_mini directory and initialize the virtual environment:

[email protected]:~$cdproject/Blog_mini/[email protected]:~/project/Blog_mini$sourcevenv/bin/activate(venv)[email protected]:~/project/Blog_mini$

Initialize Blog_mini system default data:

(venv)[email protected]:~/project/Blog_mini$pythonmanage.pydeployproductINFO[alembic.runtime.migration]ContextimplMySQLImpl.INFO[alembic.runtime.migration]Willassumenon-transactionalDDL.INFO[alembic.runtime.migration]Runningupgrade->051691f120e6,fittoMySQL

(6) Run Blog_mini

Run Blog_mini:

(venv)[email protected]:~/project/Blog_mini$gunicornmanage:app[2016-03-0811:49:11+0000][7189][INFO]Startinggunicorn19.4.5[2016-03-0811:49:11+0000][7189][INFO]Listeningat:http://127.0.0.1:8000(7189)[2016-03-0811:49:11+0000][7189][INFO]Usingworker:sync[2016-03-0811:49:11+0000][7194][INFO]Bootingworkerwithpid:7194

The above prompt indicates that Blog_mini has been successfully run! However, this running mode can only be accessed on port 8000 of the Local Machine. If your Ubuntu operating system does not have a GUI, you cannot access it on the local machine, so we can run it in the following way.

Run Blog_mini on port 80:

(venv)[email protected]:~/project/Blog_mini$gunicorn-b0.0.0.0:80manage:app[2016-03-0811:50:43+0000][7202][INFO]Startinggunicorn19.4.5[2016-03-0811:50:43+0000][7202][INFO]Listeningat:http://0.0.0.0:80(7202)[2016-03-0811:50:43+0000][7202][INFO]Usingworker:sync[2016-03-0811:50:43+0000][7207][INFO]Bootingworkerwithpid:7207

In this case:

If you deploy Blog_mini on a server with a public IP address, you only need to enter your public IP address in the browser of any host on the Internet to access Blog_mini.

If you only deploy Blog_mini on the LAN, you can enter the IP address of your host in the browser of any host on the LAN.

However, if the access fails, it may be a firewall problem. You can first turn off the Firewall:

[Email protected]: ~ $ Sudoufwdisable [sudo] xpleaf password:

Since the bloggers first learned about network engineering, if you encounter any problems in network communication, you can reply to me and I will answer them one by one.

In this step, you have successfully deployed the Blog_mini server, and then you can operate your personal blog website! Blog_mini has powerful functions, but it is very easy to use. You can refer to the blog post about Blog_mini to learn about its functions. Of course, you can also explore it on your own, I believe this is very easy for you!

You must note that Blog_mini supports background management (you can click the 'background management' logon link at the bottom of the home page to go To the logon page). below is the default account password for the Blog_mini Management Background:

Account: [email protected]

Password: blog_mini

Tip: After Blog_mini is deployed, there is no data in it. If you need some data to test the Blog_mini function, you can execute the following command after completing the above operation:

(venv)[[email protected]_mini]#pythonmanage.pydeploytest_data

This will generate 100 blog posts and 700 comments, as well as the blog classification and System navigation, so that you can easily verify the Blog_mini function.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.