基于centos搭建reviewboard

基于centos ,apache, mysql 安装 reviewboard 3.0.17

Prepartion

1.CentOS Linux release 8.1.1911 (Core)

2.Samba install

3.dependences install

$ yum install gcc libffi-devel openssl-devel patch
$ sudo yum install python2-devel.x86_64
$ sudo dnf install redhat-rpm-config
$ sudo yum install make

Apache

1.Install Apache

To install Apache on your CentOS server, use the following command:

$ sudo yum install httpd.x86_64

2.Activate Apache

To activate Apache, start its service first.

1.start httpd.service

$sudo systemctl start httpd.service
  1. Next, set the Apache service to start when the system boots:
$sudo systemctl enable httpd.service

3.Verify Apache Service

Display information about Apache, and verify it’s currently running with:

$ sudo systemctl status httpd.service 
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2020-01-27 08:55:21 EST; 1s ago
     Docs: man:httpd.service(8)
 Main PID: 3536 (httpd)
   Status: "Started, listening on: port 80"
    Tasks: 213 (limit: 5030)
   Memory: 17.2M
   CGroup: /system.slice/httpd.service
           ├─3536 /usr/sbin/httpd -DFOREGROUND
           ├─3537 /usr/sbin/httpd -DFOREGROUND
           ├─3538 /usr/sbin/httpd -DFOREGROUND
           ├─3539 /usr/sbin/httpd -DFOREGROUND
           └─3540 /usr/sbin/httpd -DFOREGROUND

Jan 27 08:55:21 soar systemd[1]: Starting The Apache HTTP Server...
Jan 27 08:55:21 soar systemd[1]: Started The Apache HTTP Server.
Jan 27 08:55:21 soar httpd[3536]: Server configured, listening on: port 80

4.Configure firewalld to Allow Apache Traffic

In a standard installation, CentOS 7 is set to prevent traffic to Apache.

Normal web traffic uses the http protocol on Port 80, while encrypted web traffic uses the https protocol, on Port 443.

  1. Modify your firewall to allow connections on these ports using the following commands:
$sudo firewall-cmd --permanent --add-port=80/tcp
$sudo firewall-cmd --permanent --add-port=443/tcp
  1. Once these complete successfully, reload the firewall to apply the changes with the command:
$sudo firewall-cmd --reload

5.Install mod_wsgi

需要先确认是否有安装apxs,若未安装通过httpd-devl 安装

$ whereis apxs
$ sudo yum install httpd-devel.x86_64

安装mod_wsgi

$wget https://pypi.python.org/packages/28/a7/de0dd1f4fae5b2ace921042071ae8563ce47dac475b332e288bc1d773e8d/mod_wsgi-4.5.7.tar.gz
$tar xzf mod_wsgi-4.5.7.tar.gz
$cd mod_wsgi-4.5.7/
$./configure --with-apxs=/usr/bin/apxs --with-python=/usr/bin/python2 
$sudo make && make install
$cd ../

配置http.conf

$ sudo vim /etc/httpd/conf/httpd.conf

添加一行:
LoadModule wsgi_module modules/mod_wsgi.so

MySQL

1.Install MySQL

$ wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.19-1.el8.x86_64.rpm-bundle.tar

$ tar xvf mysql-8.0.19-1.el8.x86_64.rpm-bundle.tar 
$ sudo rpm -ivh mysql-community-common-8.0.19-1.el8.x86_64.rpm
$ sudo rpm -ivh mysql-community-libs-8.0.19-1.el8.x86_64.rpm
$ sudo rpm -ivh mysql-community-client-8.0.19-1.el8.x86_64.rpm 
$ sudo rpm -ivh mysql-community-devel-8.0.19-1.el8.x86_64.rpm
$ sudo rpm -ivh mysql-community-server-8.0.19-1.el8.x86_64.rpm 

2.Install MySQLClient

Must installed dependences before install mysqlclient,you can reference “Prepartion” section

$ sudo pip2 install -U  mysqlclient

3.Config MySQL

1.Reference apache to start mysql service
$ sudo systemctl start mysqld.service 
$ sudo systemctl enable mysqld.service 
$ sudo systemctl status mysqld.service 
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2020-01-27 10:36:00 EST; 28s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
 Main PID: 14388 (mysqld)
   Status: "Server is operational"
    Tasks: 39 (limit: 5030)
   Memory: 243.1M
   CGroup: /system.slice/mysqld.service
           └─14388 /usr/sbin/mysqld

Jan 27 10:35:36 soarnex systemd[1]: Starting MySQL Server...
Jan 27 10:36:00 soarnex systemd[1]: Started MySQL Server.

2.Modify mysql password

第一步:修改配置文件免密码登录mysql

1、进入文件:vi /etc/my.cnf,添加skip-grant-tables

2、重启mysql:
$ sudo systemctl restart mysqld.service 

第二步免密码登录mysql

1、登录:mysql -u root -p

2、提示输入密码按回车进入

3、进入数据库,输入:use mysql;

4、查看root用户信息:select host, user, authentication_string, plugin from user;

