LNMP搭建静态网页服务器
chattr -i default/.user.ini
LNMP搭建使用
1.安装screen,命令或者操作可以一直运行下去
yum install screen
2.获取及安装 LNMP
wget http://soft.vpser.net/lnmp/lnmp1.6.tar.gz -cO lnmp1.6.tar.gz && tar zxf lnmp1.6.tar.gz && cd lnmp1.6 && ./install.sh lnmp
============================== Check install ==============================
Checking ...
Nginx: OK
MySQL: OK
PHP: OK
PHP-FPM: OK
Clean Web Server src directory...
+------------------------------------------------------------------------+
| LNMP V1.6 for CentOS Linux Server, Written by Licess |
+------------------------------------------------------------------------+
| For more information please visit https://lnmp.org |
+------------------------------------------------------------------------+
| lnmp status manage: lnmp {start|stop|reload|restart|kill|status} |
+------------------------------------------------------------------------+
| phpMyAdmin: http://IP/phpmyadmin/ |
| phpinfo: http://IP/phpinfo.php |
| Prober: http://IP/p.php |
+------------------------------------------------------------------------+
| Add VirtualHost: lnmp vhost add |
+------------------------------------------------------------------------+
| Default directory: /home/wwwroot/default |
+------------------------------------------------------------------------+
| MySQL/MariaDB root password: root |
+------------------------------------------------------------------------+
+-------------------------------------------+
| Manager for LNMP, Written by Licess |
+-------------------------------------------+
| https://lnmp.org |
+-------------------------------------------+
============================== Check ==============================
3.添加虚拟主机
[root@iZwz91gqesu0znselju9vhZ lnmp1.6]# lnmp vhost add
+-------------------------------------------+
| Manager for LNMP, Written by Licess |
+-------------------------------------------+
| https://lnmp.org |
+-------------------------------------------+
4.输入要添加网站的域名
Please enter domain(example: www.lnmp.org): rabidhare.com
Your domain: rabidhare.com
# 询问是否添加更多域名
Enter more domain name(example: lnmp.org *.lnmp.org):
Please enter the directory for the domain: rabidhare.com
5. 设置网站的目录 Enter默认
网站目录不存在的话会创建目录。也可以输入已经存在的目录或要设置的目录(注意如要输入必须是全路径即以/开头的完整路径!!!)。不输入直接回车的话,采用默认目录:/home/wwwroot/域名
Default directory: /home/wwwroot/rabidhare.com:
Virtual Host Directory: /home/wwwroot/rabidhare.com
6.伪静态可以使URL更加简洁也利于SEO,如程序支持并且需要设置伪静态的话,如启用输入 y ,不启用输入 n 回车(注意LNMPA或LAMP模式没有该选择项!)。
Allow Rewrite rule? (y/n) y
Please enter the rewrite of programme,
wordpress,discuzx,typecho,thinkphp,laravel,codeigniter,yii2 rewrite was exist.
(Default rewrite: other):
You choose rewrite: other
7.是否启用pathinfo 不需要pathinfo的网站程序开启pathinfo会访问出现各种问题 默认回车不启用,启用请输入 y 后回车。
Enable PHP Pathinfo? (y/n) y
Enable pathinfo.
8.设置日志,如启用日志输入 y ,不启用输入 n 回车。
Allow access log? (y/n) n
Disable access log.
9.是否添加数据库
Create database and MySQL user with same name (y/n) n
10.添加SSL功能
Add SSL Certificate (y/n) n
Press any key to start create virtul host...
Create Virtul Host directory......
set permissions of Virtual Host directory......
You select the exist rewrite rule:/usr/local/nginx/conf/rewrite/other.conf
Test Nginx configure file......
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Reload Nginx......
Reload service php-fpm done
================================================
Virtualhost infomation:
Your domain: rabidhare.com
Home Directory: /home/wwwroot/rabidhare.com
Rewrite: other
Enable log: no
Create database: no
Create ftp account: no
================================================
11.进入主机目录
[root@iZwz91gqesu0znselju9vhZ lnmp1.6]# cd /home/wwwroot/rabidhare.com
12.上传网站程序
13.上传网站后建议执行,chown www:www -R /path/to/dir 对网站目录进行权限设置
[root@iZwz91gqesu0znselju9vhZ rabidhare.com]# chown www:www -R /home/wwwroot/rabidhare.com/
# 提示可以忽视
chown: changing ownership of ‘/home/wwwroot/rabidhare.com/.user.ini’: Operation not permitted
14伪静态管理
#LNMPA或LAMP可以直接使用网站根目录下放.htaccess 来设置伪静态规则(具体规则可以去程序官网网站找google百度),但是在LNMP下,需要使用Nginx伪静态规则。
#伪静态可以随时添加或删除,如果添加完虚拟主机后忘记或没有添加伪静态,可以通过修改配置文件来添加伪静态。
#虚拟主机配置文件在:/usr/local/nginx/conf/vhost/域名.conf
#伪静态规则文件需要放在/usr/local/nginx/conf/ 下面。
#编辑虚拟主机配置文件,可以使用vi、nano或winscp,后2个工具对新手来说简单些。
[root@iZwz91gqesu0znselju9vhZ rabidhare.com]# cd /usr/local/nginx/conf
vi /nginx.conf
#例如前面我们添加的虚拟主机,打开后前半部分配置会显示如下:
#---------------------------------------------------
server
{
listen 80 default_server reuseport;
#listen [::]:80 default_server ipv6only=on;
server_name _;
index index.html index.htm index.php;
# 修改主机地址文件
root /home/wwwroot/rabidhare.com;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
include enable-php.conf;
location /nginx_status
{
stub_status on;
access_log off;
}
#---------------------------------------------------
15.重新启动 lnmp
[root@iZwz91gqesu0znselju9vhZ ~]# lnmp restart
+-------------------------------------------+
| Manager for LNMP, Written by Licess |
+-------------------------------------------+
| https://lnmp.org |
+-------------------------------------------+
Stoping LNMP...
Stoping nginx... done
Shutting down MySQL. SUCCESS!
Gracefully shutting down php-fpm warning, no pid file found - php-fpm is not running ?
Starting LNMP...
Starting nginx... done
Starting MySQL.. SUCCESS!
Starting php-fpm done
16.查看lnmp 状态
[root@iZwz91gqesu0znselju9vhZ ~]# lnmp status
+-------------------------------------------+
| Manager for LNMP, Written by Licess |
+-------------------------------------------+
| https://lnmp.org |
+-------------------------------------------+
nginx (pid 30843) is running...
php-fpm is runing!
SUCCESS! MySQL running (31349)
最后浏览器访问页面
命令
# 添加主机
lnmp vhost add
# 列出主机列表
lnmp vhost list
# 删除主机
lnmp vhost del
删除网站会先列出当前已有虚拟主机,按提示输入要删除的虚拟主机域名 回车确认。
删除网站会先列出当前已有虚拟主机,按提示输入要删除的虚拟主机域名 回车确认。
当执行chown或chmod对网站目录属主属组或权限进行操作时可能会提示chown: changing ownership of `/home/wwwroot/default/.user.ini': Operation not permitted,不需要理会,如果有强迫症可以参考前面先进行chattr -i的操作。
lnmp start|stop|reload|restart|kill|status
# 重启LNMP
lnmp restart
# LNMP状态查看
lnmp status
LNMP搭建静态网页服务器的更多相关文章
- 【一】Ubuntu14.04+Jekyll+Github Pages搭建静态博客
本系列有五篇:分别是 [一]Ubuntu14.04+Jekyll+Github Pages搭建静态博客:主要是安装方面 [二]jekyll 的使用 :主要是jekyll的配置 [三]Markdown+ ...
- 使用Node.js搭建静态资源服务器
对于Node.js新手,搭建一个静态资源服务器是个不错的锻炼,从最简单的返回文件或错误开始,渐进增强,还可以逐步加深对http的理解.那就开始吧,让我们的双手沾满网络请求! Note: 当然在项目中如 ...
- 搭建LNMP;搭建WIKI
#!/bin/bash#lnmp搭建#搭建WIKI 1.系统检测,系统环境优化 搭建版本: nginx-1.8.1.tar.gzmysql-5.5.32-linux2.6-x86_64.tar.gzl ...
- centos 桥接配置 设置网络代理 lnmp搭建
一.桥接配置 centos设置 编辑->虚拟网络编辑器->桥接模式->还原默认设置 虚拟机->设置->网络适配器->桥接 cd /etc/sysconfig/ne ...
- windows上使用mkdocs搭建静态博客
windows上使用mkdocs搭建静态博客 之前尝试过用HEXO搭建静态博客,最近发现有个叫mkdocs的开源项目也是搭建静态博客的好选择,而且它支持markdown格式,下面简要介绍一下mkdoc ...
- CentOS 6(64-bit) + Nginx搭建静态文件服务器
Nginx搭建静态文件服务器 使用命令打开Nginx配置文件: sudo vim /etc/nginx/conf.d/default.conf 将配置改为: server { ...... ..... ...
- Ubuntu 14.04TLS Nginx搭建静态文件服务器
Nginx搭建静态文件服务器 [官方教程]https://www.nginx.com/resources/admin-guide/serving-static-content/ 打开Nginx的配置文 ...
- 腾讯云-NGINX搭建静态网站
搭建静态网站 搭建Http静态服务器环境 任务时间:15min ~ 30min 搭建静态网站,首先需要部署环境.下面的步骤,将告诉大家如何在服务器上通过 Nginx 部署 HTTP 静态服务. 00. ...
- 使用github和hexo搭建静态博客
获得更多资料欢迎进入我的网站或者 csdn或者博客园 终于写这篇文章了,这是我使用github和hexo搭建博客的一些心得,希望能给大家一点帮助.少走点弯路.刚接触github,只是用来存项目的版本, ...
- 在GitHub上使用Hexo搭建静态博客
搭建静态博客须要一个前提是电脑上有安装git而且有github帐号,这个不懂能够看廖雪峰先生的git教程 1.下载nodejs.在官网上能够下载 2.使用git进入你新建的一个目录,输入命令 npm ...
随机推荐
- 使用SecureCRT通过SSH连接远程Linux设备
Ubuntu安装和配置ssh教程 https://blog.csdn.net/future_ai/article/details/81701744 以SecureCRT为例: 把电脑和设备连接在同一个 ...
- 剑指offer-孩子们的游戏
题目描述:每年六一儿童节,牛客都会准备一些小礼物去看望孤儿院的小朋友,今年亦是如此.HF作为牛客的资深元老,自然也准备了一些小游戏.其中,有个游戏是这样的:首先,让小朋友们围成一个大圈.然后,他随机指 ...
- vite设置跨域
1. vite.config.ts或者vite.config.js文件 server: { port: 3001, host: '0.0.0.0', open: true, proxy: { // 代 ...
- 用反证法说明List<Object>和List<String>不存在子父类关系可行吗?
看宋红康老师的Java基础视频讲解,视频中用反证法证明List
- java获取类内容
java获取类内容 Book类 public class Book implements Serializable { private int id; private String name; pri ...
- 微信小程序按下去的样式
微信小程序设置 hover-class,实现点击态效果 目前支持 hover-class 属性的组件有三个:view.button.navigator. 不支持 hover-class 属性的组件,同 ...
- 2020.11.24 typeScript命名空间
命名空间:定义了标识符的可见范围,一个标识符可以在多个命名空间中定义,它在不同命名空间的含义是互不相干的.在一个新的命名空间可以定义任何新的标识符,它不会与已有的任何标识符发生冲突. 使用: 这个时候 ...
- ssh双击互信
默认公钥文件/root/.ssh/id_rsa.pub默认私钥文件/root/.ssh/id_rsa 只有将公钥文件文件拷到其他的服务器上才能登录别的服务器. 服务器A 192.168.1.133 ...
- Linux开发——spi总线学习
1 spi总线协议简介 1.1 基本概念 SPI(Serial pe)
- 使用 SpeechT5 进行语音合成、识别和更多功能
我们很高兴地宣布,SpeechT5 现在可用于 Transformers (一个开源库,提供最前沿的机器学习模型实现的开源库). SpeechT5 最初见于微软亚洲研究院的这篇论文 SpeechT5: ...