yum安装 lnmp (linux+nginx+php7.1+mysql5.7)
1、第一步先更新yum update
只适合新服务器,生成环境慎用
2、yum安装nginx
安装nginx最新源:
yum localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum repolist enabled | grep "nginx*"
安装nginx:
yum -y install nginx
启动nginx:
service nginx start
设置nginx服务器开机自启动:
systemctl enable nginx.service
检查开机自动是否设置成功:
systemctl list-dependencies | grep nginx
3、yum安装mysql5.7
安装mysql源:
yum -y localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
yum repolist enabled | grep "mysql.-community."
安装mysql:
yum -y install mysql-community-server mysql-community-devel
启动mysql:
service mysqld start
检查mysql启动是否正常:
service mysqld status 或者 ps -ef | grep mysql
设置mysqld服务开机自启动:
systemctl enable mysqld.service
检查mysqld开机自启动是否设置成功:
systemctl list-dependencies | grep mysqld
查看密码和修改密码
查看mysql的root账号的密码 grep ‘temporary password‘ /var/log/mysqld.log
登录mysql mysql -uroot -p
修改密码 ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘password‘;
修改root用户可远程登录 GRANT ALL PRIVILEGES ON . TO ‘root‘@‘%‘ IDENTIFIED BY ‘password‘ WITH GRANT OPTION;
刷新 flush privileges;
4、yum安装php7.1
安装php源:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
检查源是否安装成功;
yum repolist enabled | grep "webtatic*"
安装php扩展源:
yum -y install php71w php71w-fpm
yum -y install php71w-mbstring php71w-common php71w-gd php71w-mcrypt
yum -y install php71w-mysql php71w-xml php71w-cli php71w-devel
yum -y install php71w-pecl-memcached php71w-pecl-redis php71w-opcache
验证php7.1.x和扩展是否安装成功 :
验证php是否安装成功
php -v
验证对应的扩展是否安装成功
php -m
设置php-fpm并检测php-fpm的运行状态:
启动php-fpm
service php-fpm star
检查启动是否成功
service php-fpm status
设置开机自启动:
systemctl enable php-fpm.service
检查开机自启动是否设置成功:
systemctl list-dependencies | grep php-fpm
ps -ef | grep php-fpm
################################################
5.单独安装redis
yum install redis
修改配置
vi /etc/redis.conf
daemonize yes 后台运行
appendonly yes 数据持久化
service redis start
6.安装php-redis扩展
先装git
yum install git
git下扩展
cd /usr/local/src
git clone https:#github.com/phpredis/phpredis.git
安装扩展
cd phpredis
phpize
修改php配置
vi /etc/php.ini 添加extension=redis.so
重启php
service php-fpm restart
下载typecho
typecho最新正式版
nginx的配置:
nginx.conf 修改user为nginx
[[email protected] nginx]# cat conf.d/web.conf
server {
listen 80;
server_name xxxx;
#rewrite ^(.*) https://wangwei520.top$1 permanent;
root /data/server/;
location / {
index index.php;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?_url=$1 last;
}
}
#解决跨域问题
location ~* \.(eot|ttf|woff)$ {
add_header Access-Control-Allow-Origin ‘*‘;
}
location ~ \.php(.*)$ {
root /data/server/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
location ~ ^/(status|ping)$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
}
}
htpps有cdn的就把域名解析到cdn 使用cdn的htpps 没有的自己去免费网站申请htpps按照教程来搭建 看个人需求是否需要htpps
上传typeho到网站根目录解压
tar zxvf 1.1-17.10.30-release.tar.gz
mv build/* .
chown -R nginx:nginx . 修改权限
Typecho启用https访问的实现方法与教程
登录Typecho后台 -> 设置 -> 基本设置 -> 站点地址改成https的域名是必须的。
编辑Typecho站点根目录下的文件config.inc.php加入下面一行配置,否则网站后台还是会调用HTTP资源。
/ 开启HTTPS */
define(‘TYPECHO_SECURE‘,true);
由于Chrome浏览器对HTTPS要求较高,Firefox已经显示小绿锁,可是Chrome还是有警告提示,F12查看,评论表单的action地址还是http,找到站点主题目录下的 comments.php 文件,并搜索 $this->commentUrl(),将其替换为:echo str_replace("http","https",$this->commentUrl()); 最后保存。
nginx -t 检查配置是否正确 nginx -s reload 从新加载
创建数据库创建typecho
安装typeho
ip/install.php 按照提示进行操作 也可以域名/install.php 前提是自己的域名以及解析或者配置htpps
后台配置
ip/admin
设置里面基本配置: 站点地址 填写网站地址htpp 还是htpps
控制台外观:
https://typecho.me 自己去这里面下载到/usr/themes
然后去外观里面点击启用
一些小的插件也可以去下载: 下载到/usr/plugins
https://www.typechodev.com/plugins/
分类:
可以创建不同的分类来 撰写不同题材的文章
原文地址:https://blog.51cto.com/12328206/2428358