{"id":3507,"date":"2024-09-23T00:27:12","date_gmt":"2024-09-22T16:27:12","guid":{"rendered":"https:\/\/blog.zengqq.com.cn\/?p=3507"},"modified":"2024-09-29T19:17:53","modified_gmt":"2024-09-29T11:17:53","slug":"%e5%9c%a8%e5%86%85%e7%bd%91%e6%90%ad%e5%bb%bawordpress%ef%bc%88%e6%b5%8b%e8%af%95%e7%8e%af%e5%a2%83%ef%bc%89","status":"publish","type":"post","link":"https:\/\/blog.zengqq.com.cn\/?p=3507","title":{"rendered":"\u5728\u5185\u7f51\u642d\u5efawordpress\uff08\u6d4b\u8bd5\u73af\u5883\uff09"},"content":{"rendered":"\n<ul class=\"wp-block-list\">\n<li>\u524d\u671f\u51c6\u5907\uff1a\n<ul class=\"wp-block-list\">\n<li>\u670d\u52a1\u5668-\u6700\u4f4e\u914d\u7f6e\u53bb\u8981\u6c42\uff1a\u5355\u68381G\u5185\u5b5832G\u5b58\u50a8\u7a7a\u95f4\uff0c\u53ef\u4ee5\u662f\u53f0\u865a\u62df\u673a\u3002<\/li>\n\n\n\n<li>\u72ec\u7acb\u7684\u7f51\u53e3\u548cIP\u5730\u5740-\u6211\u7684\u670d\u52a1\u5668\u5728\u5185\u7f51\u73af\u5883\uff0c\u53d7\u523010.10.0.0\u7f51\u6bb5\u4e0b\u7684\u865a\u62dfikuai\u8def\u7531\u670d\u52a1\u5668\u7684\u7ba1\u7406\uff0c\u5206\u914d\u5230\u7684\u5730\u5740\u662f10.10.0.53<\/li>\n\n\n\n<li>wordpress\u5b89\u88c5\u6587\u4ef6-\u53ef\u4ee5\u63d0\u524d\u4e0b\u8f7d\u597d\uff0c\u5343\u5146\u5916\u7f51\u7684\u8bdd\u4e5f\u53ef\u4ee5wget https:\/\/wordpress.org\/latest.tar.gz,\u7136\u540etar -xzvf latest.tar.gz\u89e3\u538b<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>\u6309\u81ea\u5df1\u7684\u8bbe\u8ba1\u628a\u89e3\u538b\u597d\u7684wordpress\u5b89\u88c5\u6587\u4ef6\u7684\u201d\u6574\u4e2a\u6587\u4ef6\u201c\u79fb\u52a8\u5230\u6839\u76ee\u5f55\u4e0b<\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mysql> CREATE DATABASE wordpress;\nQuery OK, 1 row affected (0.01 sec)\n\nmysql> CREATE USER 'qq'@'localhost' IDENTIFIED BY '`12w`12';\nQuery OK, 0 rows affected (0.03 sec)\n\nmysql> GRANT ALL PRIVILEGES ON wordpress.* TO 'qq'@'localhost';\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> FLUSH PRIVILEGES;\nQuery OK, 0 rows affected (0.01 sec)<\/pre>\n\n\n\n<p><strong>\u00b7 Tutorial \u00b7<\/strong><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">How to install WordPress on Ubuntu 22.04 with LEMP<\/h1>\n\n\n\n<p>Here is the detailed manual on how to install&nbsp;<strong>WordPress<\/strong>&nbsp;on&nbsp;<strong>Ubuntu 22.04<\/strong>&nbsp;with&nbsp;<strong>LEMP<\/strong>:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-1-update-the-operating-system\">Step 1: Update the Operating System<\/h2>\n\n\n\n<p>Before you start installing WordPress, it is important to make sure that your Ubuntu 22.04 operating system is up to date. Open the terminal and run the following commands:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt-get update\nsudo apt-get upgrade\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-2-install-nginx\">Step 2: Install Nginx<\/h2>\n\n\n\n<p>Nginx is a web server that will be used to host the WordPress website. Run the following command to install Nginx:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt-get install nginx\n<\/pre>\n\n\n\n<p>Once the installation is complete, start the Nginx service with the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl start nginx\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-3-install-mysql\">Step 3: Install MySQL<\/h2>\n\n\n\n<p>MySQL is a database management system that will be used to store the data for the WordPress website. Run the following command to install MySQL:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt-get install mysql-server\n<\/pre>\n\n\n\n<p>During installation, you will NOT be prompted to set a password for the MySQL&nbsp;<code>root<\/code>&nbsp;user.But Later on using SU to start MySQL to login as root without password, and then set database and authorise user with password protected.<\/p>\n\n\n\n<p>Once the installation is complete, start the MySQL service with the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl start mysql\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-4-install-php\">Step 4: Install PHP<\/h2>\n\n\n\n<p>PHP is a programming language used to execute code on the web server. Run the following command to install PHP and the necessary modules:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt-get install php8.1-fpm php-mysql\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-5-configure-nginx\">Step 5: Configure Nginx<\/h2>\n\n\n\n<p>Now that the necessary components have been installed, it is time to configure Nginx to host the WordPress website. Open the default Nginx configuration file with the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo nano \/etc\/nginx\/sites-available\/default\n<\/pre>\n\n\n\n<p>Inside the file, find the section starting with&nbsp;<code>server {<\/code>&nbsp;and replace its contents with the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">server {\n    listen 80;\n    listen [::]:80;\n    root \/var\/www\/html;\n    index index.php index.html index.htm;\n    server_name example.com www.example.com;\n\n    location \/ {\n        try_files $uri $uri\/ \/index.php?$args;\n    }\n\n    location ~ \\.php$ {\n        include snippets\/fastcgi-php.conf;\n        fastcgi_pass unix:\/var\/run\/php\/php8.1-fpm.sock;\n    }\n\n    location ~ \/\\.ht {\n        deny all;\n    }\n}\n<\/pre>\n\n\n\n<p>Remember to replace&nbsp;<code>example.com<\/code>&nbsp;and&nbsp;<code>www.example.com<\/code>&nbsp;with the domain name of your website.<\/p>\n\n\n\n<p>Save and close the configuration file.<\/p>\n\n\n\n<p>Check and reload the new nginx configuration:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nginx -t\n\/etc\/init.d\/nginx reload\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-6-create-the-wordpress-database\">Step 6: Create the WordPress database<\/h2>\n\n\n\n<p>Create a MySQL database for WordPress with the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mysql -u root -p\n<\/pre>\n\n\n\n<p>You will be prompted to enter the MySQL&nbsp;<code>root<\/code>&nbsp;user password. Once you are in the MySQL console, execute the following commands:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">CREATE DATABASE wordpress;\nCREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';\nGRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';\nFLUSH PRIVILEGES;\nexit;\n<\/pre>\n\n\n\n<p>Remember to replace&nbsp;<code>password<\/code>&nbsp;with a strong password.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-7-download-and-install-wordpress\">Step 7: Download and install WordPress<\/h2>\n\n\n\n<p>Download the latest version of WordPress with the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cd \/tmp\nwget https:\/\/wordpress.org\/latest.tar.gz\n<\/pre>\n\n\n\n<p>Unzip the downloaded file with the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">tar -zxvf latest.tar.gz\n<\/pre>\n\n\n\n<p>Copy the unzipped WordPress files to the root directory of the web server with the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo cp -r \/tmp\/wordpress\/* \/var\/www\/html\n<\/pre>\n\n\n\n<p>Change the ownership of the root directory to the user&nbsp;<code>www-data<\/code>&nbsp;with the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo chown -R www-data:www-data \/var\/www\/html\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-8-configure-wordpress\">Step 8: Configure WordPress<\/h2>\n\n\n\n<p>Open your browser and access the website.<\/p>\n\n\n\n<p>Follow the WordPress installation, selecting first the language and, in the next tab, the data concerning the database. The database name, username, password and server.<\/p>\n\n\n\n<p>During the manual we have used the following data:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Database name: wordpress\nUser: wordpressuser\nPassword: password\n<\/pre>\n\n\n\n<p>As the server, you will need to enter &#8220;localhost&#8221;.<\/p>\n\n\n\n<p>Complete the WordPress configuration details and follow the instructions to set up your website.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>That&#8217;s it! You now have WordPress installed on Ubuntu 22.04 with LEMP.<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u6309\u81ea\u5df1\u7684\u8bbe\u8ba1\u628a\u89e3\u538b\u597d\u7684wordpress\u5b89\u88c5\u6587\u4ef6\u7684 [&#8230;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[89],"tags":[],"class_list":["post-3507","post","type-post","status-publish","format-standard","hentry","category-live"],"_links":{"self":[{"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/3507","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3507"}],"version-history":[{"count":6,"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/3507\/revisions"}],"predecessor-version":[{"id":3521,"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/3507\/revisions\/3521"}],"wp:attachment":[{"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3507"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3507"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3507"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}