{"id":230,"date":"2024-11-23T21:26:02","date_gmt":"2024-11-23T13:26:02","guid":{"rendered":"https:\/\/zhzxs.asia\/?p=230"},"modified":"2025-09-02T15:12:39","modified_gmt":"2025-09-02T07:12:39","slug":"1732368731","status":"publish","type":"post","link":"https:\/\/www.zhzxs.site\/index.php\/2024\/11\/23\/1732368731\/","title":{"rendered":"\u534e\u4e3aubuntu22.04\u547d\u4ee4\u884c\u642d\u5efawordpress"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\"><strong>1. \u66f4\u65b0\u7cfb\u7edf<\/strong><\/h3>\n\n\n\n<p>\u5148\u786e\u4fdd\u4f60\u7684\u670d\u52a1\u5668\u7cfb\u7edf\u662f\u6700\u65b0\u7684\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update &amp;&amp; sudo apt upgrade -y<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-default\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. \u5b89\u88c5 LAMP \u73af\u5883<\/strong><\/h3>\n\n\n\n<p>WordPress \u9700\u8981\u8fd0\u884c\u5728 LAMP \u73af\u5883\u4e0a\uff08Linux, Apache, MySQL\/MariaDB, PHP\uff09\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b89\u88c5 Apache<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt install apache2 -y<br>sudo systemctl enable apache2<br>sudo systemctl start apache2<br><\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b89\u88c5 MySQL\/MariaDB<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt install mysql-server -y<br>sudo systemctl enable mysql<br>sudo systemctl start mysql<br><\/code><\/pre>\n\n\n\n<p>\u8bbe\u7f6e MySQL \u5b89\u5168\u6027\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo mysql_secure_installation<br><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6309\u63d0\u793a\u8bbe\u7f6e MySQL root \u5bc6\u7801\u3002<\/li>\n\n\n\n<li>\u5220\u9664\u533f\u540d\u7528\u6237\u3002<\/li>\n\n\n\n<li>\u7981\u7528\u8fdc\u7a0b root \u767b\u5f55\u3002<\/li>\n\n\n\n<li>\u5220\u9664\u6d4b\u8bd5\u6570\u636e\u5e93\u3002<\/li>\n\n\n\n<li>\u91cd\u65b0\u52a0\u8f7d\u6743\u9650\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b89\u88c5 PHP\uff0cphp\u6211\u4eec\u5b89\u88c58.3\u7684\u7248\u672c<\/h4>\n\n\n\n<p>\u6dfb\u52a0 PHP 8.4 \u7684\u4ed3\u5e93(\u670d\u52a1\u5668\u9ed8\u8ba4\u4f1a\u5b89\u88c58.1\u7684\u7248\u672c\uff0c\u6240\u4ee5\u6211\u4eec\u5148\u6dfb\u52a0php8.4\u7684\u4ed3\u5e93\uff0c\u624b\u52a8\u5b89\u88c58.4\u7248\u672c\u540e\uff0c\u540e\u9762\u5b89\u88c5\u6269\u5c55\u670d\u52a1\u5668\u5c31\u4f1a\u7ed9\u6211\u4eec\u5b89\u88c5\u5339\u914dphp8.3\u7248\u672c\u7684\u6269\u5c55)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo add-apt-repository ppa:ondrej\/php\nsudo apt update<\/code><\/pre>\n\n\n\n<p>\u5b89\u88c5php8.3<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install php<span style=\"background-color: initial; font-family: inherit; font-size: inherit; color: initial;\">8.3<\/span><\/code><\/pre>\n\n\n\n<p>\u5b89\u88c5php\u5e38\u7528\u6269\u5c55<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install php-mysql php-curl php-json php-cgi php-gd php-mbstring php-xml php-zip  -y\n<\/code><\/pre>\n\n\n\n<p>\u786e\u8ba4 PHP \u7248\u672c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>php -v<br><\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. \u914d\u7f6e\u6570\u636e\u5e93<\/strong><\/h3>\n\n\n\n<p>\u4e3a WordPress \u521b\u5efa\u4e00\u4e2a\u6570\u636e\u5e93\u548c\u7528\u6237\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo mysql -u root -p<br><\/code><\/pre>\n\n\n\n<p>\u5728 MySQL \u63a7\u5236\u53f0\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;<br>CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'your_password';<br>GRANT ALL PRIVILEGES ON wordpress.* TO 'wp_user'@'localhost';<br>FLUSH PRIVILEGES;<br>EXIT;<br><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5c06 <code>your_password<\/code> \u66ff\u6362\u4e3a\u4e00\u4e2a\u5b89\u5168\u7684\u5bc6\u7801\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>4. \u4e0b\u8f7d\u548c\u5b89\u88c5 WordPress<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u4e0b\u8f7d WordPress<\/h4>\n\n\n\n<p>\u8fdb\u5165 Web \u76ee\u5f55\u5e76\u4e0b\u8f7d WordPress\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>cd \/var\/www\/html<br>sudo wget https:\/\/wordpress.org\/latest.tar.gz<br>sudo tar -xvzf latest.tar.gz<br>sudo rm latest.tar.gz<br><\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u8bbe\u7f6e\u6743\u9650<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo chown -R www-data:www-data \/var\/www\/html\/wordpress<br>sudo chmod -R 755 \/var\/www\/html\/wordpress<br><\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>5. \u914d\u7f6e Apache<\/strong><\/h3>\n\n\n\n<p>\u4e3a WordPress \u521b\u5efa\u4e00\u4e2a Apache \u865a\u62df\u4e3b\u673a\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo vim \/etc\/apache2\/sites-available\/wordpress.conf<br><\/code><\/pre>\n\n\n\n<p>\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9\uff08\u5047\u8bbe\u4f60\u7684\u57df\u540d\u662f <code>example.com<\/code>\uff0c\u7528\u5b9e\u9645\u57df\u540d\u66ff\u6362\uff09\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;VirtualHost *:80&gt;<br>    ServerName example.com<br>    ServerAlias www.example.com<br>    DocumentRoot \/var\/www\/html\/wordpress<br>    &lt;Directory \/var\/www\/html\/wordpress&gt;<br>        AllowOverride All<br>    &lt;\/Directory&gt;<br>    ErrorLog ${APACHE_LOG_DIR}\/wordpress_error.log<br>    CustomLog ${APACHE_LOG_DIR}\/wordpress_access.log combined<br>&lt;\/VirtualHost&gt;<br><\/code><\/pre>\n\n\n\n<p>\u4fdd\u5b58\u5e76\u5173\u95ed\u6587\u4ef6\u540e\uff0c\u542f\u7528\u865a\u62df\u4e3b\u673a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo a2ensite wordpress<br>sudo a2enmod rewrite<br>sudo systemctl restart apache2<br><\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>6. \u914d\u7f6e WordPress<\/strong><\/h3>\n\n\n\n<p>\u8bbf\u95ee WordPress \u7684 URL\uff08<a>http:\/\/\u4f60\u7684\u670d\u52a1\u5668IP\/wordpress<\/a> \u6216\u4f60\u7684\u57df\u540d\uff09\uff0c\u6309\u7167\u9875\u9762\u63d0\u793a\u5b8c\u6210\u5b89\u88c5\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u9009\u62e9\u8bed\u8a00\u3002<\/li>\n\n\n\n<li>\u8f93\u5165\u6570\u636e\u5e93\u4fe1\u606f\uff1a\n<ul class=\"wp-block-list\">\n<li>\u6570\u636e\u5e93\u540d\uff1a<code>wordpress<\/code><\/li>\n\n\n\n<li>\u7528\u6237\u540d\uff1a<code>wp_user<\/code><\/li>\n\n\n\n<li>\u5bc6\u7801\uff1a\u8bbe\u7f6e\u7684 <code>your_password<\/code><\/li>\n\n\n\n<li>\u6570\u636e\u5e93\u4e3b\u673a\uff1a<code>localhost<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u63d0\u4ea4\u540e\u8bbe\u7f6e\u7ba1\u7406\u5458\u8d26\u6237\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>7. \u914d\u7f6e HTTPS\uff08\u53ef\u9009\u4f46\u63a8\u8350\uff09<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b89\u88c5 Certbot \u548c\u83b7\u53d6 SSL \u8bc1\u4e66<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt install certbot python3-certbot-apache -y<br>sudo certbot --apache<br><\/code><\/pre>\n\n\n\n<p>\u6309\u7167\u63d0\u793a\u8f93\u5165\u57df\u540d\u5e76\u542f\u7528 HTTPS\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u73b0\u5728\u4f60\u7684\u670d\u52a1\u5668\u5df2\u7ecf\u6210\u529f\u5b89\u88c5wordpress\u4e86<\/p>\n\n\n\n<p><strong>\u63d0\u793a:<\/strong><\/p>\n\n\n\n<p>\u82e5\u5b89\u88c5\u663e\u793aphp mysql\u6ca1\u6709\u6b63\u786e\u5b89\u88c5\uff0c\u624b\u52a8\u5728\u5b89\u88c5\u4e00\u4e0b8.3\u7248\u672c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install php8.3-mysql<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1. \u66f4\u65b0\u7cfb\u7edf \u5148\u786e\u4fdd\u4f60\u7684\u670d\u52a1\u5668\u7cfb\u7edf\u662f\u6700\u65b0\u7684\uff1a 2. \u5b89\u88c5 LAMP \u73af\u5883 WordPress \u9700\u8981\u8fd0\u884c\u5728 L [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":101,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[61,60,62],"class_list":["post-230","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-2","tag-lnmp","tag-wordpress","tag-62"],"_links":{"self":[{"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/posts\/230","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/comments?post=230"}],"version-history":[{"count":10,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/posts\/230\/revisions"}],"predecessor-version":[{"id":828,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/posts\/230\/revisions\/828"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/media\/101"}],"wp:attachment":[{"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/media?parent=230"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/categories?post=230"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/tags?post=230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}