当前位置: 首页 > 后端技术 > PHP

部署lnmp环境,安装typecho博客

时间:2023-03-29 19:48:07 PHP

安装nginx和PHP环境root@cby:~#aptinstallnginxphp7.4php7.4-mysqlphp7.4-fpm修改nginx配置文件root@cby:~#vim/etc/nginx/sites-available/defaultroot@cby:~#cat/etc/nginx/sites-available/defaultserver{listen80;听[::]:80;#填写域名或IPserver_namewww.oiox.cn;#SSL配置##开启ssl证书监听端口listen443ssl;听[::]:443;#配置证书ssl_certificate/var/www/ssl/www.oiox.cn_nginx/www.oiox.cn_bundle.pem;ssl_certificate_key/var/www/ssl/www.oiox.cn_nginx/www.oiox.cn.key;ssl_session_timeout5m;ssl_ciphersECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;ssl_protocolsTLSv1TLSv1.1TLSv1.2;ssl_prefer_server_ciphers开启;根/var/www/html;#配置默认访问页面indexindex.phpindex.htmlindex.htmindex.nginx-debian.html;#配置访问路径location/{#首先尝试将请求作为文件提供,然后作为目录提供请求,然后退回到显示404。try_files$uri$uri/=404;}#配置跳转路径由if(-f$request_filename/index.html){rewrite(.*)$1/index.htmlbreak;}if(-f$request_filename/index.php){重写(.*)$1/index.php;}if(!-f$request_filename){重写(.*)/index.php;}#配置PHP访问路径由location~\.php${includesnippets/fastcgi-php.conf;#使用php-fpm(或其他unix套接字):fastcgi_passunix:/var/run/php/php7.4-fpm.sock;#使用php-cgi(或其他tcp套接字):#fastcgi_pass127.0.0.1:9000;fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;包括fastcgi_params;fastcgi_intercept_errors开启;}}#配置其他的域名访问服务器{听80;听[::]:80;server_namealiyun.chenby.cn;根/var/www/cby;索引index.html;位置/{try_files$uri$uri/=404;}}root@cby:~#启动服务并设置开机自启动root@cby:~#nginx-troot@cby:~#systemctlrestartnginxroot@cby:~#systemctlenablephp7.4-fpm同步php7状态。4-fpm.service与SysV服务脚本与/lib/systemd/systemd-sysv-install.Executing:/lib/systemd/systemd-sysv-installenablephp7.4-fpmroot@cby:~#root@cby:~#root@cby:~#systemctlenablenginxSynchronizingstateofnginx.servicewithSysVservicescriptwith/lib/systemd/systemd-sysv-install.Executing:/lib/systemd/systemd-sysv-installenablenginxroot@cby:~#安装docker,并使用docker启动MySQL服务root@cby:~#curl-fsSLhttps://get.docker.com|bash-sdocker--mirrorAliyunroot@cby:~#mkdir/mysqlroot@cby:~#cd/mysqlroot@cby:/mysql#dockerrun-p3306:3306--namemymysql--restart=always-v$密码/conf:/etc/mysql/conf.d-v$PWD/logs:/logs-v$PWD/data:/var/lib/mysql-eMYSQL\_ROOT\_PASSWORD=Cby123..-dmysql:5.7#登录MySQL数据库执行创建数据库创建数据库typecho;部署typechoroot@cby:~#cd/var/www/html/root@cby:/var/www/html#wgethttps://typecho.org/downloads/1.1-17.10.30-release.tar.gzroot@cby:/var/www/html#tarxvf1.1-17.10.30-release.tar.gzroot@cby:/var/www/html#mvbuild/*.Linux运维交流社区Linux运维交流社区,互联网新闻和技术交流。75原创内容公众号https://blog.csdn.net/qq\_33921750https://my.oschina.net/u/3981543https://www.zhihu.com/people/...https://segmentfault.com/u/hp...https://juejin.cn/user/331578...https://space.bilibili.com/35...https://cloud.tencent.com/dev...https://www.jianshu.com/u/0f8...https://www.toutiao.com/c/use...知乎、CSDN、开源中国、师傅、掘金、哔哩哔哩、腾讯云、简书、今日头条