在CentOS7上部署Ghost2博客系统

时间:2022-09-14 15:09:07

CentOS7版本:CentOS-7-x86_64-DVD-1810

Ghost版本:2.23.4

系统先update


1.adduser alex
2.passwd alex
3.vi /etc/sudoers
4.yum -y install epel-release
yum -y install nginx
5.systemctl stop firewalld
6.sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
sudo yum-config-manager --disable mysql80-community
sudo yum-config-manager --enable mysql57-community
yum -y install mysql-community-server
systemctl start mysqld.service
sudo grep 'temporary password' /var/log/mysqld.log
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Tong0715@';
7.curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -
sudo yum -y install nodejs
node --version
//sudo yum install gcc-c++ make
8.sudo npm install ghost-cli@latest -g
9.sudo mkdir -p /home/wwwroot/ghost
sudo chown <user>:<user> /home/wwwroot/ghost
sudo chmod 775 /home/wwwroot/ghost
cd /home/wwwroot/ghost
10.ghost install
If an install is interrupted or the connection lost, use "ghost setup" to restart the configuration process.
11.sudo systemctl start ghost_localhost
sudo systemctl restart nginx

反向代理(引用自https://qizhanming.com/blog/2018/08/06/how-to-install-nginx-on-centos-7)

需要指出的是 CentOS 7 的 SELinux,使用反向代理需要打开网络访问权限。

$ sudo setsebool httpd_can_network_connect 1
打开网络权限之后,反向代理可以使用了。

 location / {
         proxy_pass http://127.0.0.1:2368;
         proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
         proxy_redirect off;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header Host $http_host;
         proxy_set_header X-NginX-Proxy true;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header X-Forwarded-Proto $scheme;          
        }