部署lnmp

1)安装软件包
[root@centos7 ~]# yum -y install gcc openssl-devel pcre-devel
#gcc支持编译C语言,openssl-devel支持链接数据库,pcre-devel是支持包括 perl 兼容的正规表达式库
[root@centos7 ~]# useradd -s /sbin/nologin nginx
#添加用户nginx,登录的解释器是/sbin/nologin,提高安全
[root@centos7 ~]# tar -xvf nginx-1.12.2.tar.gz
#解压nginx源码包,-v显示详细信息
[root@centos7 ~]# cd nginx-1.12.2
[root@centos7 nginx-1.12.2]# ./configure
–user=nginx --group=nginx
–with-http_ssl_module
–with-http_stub_status_module
#–user=nginx --group=nginx指定用户和组都是nginx
–with-http_ssl_module 安装加密模块
–with-http_stub_status_module安装监控模块

[root@centos7 nginx-1.12.2]# make && make install#编译及安装
[root@centos7 ~]# yum -y install mariadb mariadb-server mariadb-devel
#mariadb是数据库的客户端软件
#mariadb-server是数据库的服务器软件
#mariadb-devel是依赖包(红帽或centos系统中以devel结尾的软件都是依赖)

[root@centos7 ~]# yum -y install php php-mysql php-fpm
#php是解释器
#php-fpm是让PHP支持fastcgi的扩展
#php-mysql是让PHP可以连接使用mysql数据库的扩展

2)启动服务(nginx、mariadb、php-fpm)
[root@centos7~]/usr/local/nginx/sbin/nginx#启动nginx服务
[root@centos7 ~]# echo “/usr/local/nginx/sbin/nginx” >> /etc/rc.local #nginx开机自启
[root@centos7 ~]# chmod +x /etc/rc.local*#添加执行权限*
[root@centos7 ~]# ss –ntulp |grep :80*#查看80端口*
[root@centos7 ~]# systemctl start mariadb #启动mariadb服务
[root@centos7 ~]# systemctl enable mariadb*#mariadb开机自启*
[root@centos7 ~]# systemctl start phpfpm #启动php服务
[root@centos7 ~]# systemctl enable php-fpm*#php开机自启*
3)修改Nginx配置文件,实现动静分离
[root@centos7 ~]# vim /usr/local/nginx/conf/nginx.conf
修改内容如下:
location / {
root html;
index index.php index.html index.htm;#加入动态页面
}
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;#修改文件为.conf结尾
}
4)配置数据库账户与权限
[root@centos7 ~]# mysql
#进入mariadb数据库
MariaDB [(none)]> create database wordpress character set utf8mb4;
#create创建数据库 名字是WordPress utf8mb4支持中文
MariaDB [(none)]> grant all on wordpress.* to wordpress@‘localhost’ identified by ‘wordpress’;
#grant all on授权 名字是wordpress的数据库本地登录
MariaDB [(none)]> grant all on wordpress.* to wordpress@‘192.168.2.11’ identified by ‘wordpress’;
#grant all on授权 主机名是WordPress,密码是WordPress,主机是192.168.2.11 远程登录
MariaDB [(none)]> flush privileges;#刷新配置
MariaDB [(none)]> exit
5)上线wordpress代码
[root@centos7 ~]# yum -y install unzip*#安装unzip软件包*
[root@centos7 ~]# unzip wordpress.zip #解压zip包
[root@centos7 ~]# cd wordpress #进入相对路径,
[root@centos7 wordpress]# tar -xf wordpress-5.0.3-zh_CN.tar.gz#解压
[root@centos7 wordpress]# cp -r wordpress/* /usr/local/nginx/html/
#直接拷贝目录到/usr/local/nginx/html/下,/usr/local/nginx/html/是nginx网页的家目录
[root@centos7 wordpress]# chown -R apache.apache /usr/local/nginx/html/
#添加属主和所属组
6)进行数据库初始化
WordPress是一款博客平台,我们的lnmp网站可以部署在上面

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值