JABZ7SHOP : Web Selling Things With Cheap Price : https://jabz7shop.blogspot.com/ : Go To My Shop Online Now
Bài đăng

Install Flarum in Centos 7 Nginx

3 min read

 

1. Installing Nginx

yum install epel-release -y
yum install nginx -y
systemctl start nginx
systemctl enable nginx

2. Installing MariaDB

yum install mariadb-server mariadb -y
systemctl start mariadb
systemctl enable mariadb

Sau khi cài xong thì chạy lệnh sau để cài đặt pass root cho MySQL:
mysql_secure_installation

3. Installing PHP 7

wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm
yum install yum-utils -y
yum-config-manager --enable remi-php71
yum --enablerepo=remi,remi-php71 install php-fpm php-common
yum --enablerepo=remi,remi-php71 install php-opcache php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongodb php-pecl-redis php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml

4. Configuring firewall (tùy VPS nữa)

yum firewall-cmd --zone=public --permanent --add-service=http
yum firewall-cmd --zone=public --permanent --add-service=mysql
yum firewall-cmd --zone=public --add-port=3306/tcp (only to make sure mysql port is open)
firewall-cmd --reload

5. Configuring Flarum to nginx

Tạo cấu hình nginx tại:
/etc/nginx/conf.d/
Ví dụ:
/etc/nginx/conf.d/myflarum.conf
và bỏ code này vào:

server {
    listen   80;
    server_name  yourdomain.com www.yourdomain.com;
 
# note that these lines are originally from the "location /" block
root   /usr/share/nginx/YOURFOLDERSITE;
index index.php index.html index.htm;

location / { try_files $uri $uri/ /index.php?$query_string; }
location /api { try_files $uri $uri/ /api.php?$query_string; }
location /admin { try_files $uri $uri/ /admin.php?$query_string; }

location /flarum {
    deny all;
    return 404;
}

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

location ~* \.html$ {
    expires -1;
}

location ~* \.(css|js|gif|jpe?g|png)$ {
    expires 1M;
    add_header Pragma public;
    add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}

gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types application/atom+xml
           application/javascript
           application/json
           application/vnd.ms-fontobject
           application/x-font-ttf
           application/x-web-app-manifest+json
           application/xhtml+xml
           application/xml
           font/opentype
           image/svg+xml
           image/x-icon
           text/css
           #text/html -- text/html is gzipped by default by nginx
           text/plain
           text/xml;
gzip_buffers 16 8k;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
   }

Sau khi làm xong thì:
systemctl restart nginx### 6. Configuring Php-fpm to work in nginx

Go to:

/etc/php-fpm.d/www.conf
Bạn sẽ cần phải sửa lại những đoạn sau

user = apache to user = nginx
group = apache to group = nginx
listen.owner = nobody to listen.owner = nginx
listen.group = nobody to listen.group = nginx

Finally check if ;listen = 127.0.0.1:9000 is without ;

When you finish:

systemctl start php-fpm.service
systemctl enable php-fpm.service

7. Installing composer

cd /tmp
sudo curl -sS https://getcomposer.org/installer | php

And for finish

mv composer.phar /usr/local/bin/composer

8. Installing FLARUM

Go to

cd /usr/share/nginx/YOURFOLDER
And use:

composer create-project flarum/flarum . --stability=beta
Correct Permissions

chown -R nginx: /usr/share/nginx/YOURFOLDER
chown -R nginx: /var/lib/php

9. Creating one database for flarum

First:

mysql -u root -p
and enter your password.

When logged:

CREATE DATABASE forumcuaban;

10. Now you can start install flarum

00:00 / 00:00

Bạn có thể thích những bài đăng này

Đăng nhận xét