LNMP四部曲
①Linux,操作系统
②Nginx,网页服务器
③MariaDB或MySQL,数据库管理系统(或者数据库服务器)
④PHP、Perl或Python,脚本语言
搭建LNMP环境
Nginx安装及配置
配置nginx源
[root@localhost ~]# rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
安装nginx
[root@localhost share]# yum install nginx -y
[root@localhost ~]# nginx -v
nginx version: nginx/1.16.1
[root@localhost /]# systemctl enable nginx
[root@localhost /]# systemctl start nginx
(注) 文件默认位置:
二进制文件 /usr/sbin/nginx
配置文件夹 /etc/nginx/
log文件夹 /var/log/nginx
我们可以看到nginx已经正常工作了
MariaDB安装
[root@localhost ~]# yum install mariadb-server
[root@localhost /]# systemctl enable mariadb
[root@localhost /]# systemctl start mariadb
初始化数据库
[root@localhost /]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): #回车
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y #设置root用户密码
New password: #输入密码
Re-enter new password: 确认密码
Password updated successfully!
Reloading privilege tables..
... Success!
By def