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 ...
随机推荐
- 位运算与MOD快速幂详细知识点
最近写的一些题目设计到了数论的取模 如下题 链接:https://ac.nowcoder.com/acm/contest/3003/G来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制: ...
- datax-web踩坑记录
实习期间接触了两种ETL工具:kettle.datax 1.datax-web的安装 (跟着文档一步步来就好了) https://github.com/WeiYe-Jing/datax-web/blo ...
- Blog作业03
目录 前言 设计与分析 踩坑心得 改进建议 总结 前言 这三次作业的题目只有2道题,但是在题量减小的同时,这三次作业集的难度也相应的上去了,题目的质量很好,运用很广泛,也考验了很多的知识点.这三次的作 ...
- hive --service metastore 启动报错
1.问题示例: [Hadoop@master Hive]$ hive --service metastore2021-10-28 15:37:57: Starting Hive Metastore S ...
- 《Unix/Linux系统编程》第九周学习笔记
<Unix/Linux系统编程>第九周学习笔记 信号和中断 中断"是从I/O设备或协处理器发送到CPU的外部请求,它将CPU从正常执行转移 到中断处理.与发送给CPU的中断请求一 ...
- [复现]DASCTF Sept X 浙江工业大学秋季挑战赛-PWN
hehepwn 一开始泄露stack地址,然后写入shellcode返回到shellcode执行 from pwn import * context.os = 'linux' context.log_ ...
- SpringBoot——实现WebService接口服务端以及客户端开发
参考:https://blog.csdn.net/qq_43842093/article/details/123076587 https://www.cnblogs.com/yinyl/p/14197 ...
- Java笔记第三弹
Map集合的获取功能 V get(Object key);//根据键获取值 Set<K> keySet();//获取所有键的集合 Collection<K> values(); ...
- Spring--案例:百度网盘密码数据兼容处理
案例再度来袭 也就是说,在百度网盘的密码复制时,后面即使有空格也能提取成功(trim方法) 案例的实现: 也就是实现存在空格时,也能输出true: 现在的话: 那么,我们应该如何使得它忽略空格呢? 这 ...
- JS兼容问题总结
JS兼容问题总结 "标准浏览器"和"低版本浏览器(IE)"兼容写法 一.浏览器卷去的高度和宽度 var scrollTop = document.documen ...