20、编译安装搭建LNMP

1、编译安装LNMP,并安装wordpress

编译安装nginx
1、下载安装包
wget http://nginx.org/download/nginx-1.16.1.tar.gz
2、解压
[root@C76 ~]# tar xvf nginx-1.16.1.tar.gz
3、安装编译包
[root@C76 ~]# yum install gcc pcre-devel openssl-devel zlib-devel -y
4、创建一个用户
[root@C76 ~]# useradd -r -s /sbin/nologin nginx
[root@C76 ~]# getent passwd nginx  #查看用户
5、编译安装
[root@C76 nginx-1.16.1]# ./configure --prefix=/apps/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module
[root@C76 nginx-1.16.1]# make && make install
6、创建软连接
[root@C76 nginx]# ln -s /apps/nginx/sbin/nginx /usr/sbin/
7、启动服务
nginx
8、设置开启启动
[root@C76 nginx]# vim /etc/rc.d/rc.local 
/usr/sbin/nginx     #添加的信息
[root@C76 nginx]# chmod +x /etc/rc.d/rc.local
9、设置配置文件
[root@C76 conf.d]# vim /apps/nginx/conf/nginx.conf  ###在配置文件增加如下一行
include       /apps/nginx/conf.d/*.conf;
[root@C76 conf.d]# vim wordpress.conf
[root@C76 conf.d]# cat wordpress.conf 
server {
        listen       80;
        server_name  www.x.com;
        root /data/php;
        index index.php;
        location ~* \.php$ {
                root /data/php;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
}
[root@C76 conf.d]# systemctl start php-fpm
安装mariadb
1、安装mariadb
[root@C76 ~]# yum install mariadb-server -y
2、启动服务
[root@C76 ~]# systemctl start mariadb
3、登录mysql
[root@C76 ~]# mysql
4、创建数据并授权
MariaDB [(none)]> create database wpdb;
MariaDB [(none)]>  grant all privileges on wpdb.* to wpuser@‘%‘ identified by "redhat";
MariaDB [(none)]> flush privileges;
[root@C76 ~]# mysql_secure_installation #跑安全加固脚本
5、下载wordpress
wget https://cn.wordpress.org/download/releases/
[root@C76 ~]# tar xvf wordpress-5.0.10-zh_CN.tar.gz  #解压
[root@C76 html]# cd /apps/nginx/html/
[root@C76 html]# mv ~root/wordpress/* .
[root@C76 html]# cp wp-config-sample.php wp-config.php
[root@C76 html]# vim wp-config.php
/** WordPress数据库的名称 */
define('DB_NAME', 'wpdb');

/** MySQL数据库用户名 */
define('DB_USER', 'wpuser');

/** MySQL数据库密码 */
define('DB_PASSWORD', 'redhat');
6、设置权限
[root@C76 html]# mkdir /data/
[root@C76 html]# setfacl -R -m u:nginx:rwx /data

2、配置虚拟主机,www.x.com域名实现首页访问,admin.x.com域名实现wordpress的后台访问

[root@C76 conf.d]# cat wordpress.conf 
server {
        listen       80;
        server_name  www.x.com;
        root /data/php;
        index index.php;
        location ~* \.php$ {
                root /data/php;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
}

server {
        listen       80;
        server_name  admin.x.com;
        root /data/php;
        index wp-login.php;
        location ~* \.php$ {
                root /data/php;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值