搭建lnmp平台
安装Nginx:
使用Nginx官方提供的rpm包
vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
保存退出
执行yum安装
yum install nginx -y #安装Nginx systemctl start nginx #启动Nginx systemctl enable nginx #设置Nginx的自启动
使用第三方扩展epel源安装PHP7.2:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
附照片:[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-6aSxHQUy-1596458063199)(C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20200803185634156.png)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-03vJYhhA-1596458063201)(C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20200803185737995.png)]
安装 php72 版本
yum -y install php72w php72w-cli php72w-common php72w-devel \ php72w-embedded php72w-gd php72w-mbstring php72w-pdo php72w-xml php72w-fpm \ php72w-mysqlnd php72w-opcache
启动 php
systemctl start php-fpm #启动PHP
systemctl enable php-fpm #设置PHP开机自启
安装mysql(mariadb):
rpm -ivh http://repo.mysql.com/yum/mysql-5.6-community/el/7/x86_64/mysql-community-release-el7-5.noarch.rpm
附:[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-O7MyqlQt-1596458063203)(C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20200803191117122.png)]
yum install mysql-community-server -y #安装MySQL systemctl start mysqld #启动MySQL systemctl enable mysqld #设置MySQL的自启动 mysql_secure_installation #修改MySQL密码
应用1:搭建wordpress
(1)下载wordpress源码包
可到站长之家或者百度自行查找 (wordpress-4.9.4-zh_CN.zip)
(2)复制wordpress安装包,到虚拟机/,解压并赋权
mkdir /wordpress #创建源码包的存放目录
unzip wordpress-4.9.4-zh_CN.zip #解压源码包
chmod -R 777 /wordpress #添加权限
(3)创建虚拟主机配置文件
vim /etc/nginx/conf.d/blog.conf
添加:
server {
listen 80;
server_name blog.benet.com;
root /wordpress;
index index.php index.html;
location ~ \.php$ {
root /wordpress;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
保存退出
stemctl reload nginx #刷新Nginx
(4)创建blog数据库和管理用户
登录数据库:mysql -uroot -p123.com
创建数据库:create database blog;
设置管理用户及密码:grant all on blog.* to lisi@localhost identified by '123.com';
(5)客户端通过域名访问blog,安装并配置
http://blog.benet.com
登录后台
http://blog.benet.com/wp-admin
5.应用2:搭建知乎wecenter
(1)下载wecenter源码包
可在百度或站长之家进行下载
(2)复制wecenter安装包,到虚拟机/zh目录下,赋权,并复制/zh目录到php服务器
mkdir /zh
cd /zh unzip wecenter_3-3-4.zip chmod -R 777 /zh
(3)创建虚拟主机配置文件
vim /etc/nginx/conf.d/zh.conf
添加:
server {
listen 80;
server_name zh.benet.com;
root /zh;
index index.php index.html;
location ~ \.php$ {
root /zh;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
保存退出
stemctl reload nginx #刷新Nginx
保存退出
systemctl reload nginx
(4)创建blog数据库和管理用户
登录数据库:mysql -uroot -p123.com
创建数据库:create database zh;
设置管理用户及密码:grant all on zh.* to wangwu@localhost identified by '123.com';
(5)客户端通过域名访问zh,安装并配置
http://zh.benet.com
登录后台
http://zh.benet.com/?/admin
all on zh.* to wangwu@localhost identified by ‘123.com’;
**(5)客户端通过域名访问zh,安装并配置**
http://zh.benet.com
**登录后台**
http://zh.benet.com/?/admin
**ps:访问时需要在linux客户端添加本地解析(hosts文件下添加 ip 域名)**