LAMP Build Wordpress site Linux Apache MariaDB PHP

Source: Internet
Author: User
Tags phpinfo install wordpress nfsd

Using lamp to build WordPress requires the following:

Preparatory work:
    1. VMware 14
    2. CentOS 7.4 Minimized installation image
    3. Wordpress Install package, download
Preheating:
    1. Use VMware to create a new 4 virtual machine, and install a CentOS 7 minimum system first, and then use the cloning function to replicate the other three, the direct installation is faster;
    2. Set up Yum sources, and basic applications such as network cards, using YUM-Y update
    3. Log IP for each host
MARIADB Host 192.168.142.128/24
Nfs 192.168.142.140/24
Httpd1 192.168.142.135/24
Httpd2 192.168.142.141/24

Begin:
    • HTTPD1/2 Shared Settings--configure PHP, httpd and MARIADB clients
      1. Yum-y Install httpd php php-devel php-mysql mariadb
      2. Systemctl Start httpd
      3. vim/var/www/html/index.php---<?php phpinfo ();?>
      4. Systemctl Reload httpd
      5. To test whether the PHP load was successful:

    • MARIADB Server settings:
    1. Yum-y Install mariadb Mariadb-server---Installs MARIADB client and server
    2. Mysql-uroot-p---log on to the local MySQL server to perform the following actions
        1. New library wpress--> create database wpress;
        2. new WordPress Dedicated user and authorization--> 
           grant  select , update , alter,insert , create,delete  on  wpress. *  to    wpuser   " @"  192.168.142. %   " identified by   '  
    3. Landing test on the httpd side

      mysql-uwpress-h192. 168.142.  -ppassword
      >show GRANTS; --After logging into the MySQL server, use this command to display the authorization information;

      MariaDB [(none)]> show grants;
      +-------------------------------------------------------------------------------------------------------------- -----+
      | Grants for [email protected]% |
      +-------------------------------------------------------------------------------------------------------------- -----+
      | GRANT USAGE on *. wpuser ' @ ' 192.168.142.% ' identified by PASSWORD ' *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 ' |
      | GRANT SELECT, INSERT, UPDATE, CREATE, DELETE, ALTER on ' wpress '. * to ' wpuser ' @ ' 192.168.142.% ' |
      +-------------------------------------------------------------------------------------------------------------- -----+
      2 rows in Set (0.00 sec)

      • To perform a php-mysql connection test:
        vim/var/www/html/index.php-->↓ modified as follows ↓
        <? PHP      Echo '<title> This is        a PHP page    </title>';     $link=mysql_connect(' 192.168.142.128 ', ' wpuser ', ' Password ');     if ($link)     Echo "MySQL Connected";--Connect    success else    echo "MySQL Failed"    ; Mysql_close (); Phpinfo ();? >

    • Configure WordPress to httpd 1 server, ready to be configured and copy directly to NFS
      • After downloading the source package, use Xftp to import the HTTPD1 server, extract:

      • Visit the WP site on httpd server 1: http://192.168.142.135/wordpress
        • Generate wp-config.php file contents according to prompt; Or, directly under the wordpress/directory, CP wp-config-sample.php wp-config.php , modify the define of the top lines (' db_name ', ' Database_name_here '); _here for your own database can be set;
        • Refresh the page and follow the prompts to set
        • If you are prompted to modify the database contents--It is best to delete wpress, and then create a new wpress;
        • View sites, test sites, new users, etc.;

  • Configuring the HTTPD2 service side
    1. Configure HTTPD2 server, install httpd mariadb PHP php-mysql for testing
  • Server for NFS configuration:
    1. Yum-y Install Nfsd-utils--Installing an NFS shared environment
    2. mkdir -pv/share/wp I use this directory for NFS shared directories
    3. Edit/etc/exports defines the shared file system /share/wp 192.168. 142.0/(Rw,no_root_squash)
    4. Systemctl start NFS start service
    5. Use showmount-e localhost to see if sharing is successful
      [Email protected] ~]# showmount -for localhost:192.168. 142.0/
    6. Install Nfs-utils on HTTPD1 and HTTPD2 respectively, then mount the/share/wp file system mount -T NFS 192.168. 142.140:/share/wp/var/www/html/ ---here steal a lazy, directly mount to httpd default resource path, save to modify ...
    7. Create a index.php < at your fingertips ; PHP echo "This page was fromNFS Server"; Phpinfo (); ?> , re-visit:

  • Copy the configured wordpress/on the HTTPD1 to the NFS server to see if the access is normal:
  • But there is a problem: the management page will jump to the HTTPD1 server, then we delete this WP site to try again;
    • Delete wordpress/, delete database new

    • Unzip and install WordPress on the NFS server
    • For experimental results, we use HTTPD2 this server to configure WP-and results: After landing the same will jump to httpd2 this host;
  • Uploading file issues:
    • Since the httpd service on the HTTPD server is running as Apache user, we need to increase the write access to the/var/www/html directory for Apache users. But! After using chmod 766, the whole site of WordPress is hung;
    • Well, you need x permission to access it correctly;
    • Carefully review the WP on the upload time error, found: /wordpress/wp-content is required to change the 777 permissions , after the change, upload normal;
Final Test

Summarize:
    1. At first, it is wrong to put WP site resources on HTTPD1 and HTTPD2 respectively, and the correct practice is to put on NFS so that all accesses will invoke static resources from NFS;
    2. NFS Jumbo card, poor performance;
    3. Inevitably, no matter on which httpd on the completion of the initialization of WordPress, the management of access to the landing will eventually jump to the server to initialize, and do not understand why;
    4. To the opening of the structure of the content: httpd server only provide httpd services, not static resources;
    5. A few points to note:
      1. MARIADB Authorization for Wpuser requires DELETE permission;
      2. NFS Build installation package is nfs-utils;
      3. This form of site is not good to use.

Related Command collation:

Server for NFS: NFSD (nfs-utils), Mountd, IDMAPD

SHOWMOUNT-E host_ip
Showmount-a host_ip Display all mounts on specified NFS

Mount
Mount-t NFS Server:/path/to/shared_fs/path/to/mount_point

/etc/exports: Format:
Directory (or file system) Client1 (Option1, Option2) client2 (Option1, Option2)

LAMP Build Wordpress site Linux Apache MariaDB PHP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.