站長資訊網
        最全最豐富的資訊網站

        在Ubuntu 18.04上安裝帶有Nginx,MariaDB 10和PHP 7的WordPress

        WordPress 5最近發布了一些核心變化,例如Gutenberg編輯器。我們的許多讀者可能想在自己的服務器上測試它。對于那些人,在本教程中,我們將在Ubuntu 18.04上使用LEMP設置WordPress 5。

        對于不了解的人,LEMP是Linux,Nginx,MySQL / MariaDB和PHP的流行組合。

        在Ubuntu 18.04上安裝帶有Nginx,MariaDB 10和PHP 7的WordPress

        要求

        • 使用Ubuntu 18.04最小安裝的專用服務器或VPS(虛擬專用服務器)。

        本教程將指導您完成所有必需軟件包的安裝,創建自己的數據庫,準備vhost以及通過瀏覽器完成WordPress安裝。

        在Ubuntu 18.04上安裝Nginx Web服務器

        首先,我們將準備我們的Web服務器Nginx。要安裝軟件包,請運行以下命令:

        linuxidc@linuxidc:~$ sudo apt update && sudo apt upgrade
        linuxidc@linuxidc:~$ sudo apt install nginx

        在Ubuntu 18.04上安裝帶有Nginx,MariaDB 10和PHP 7的WordPress

        要啟動nginx服務并在系統引導時自動啟動它,請運行以下命令:

        linuxidc@linuxidc:~$ sudo systemctl start nginx.service
        linuxidc@linuxidc:~$ sudo systemctl enable nginx.service

        在Ubuntu 18.04上安裝帶有Nginx,MariaDB 10和PHP 7的WordPress

        在Nginx上為WordPress網站創建虛擬主機

        現在我們將為您的WordPress網站創建虛擬主機。 使用您喜歡的文本編輯器創建以下文件:

        $ sudo vim /etc/nginx/sites-available/wordpress.conf

        在下面的示例中,使用您要使用的域更改linuxidc.com:

        server {
            listen 80;
            listen [::]:80;
            root /var/www/html/wordpress;
            index  index.php index.html index.htm;
            server_name linuxidc.com www.linuxidc.com;

            client_max_body_size 100M;

            location / {
                try_files $uri $uri/ /index.php?$args;       
            }

            location ~ .php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass            unix:/var/run/php/php7.2-fpm.sock;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            }
        }

        在Ubuntu 18.04上安裝帶有Nginx,MariaDB 10和PHP 7的WordPress

        保存文件并退出。 然后啟用該站點:

        $ sudo ln -s /etc/nginx/sites-available/wordpress.conf  /etc/nginx/sites-enabled/

        然后重新加載nginx:

        $ sudo systemctl reload nginx

        在Ubuntu 18.04上安裝帶有Nginx,MariaDB 10和PHP 7的WordPress

        在Ubuntu 18.04上安裝MariaDB 10

        我們將使用MariaDB作為您的WordPress數據庫。 要安裝MariaDB,請運行以下命令:

        $ sudo apt install mariadb-server mariadb-client

        在Ubuntu 18.04上安裝帶有Nginx,MariaDB 10和PHP 7的WordPress

        安裝完成后,我們將啟動它并將其配置為在系統引導時自動啟動:

        $ sudo systemctl start mariadb.service
        $ sudo systemctl enable mariadb.service

        在Ubuntu 18.04上安裝帶有Nginx,MariaDB 10和PHP 7的WordPress

        接下來,通過運行以下命令來保護MariaDB安裝:

        linuxidc@linuxidc:~$ sudo mysql_secure_installation

        NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
              SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

        In order to log into MariaDB to secure it, we’ll need the current
        password for the root user.  If you’ve just installed MariaDB, and
        you haven’t set the root password yet, the password will be blank,
        so you should just press enter here.

        Enter current password for root (enter for none):
        OK, successfully used password, moving on…

        Setting the root password ensures that nobody can log into the MariaDB
        root user without the proper authorisation.

        You already have a root password set, so you can safely answer ‘n’.

        Change the root password? [Y/n] y
        New password:
        Re-enter new password:
        Password updated successfully!
        Reloading privilege tables..
         … Success!

        By default, a MariaDB installation has an anonymous user, allowing anyone
        to log into MariaDB without having to have a user account created for
        them.  This is intended only for testing, and to make the installation
        go a bit smoother.  You should remove them before moving into a
        production environment.

        Remove anonymous users? [Y/n] Y
         … Success!

        Normally, root should only be allowed to connect from ‘localhost’.  This
        ensures that someone cannot guess at the root password from the network.

        Disallow root login remotely? [Y/n] n
         … skipping.

        By default, MariaDB comes with a database named ‘test’ that anyone can
        access.  This is also intended only for testing, and should be removed
        before moving into a production environment.

        Remove test database and access to it? [Y/n] y
         – Dropping test database…
         … Success!
         – Removing privileges on test database…
         … Success!

        Reloading the privilege tables will ensure that all changes made so far
        will take effect immediately.

        Reload privilege tables now? [Y/n] Y
         … Success!

        在Ubuntu 18.04上安裝帶有Nginx,MariaDB 10和PHP 7的WordPress

        只需在提示中回答問題即可完成任務。

        為網站創建WordPress數據庫

        之后,我們將為該用戶準備數據庫,數據庫用戶和密碼。 它們將由我們的WordPress應用程序使用,因此它可以連接到MySQL服務器。

        linuxidc@linuxidc:~$ sudo mariadb -u root

        使用下面的命令,我們將首先創建數據庫,然后創建數據庫用戶及其密碼。 然后我們將授予用戶對該數據庫的權限。

        CREATE DATABASE linuxidc;
        grant all privileges on linuxidc.* to linuxidc@localhost identified by ‘你的密碼’;
        FLUSH PRIVILEGES;
        EXIT;

        在Ubuntu 18.04上安裝帶有Nginx,MariaDB 10和PHP 7的WordPress在Ubuntu 18.04上安裝帶有Nginx,MariaDB 10和PHP 7的WordPress

        在Ubuntu 18.04上安裝PHP 7

        由于WordPress是用PHP編寫的應用程序,我們將安裝PHP和運行WordPress所需的PHP包,使用以下命令:

        $ sudo apt install php-fpm php-common php-mbstring php-xmlrpc php-soap php-gd php-xml php-intl php-mysql php-cli php-ldap php-zip php-curl

        在Ubuntu 18.04上安裝帶有Nginx,MariaDB 10和PHP 7的WordPress

        安裝完成后,我們將啟動php-fpm服務并啟用它:

        linuxidc@linuxidc:~$ sudo systemctl start php7.2-fpm
        linuxidc@linuxidc:~$ systemctl enable php7.2-fpm
        Synchronizing state of php7.2-fpm.service with SysV service script with /lib/systemd/systemd-sysv-install.
        Executing: /lib/systemd/systemd-sysv-install enable php7.2-fpm

        在Ubuntu 18.04上安裝帶有Nginx,MariaDB 10和PHP 7的WordPress

        在Ubuntu 18.04上安裝WordPress 5

        從這一點開始,開始簡單的部分。 使用以下wget命令下載最新的WordPress包:

        linuxidc@linuxidc:~$ cd /tmp && wget https://wordpress.org/latest.tar.gz

        在Ubuntu 18.04上安裝帶有Nginx,MariaDB 10和PHP 7的WordPress

        然后用以下內容提取存檔:

        linuxidc@linuxidc:/tmp$ sudo tar -xvzf latest.tar.gz -C /var/www/html

        以上將創建我們在vhost中設置的文檔根目錄,即/var/www/html/wordpress。 然后,我們需要更改該目錄中文件和文件夾的所有權:

        linuxidc@linuxidc:/tmp$ sudo chown www-data: /var/www/html/wordpress/ -R

        現在我們準備運行WordPress的安裝。 如果您使用了未注冊/不存在的域,則可以使用以下記錄配置 /etc/hosts的hosts文件:

        192.168.1.100 www.linuxidc.com

        假設您的服務器的IP地址是192.168.1.100并且您使用的域是linuxidc.com那么您的計算機將在給定的IP地址上解析linuxidc.com。

        現在將您的域加載到瀏覽器中,您應該看到WordPress安裝頁面:

        在Ubuntu 18.04上安裝帶有Nginx,MariaDB 10和PHP 7的WordPress

        在下一頁上輸入我們之前設置的數據庫憑據:

        在Ubuntu 18.04上安裝帶有Nginx,MariaDB 10和PHP 7的WordPress

        在Ubuntu 18.04上安裝帶有Nginx,MariaDB 10和PHP 7的WordPress

        提交表單,然后在下一個屏幕上配置您的網站標題,管理員用戶和電子郵件:

        在Ubuntu 18.04上安裝帶有Nginx,MariaDB 10和PHP 7的WordPress

        您的安裝現已完成,您可以開始管理您的WordPress網站。 您可以先安裝一些全新的主題或通過插件擴展網站功能。

        在Ubuntu 18.04上安裝帶有Nginx,MariaDB 10和PHP 7的WordPress

        總結

        就是這樣。 在Ubuntu 18.04上安裝設置自己的WordPress過程。 我希望這個過程簡單明了。

        贊(0)
        分享到: 更多 (0)
        網站地圖   滬ICP備18035694號-2    滬公網安備31011702889846號
        主站蜘蛛池模板: 一本一本久久a久久精品综合麻豆 一本色道久久88综合日韩精品 | 国产69精品久久久久99尤物| 国产亚洲精品无码拍拍拍色欲| 精品调教CHINESEGAY| 麻豆国产高清精品国在线| 香蕉国产精品频视| 国99精品无码一区二区三区| 亚洲а∨天堂久久精品| 国产精品免费在线播放| 精品国产91久久久久久久| 国产三级久久久精品麻豆三级| 中国国产精品| 久久久久久国产精品无码下载| 国产精品单位女同事在线| 久久精品国产久精国产| 国产精品91av| 99re6在线视频精品免费| 久久精品无码一区二区无码| 亚洲精品乱码久久久久久久久久久久| 精品亚洲视频在线观看| 国产高清在线精品一区二区| 日韩精品一区二区三区四区| 99久久免费国产精品热| 国产精品三级在线观看无码| 久久永久免费人妻精品下载| 亚洲精品白浆高清久久久久久| 亚洲精品成人片在线观看| 亚洲国产精品尤物YW在线观看 | 亚洲视频在线精品| 久久亚洲中文字幕精品一区| 精品久久人人妻人人做精品| 国产乱码伦精品一区二区三区麻豆| 99久久精品九九亚洲精品| 9999国产精品欧美久久久久久| 午夜精品福利视频| 欧美巨大黑人精品videos| 精品国产麻豆免费人成网站| 久久精品国产精品青草| 99热精品毛片全部国产无缓冲| 亚洲愉拍自拍欧美精品| 国产高清国内精品福利99久久|