基于lnmp架构搭建wordpress个人博客

一、安装nginx

1、更改nginx源安装nginx

#vi /etc/yum.repos.d/nginx.repo

添加以下内容

[nginx-stable]

name=nginx stable repo

baseurl=http://nginx.org/packages/centos/$releasever/$basearch/

gpgcheck=1

enabled=1

gpgkey=https://nginx.org/keys/nginx_signing.key

module_hotfixes=true

2、开启缓存,安装nginx,备份安装过的包

#vi /etc/yum.conf

[main]

cachedir=/var/cache/yum/$basearch/$releasever

keepapache=1

#yum -y install nginx

二、安装php

1、安装php

#vim /etc/yum.repos.d/php.repo

[php-webtatic]

name=PHP Repository

baseurl=http://us-east.repo.webtatic.com/yum/el7/x86_64/gpgcheck=0

#yum install libmcrypt-devel

#yum -y install  php71w

3、统一PHP和nginx的用户

#groupadd www -g 666

#useradd www -u666 -g666 -s /sbin/nologin -M

4、让nginx使用www用户

#vi /etc/nginx/nginx.conf

user www;

#systemctl start nginx

#systemctl enable nginx

5、修改php的启动用户,找到相应的匹配用户和组的字段配置即可

#vi /etc/php-fpm.d/www.conf

;Start a new pool named 'www'.

[www]

;unix user/group of processes

;Note: The user is mandatory.If the group is not set, the default user 's group

;          will bd used.

; RPM: apache Choosed to be able to access some dir as httpd

user=www

; RPM: Keep a group allowed to write in log dir.

group=www

#systemctl start php-fpm

#systemctl enable php-fpm

三、安装数据库

1、安装数据库

#yum install  -y mariadb-server

2、启动服务,开机自启

#systemctl start mariadb

#systemctl enable mariadb

3、设置连接数据库的密码

#mysqldamin -uroot password '123'

4、链接数据库

#mysql -u root -p123

4、创建数据库

MariaDB[(none)]>cretae database wp;

6、查看数据库

MariaDB[(none)]>show database;

7、创建WordPress连接数据库的用户和密码

MariaDB[(none)]>grant all on wp.* to wp_user@'localhost' identified by '111';

#vi /etc/my.conf

[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

skip_name_resolve

8、给站点目录授权

#chown www.www/code/php/ -R

#vi index.php

<?php

         $servername="localhost";

         $username="wq_user";

         $password="111";

         $conn=mysqli_connect($servername, $username,$password);

         if (! $conn) {

             die("Connection failed:". mysqld_connect_error()

             }

             echo "小哥哥,PHP可以连接MYSQL...";

?>

四、使用nginx_http_fastcgi_module

1、使用nginx的ngx_http_fastcgi_module连接php,编辑配置文件

#vi php.conf

2、建立网站目录

#mkdir /code/php -p

#vi /code/php/index.php

五、部署wordpress

1、把WordPress的包解压到网站的主目录下/code/php/,在wordpress的官网上可以下载

#tar -zxvf wordpress-5.4-zh_CN.tar.gz

2、浏览器输入php.gong.com会自动跳转

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值