Linux搭建lnmp并部署WeCenter博客
WeCenter源码链接:https://down.chinaz.com/soft/432.htm 准备环境:
- Linux(Centos7)
- PHP
- Nginx
- Mariadb
1.关闭防火墙、Selinux
service firewalld stop
set enforce 0
2.添加yum源,安装nginx
vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
保存退出
3.安装nginx
yum install -y nginx
4.安装、启动、初始化、登陆数据库
yum install -y mariadb mariadb-server
service mariadb start
mysql_secure_installation
mysql -uroot -p
5.创建一个数据库,为后续做准备
create database <库名>;
6.使用第三方扩展安装PHP7
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
安装PHP
yum -y install php72w php72w-cli php72w-common php72w-devel php72wembedded php72w-gd php72w-mbstring php72w-pdo php72w-xml php72w-fpm php72w-mysqlnd php72w-opcache
7.修改配置文件
vim /etc/php-fpm.d/www.conf
user = nginx
group = nginx
#PS:保证nginx进行的管理用户和php服务进程的管理用户保持一致
service php-fpm restart
//重启服务
8.实现nginx+php关联
vim /etc/nginx/conf.d/bbb.conf
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html; //nginx网页代码存放目录
index index.html index.php;
}
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
}
9.编写一个简单的测试文件
cd /usr/share/nginx/html
vim test.php //编辑一个php配置文件
cat test.php
<?php
phpinfo();
?>
重启nginx服务,进行测试
10.将下载好的源码传入Linux
我这里采用的是cmd里面的scp
scp <文件名> root@<Linux主机的ip>:/ <你要传入Linux的哪个位置,我就先传到/目录>
11.将下载好的wecenter源码上传到Centos7里,并且移动到/usr/share/nginx/html/里面,新建一个文件夹,方便观看。
unzip WeCenter_v3.3.0.zip //解压此文件
12.创建虚拟主机文件
vim /etc/nginx/conf.d/ccc.conf
cat ccc.conf
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html/we;
index index.html index.php;
}
location ~ \.php$ {
root /usr/share/nginx/html/we;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
}
保存退出
进入/usr/share/nginx文件夹,给html文件夹下的所有文件的所属组和用户更改
chown nginx:nginx -R html
重启nginx服务
service nginx restart
|