暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Typecho 1.2.0 部署

原创 Acha 2022-10-28
900

# Typecho 1.2.0 部署

> 环境

- CentOS7.9

- Nginx/1.20.1

- PHP 7.2.34

- mysql-5.7.37



## 初始化系统

```sh
curl -O file.youto.club/Script/init.sh
sh init.sh blog
```

```sh
[root@blog nginx]# cat /script/init.sh
#!/usr/bin/bash
echo "=-=-=- Action -=-=-="
hostnamectl set-hostname $1
echo "# ==> Hostname: " `hostname`

systemctl stop firewalld && systemctl disable firewalld >/dev/null 2>&1
setenforce 0 >/dev/null 2>&1
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
echo "# ==> Stop Firewalld && Selinux"

mkdir /etc/yum.repos.d/bak -p
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo >/dev/null 2>&1
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo >/dev/null 2>&1

yum repolist | grep repolist


echo "# ==>repo"
yum install -y lrzsz tree wget vim net-tools unzip bash-completion git >/dev/null 2>&1

sed -i "s/\#UseDNS no/UseDNS yes/g" /etc/ssh/sshd_config
echo "# ==> SSH "

echo "=-=-=- Done -=-=-="
```



## 准备软件包

- mysql-5.7.37-1.el7.x86_64.rpm.tar

- nginx-1.20.1.tar.gz

- typecho.zip

```sh
mkdir /{repo,software,script}
# MySQl
wget http://file.youto.club/Repo/mysql-5.7.37-1.el7.x86_64.rpm.tar
tar xf mysql-5.7.37-1.el7.x86_64.rpm.tar -c /repo
ls /repo/mysql57_2009_repo/
vim /etc/yum.repos.d/mysql_local.repo
yum repolist

# PHP72
yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum install -y yum-utils
yum-config-manager --enable remi-php72

# typecho
wget https://github.com/typecho/typecho/releases/latest/download/typecho.zip
mv typecho.zip /software/
```

```sh
[root@blog nginx]# cat /etc/yum.repos.d/mysql_local.repo
[mysql57]
name=mysql57
baseurl=file:///repo/mysql57_2009_repo/
gpgcheck=0
enabled=1
```



## MySQL

```sh
yum install -y mysql-server
systemctl enable mysqld
systemctl start mysqld
grep pass /var/log/mysqld.log
mysql -uroot -p
```

```sql
[root@blog nginx]# mysql -uroot -p

mysql> alter user user() identified by 'Admin@123';
Query OK, 0 rows affected (0.00 sec)

mysql> create database typecho;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL ON typecho.* TO 'typecho'@'localhost' IDENTIFIED BY 'Abc@1234';
Query OK, 0 rows affected, 1 warning (0.00 sec)
```



## PHP

```sh
yum install -y php72
php72 -v
yum install -y php72-php-fpm php72-php-mbstring php72-php-mysqlnd
systemctl enable php72-php-fpm.service
systemctl start php72-php-fpm.service
netstat -lntp

rpm -ql php72-php-fpm
vim /etc/opt/remi/php72/php-fpm.d/www.conf
```

```sh
[root@blog nginx]# grep nginx /etc/opt/remi/php72/php-fpm.d/www.conf
user = nginx
group = nginx
```



## Nginx

```sh
yum install -y nginx
wget https://nginx.org/download/nginx-1.20.1.tar.gz

mkdir /html
unzip /software/typecho.zip

cd /etc/nginx/
grep -Ev "#|^$" nginx.conf.default > nginx.conf
vim nginx.conf
mkdir -p /var/log/blog
chown -R nginx.nginx /var/log/blog

nginx -t
chown -R nginx.nginx /html/

systemctl start nginx
```

```nginx
# cat /etc/nginx/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;

server {
listen 80;
root /html;
index index.html index.htm index.php;

if (!-e $request_filename) {
rewrite ^(.*)$ /index.php$1 last;
}

location ~ .*\.php(\/.*)*$ {
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
}

access_log /html/access.log combined;
}

}
```



## 访问


「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论