5、更新root用户信息,把密码设置为空字符串:update user set authentication_string='' where user='root';

第三步、退出mysql;注释掉/etc/my.cnf文件最后的 skip-grant-tables ;重启mysql

$ sudo systemctl restart mysqld.service 

第四步:设置密码

1、重新开启一个客户端;

2、登录mysql(这时候还是不用输入密码,因为上面已经把密码设置为空字符串了);

3、修改root用户密码:ALTER user 'root'@'localhost' IDENTIFIED BY 'root';
提示如下信息表示修改成功:
Query OK, 0 rows affected (0.04 sec)


4、退出mysql后就可以用密码登录了

第四步的第3点执行容易出现如下信息提示,无法修改密码,请从第一步重复再次执行,(第三步与第四步的执行可以多等一些时间–猜测与时间有关)

You must reset your password using ALTER USER statement before executing this statement

第五步:修改密码策略

设置密码的默认规则:大于8位的包含数字、字符、特殊字符、大小写,此规则可以修改,

如下是MySQL 8.0版本修改密码策略的方法:root密码:root123

mysql>  SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name                        | Value  |
+--------------------------------------+--------+
| validate_password.check_user_name    | ON     |
| validate_password.dictionary_file    |        |
| validate_password.length             | 8      |
| validate_password.mixed_case_count   | 1      |
| validate_password.number_count       | 1      |
| validate_password.policy             | MEDIUM |
| validate_password.special_char_count | 1      |
+--------------------------------------+--------+
7 rows in set (0.02 sec)

mysql> set global validate_password.policy=0;
Query OK, 0 rows affected (0.00 sec)

mysql> set global validate_password.length=1;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name                        | Value |
+--------------------------------------+-------+
| validate_password.check_user_name    | ON    |
| validate_password.dictionary_file    |       |
| validate_password.length             | 4     |
| validate_password.mixed_case_count   | 1     |
| validate_password.number_count       | 1     |
| validate_password.policy             | LOW   |
| validate_password.special_char_count | 1     |
+--------------------------------------+-------+
7 rows in set (0.00 sec)

mysql> ALTER user 'root'@'localhost' IDENTIFIED BY 'root123';
Query OK, 0 rows affected (0.02 sec)

3.使用mysql 管理工具 navicat

https://blog.csdn.net/dabao87/article/details/80571877

4.数据库的备份与恢复

https://www.cnblogs.com/boundless-sky/p/6087976.html

5.Reviewboard mysql 异常恢复
reviewboard可以了, 你试下:
以前的指令是:

https://stackoverflow.com/questions/8843776/mysql-table-is-marked-as-crashed-and-last-automatic-repair-failed MySQL table is marked as crashed and last (automatic?) repair failed

sudo service mysql stop
cd /var/lib/mysql/$DATABASE_NAME
myisamchk -r $TABLE_NAME
myisamchk -r -v -f $TABLE_NAME
sudo service mysql start

Reviewboard

1.Install Reviewboard

sudo pip2 install oauthlib==1.0.1
sudo pip2 install Reviewboard

2.Creating Review Board Site

Must Create reviewboard database and user first.

1.MySQL

In MySQL, before creating your database, make sure that your server is configured to use the UTF-8 encoding for text. In the file my.cnf, add the following settings:

[client]
default-character-set=utf8

[mysqld]
character-set-server=utf8

After making these changes, restart your MySQL server.

Next, start up the mysql command prompt as your root user, and create a new database and user (replacing myuser and myspassword with your desired username and password, respectively):

$ mysql -u root -p
mysql> CREATE DATABASE reviewboard CHARACTER SET utf8;
mysql> CREATE USER 'toney'@'localhost' IDENTIFIED BY 'toney123';
mysql> GRANT ALL PRIVILEGES ON reviewboard.* to 'toney'@'localhost';

Note:
此处reviewboard database 用户可以创建为 reviewboard/reviewboard,便于记忆

2.Install site
$ sudo rb-site install /var/www/review.com

需特别注意如下项:

  • What is the login and password for this database?
  • Create an administrator account
3.Configuration

创建软连接

$ cd /etc/httpd/conf.d
$ sudo ln -s  /var/www/review.com/conf/apache-wsgi.conf review.conf

修改confsettings_local.py

修改
DEBUG=True -- enable debug
DISABLE_FOLLOW_MENU = True    -- disabled follow menu
sudo vim /var/www/review.com/confsettings_local.py


去除Suuport

vim ./lib64/python2.7/site-packages/reviewboard/templates/base/_nav_support_menu.html

  • {% trans "Support" %}
  • 修改目录权限

    $ sudo chown -R apache "/var/www/review.com/data"
    $ sudo chown -R apache "/var/www/review.com/htdocs/media/ext"
    

    安装Apache的时候默认创建apache 用户,访问页面时都是通过此用户访问相关文件,所以需要修改相关文件的权限

    Note:可以通过/etc/httpd/conf/httpd.conf 修改访问用户名

    4.Restart httpd.service
    $ sudo systemctl restart httpd.service
    

    此时可以正常访问reviewboard site.

    你可能感兴趣的:(linux)