当前位置: 首页 > news >正文

Set up a WordPress blog with Nginx

CentOS7 配置Nginx域名HTTPS
Here is the revised guideline for setting up a WordPress blog with Nginx:

Step 1: Install Nginx, MySQL, and PHP (LEMP Stack)

  1. Install Nginx:

    sudo yum install nginx
    sudo systemctl start nginx
    sudo systemctl enable nginx
    
  2. Install MySQL:

    sudo yum install mariadb-server mariadb
    sudo systemctl start mariadb
    sudo systemctl enable mariadb
    sudo mysql_secure_installation
    
  3. Install PHP and PHP-FPM:

    sudo yum install epel-release
    sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
    sudo yum install yum-utils
    sudo yum-config-manager --enable remi-php74
    

sudo yum install php php-fpm php-mysql php-common php-cli php-json php-zip php-gd php-mbstring php-curl php-xml php-xmlrpc php-soap php-intl
php -v
sudo systemctl start php-fpm
sudo systemctl enable php-fpm


### Step 2: Create a MySQL Database and User1. **Log in to MySQL:**
```bash
sudo mysql -u root -p
  1. Create a database for WordPress:

    CREATE DATABASE wordpress;
    
  2. Create a new MySQL user:

    CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'password';
    
  3. Grant privileges to the new user:

    GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
    FLUSH PRIVILEGES;
    EXIT;
    

Step 3: Download and Configure WordPress

  1. Download the latest WordPress:

    cd /usr/share/nginx/html
    sudo wget https://wordpress.org/latest.tar.gz
    sudo tar -xzf latest.tar.gz
    sudo mv wordpress/* .
    sudo rmdir wordpress
    sudo rm -f latest.tar.gz
    
  2. Set the correct permissions:

    sudo chown -R nginx:nginx /usr/share/nginx/html
    sudo chmod -R 755 /usr/share/nginx/html
    
  3. Configure WordPress:

    sudo cp wp-config-sample.php wp-config.php
    sudo nano wp-config.php
    

    Edit the following lines to include your database information:

    define('DB_NAME', 'wordpress');
    define('DB_USER', 'wpuser');
    define('DB_PASSWORD', 'password');
    define('DB_HOST', 'localhost');
    

Step 4: Configure Nginx for WordPress

  1. Create a new Nginx configuration file for your site:

    sudo nano /etc/nginx/conf.d/wordpress.conf
    
  2. Add the following configuration:

    server {listen 80;server_name www.xxx.xyz;root /usr/share/nginx/html;index index.php index.html index.htm;location / {try_files $uri $uri/ /index.php?$args;}location ~ \.php$ {include /etc/nginx/fastcgi_params;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;}location ~ /\.ht {deny all;}
    }
    
  3. Test the Nginx configuration:

    sudo nginx -t
    
  4. Restart Nginx:

    sudo systemctl restart nginx
    

Step 5: Complete the WordPress Installation

  1. Open your browser and go to:

    http://www.xxx.xyz
    
  2. Follow the on-screen instructions to complete the installation:

    • Choose your language
    • Fill in the site title, username, password, and email
    • Click “Install WordPress”

Step 6: Configure Google AdSense

  1. Sign up for Google AdSense:

    • Go to Google AdSense
    • Sign up with your Google account
  2. Add your site to AdSense:

    • Enter your website URL
    • Follow the instructions to verify your site
  3. Get the AdSense code:

    • After your site is verified, get the AdSense code from your AdSense account
  4. Add AdSense code to WordPress:

    • Install a plugin like “Ad Inserter” or “Insert Headers and Footers” in WordPress
    • Go to the plugin settings and paste the AdSense code in the appropriate section
  5. Configure ad placements:

    • Use the plugin to choose where you want ads to appear on your site

Step 7: Write and Publish Your Blog Posts

  1. Log in to WordPress Admin:

    http://www.xxx.xyz/wp-admin
    
  2. Create a new post:

    • Go to Posts -> Add New
    • Write your content and publish
  3. Customize your site:

    • Go to Appearance -> Themes to choose a theme
    • Use the Customizer to adjust the look and feel of your site

By following these steps, you will have a WordPress blog up and running on your domain with Google AdSense configured to help generate passive income.

http://www.lryc.cn/news/368343.html

相关文章:

  • Facebook开户|Facebook广告设计与测试优化
  • vite获取所有环境变量(env)
  • 【算法】常用排序算法(插入排序、希尔排序、堆排序、选择排序、冒泡排序、快速排序、归并排序、计数排序)超详细
  • 力扣 240.搜素矩阵II
  • ASUS华硕ROG幻14Air笔记本GA403UI(UI UV UU UJ)工厂模式原厂Windows11系统安装包,带MyASUS in WinRE重置还原
  • Spring Boot通过自定义注解和Redis+Lua脚本实现接口限流
  • 硬件工程师的蜗牛成长路
  • 简单记录玩4399游戏flash插件问题
  • GNU/Linux - 使用字符设备来操作GPIO
  • Android13 Settings 左上角箭头图标点击无效
  • WinForms 应用(.NET 8.0)使用ReportViewerCore.WinForms显示打印RDLC报表
  • 【网络安全】【深度学习】【入侵检测】SDN模拟网络入侵攻击并检测,实时检测,深度学习
  • 【CentOS】手动编译安装make、cmake、gcc、git
  • 45.django - 开始建立第一个项目
  • # 梯影传媒T6投影仪刷机方法及一些刷机工具链接
  • 【代码随想录算法训练营第37期 第三十二天 | LeetCode122.买卖股票的最佳时机II、55. 跳跃游戏、45.跳跃游戏II】
  • DP:回文串模型
  • STM32CubeMX软件的安装以及配置
  • 【适配鸿蒙next】Flutter 新一代混合栈管理框架
  • 车载电子电气架构 --- 车载信息安全
  • 【数据结构(邓俊辉)学习笔记】图04——双连通域分解
  • UI学习(二)
  • 【嵌入式】波特率9600,发送8个字节需要多少时间,如何计算?
  • jmeter -n -t 使用非GUI模式运行脚本说明
  • 网络流媒体协议——HLS协议
  • Linux服务器扩容及磁盘分区(LVM和非LVM)
  • 支持向量机
  • Kafka 架构
  • iOS 查看runtime源码的几种方法
  • 底板外设倒灌到处理器分析