部署LNMP动态网站

实现以下功能:(1)配置Nginx实现动静分离
(2)配置数据库,创建账户与密码
步骤一
1.安装LNMP软件包:mariadb,mariadb-server,mairadb-devle,php,php-mysql,php-fpm
安装 nginx 需要先将官网下载的源码进行编译,则需依赖包:gcc,openssl-devle,pcre-devle
共需安装九个软件包.
2.下载nginx完成进行tar解包.执行configure,执行configure时可以根据需求添加相应的模块.例如:with-http_ssl_module(开启SSL加密功能),with-http_stub_status_module(开启status状态页面)在这里插入图片描述
3.进行make编译安装
make && make install
4.启动服务,并设为开机自启.
/usr/local/nginx/sbin/nginx #开启nginx服务
echo “/usr/local/nginx/sbin/nginx” >> /etc/rc.local #设置为开机自启
chmod +x /etc/rc.local #添加执行权限
systemctl restart mariadb #开启nginx服务
systemctl enable mariadb #设为开机自启
systemctl restart php-fpm
systemctl restart php-fpm
用netstat -ltnup查看服务是否开启
5.配置nginx文件,实现动态分离
vim /usr/local/nginx/conf/nginx.conf
…省略部分文件…
location / {
root html;
index index.html index.htm;
} #实现静态网页
…省略部分文件…
ocation ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi.conf; #实现动态网页
6.重新加载配置
/usr/local/nginx/conf/nginx.conf -s reload
步骤二
配置数据库与账户权限
1.在linux中输入mysql进入数据库
MariaDB [(none)]> create database 数据名 character set utf8mb4;
MariaDB [(none)]> grant all on 数据库.* to 用户名@localhost identified by ‘密码’; #添加权限

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值