centos7搭建LNMP部署wordpress

本文详细指导如何在CentOS 7.6上配置Nginx以同时挂载两个域名(localhost与www.hl01.com, www.hl02.com),实现PHP与Nginx的联动,并配置MySQL数据库,安装WordPress并完成多站配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

**WordPress是一款常用的搭建个人博客网站软件,该软件使用PHP语言开发。

  • 搭建nginx

    默认情况下centos7.6没有nginx的源,需要配置Nginx官网提供Gentos的源地址。

  • 配置nginx源
[root@hl-web lnmp-wordpress]# rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

[root@hl-web ~]# yum search nginx

  • 安装nginx
[root@hl-web ~]#  yum install -y pcre-devel openssl-devel #安装nginx依赖包
[root@hl-web ~]# yum install -y nginx
  • 实现PHP联动

    • 配置nginx的/etc/nginx/conf.d/default.conf文件,
      server {
          listen       80;
          server_name  192.168.0.116;
      
          #access_log  /var/log/nginx/host.access.log  main;
      
          location / {
              root   /usr/share/nginx/html/wordpress;
              index index.html index.htm index.php;
          }
      
          
          error_page   500 502 503 504  /50x.html;
          location = /50x.html {
              root   /usr/share/nginx/html;
          }
      
          location ~ \.php$ {
               root           /usr/share/nginx/html/wordpress;
               fastcgi_pass   127.0.0.1:9000;
               fastcgi_index  index.php;
               fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
               include        fastcgi_params;
             }
          
      }
      
      
    • 或者有的是配置nginx的/etc/nginx/nginx.conf文件
      http {
          log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                            '$status $body_bytes_sent "$http_referer" '
                            '"$http_user_agent" "$http_x_forwarded_for"';
      
          access_log  /var/log/nginx/access.log  main;
      
          sendfile            on;
          tcp_nopush          on;
          tcp_nodelay         on;
          keepalive_timeout   65;
          types_hash_max_size 4096;
      
          include             /etc/nginx/mime.types;
          default_type        application/octet-stream;
      
          # Load modular configuration files from the /etc/nginx/conf.d directory.
          # See http://nginx.org/en/docs/ngx_c
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值