Using lamp to build WordPress requires the following:
Preparatory work:
- VMware 14
- CentOS 7.4 Minimized installation image
- Wordpress Install package, download
Preheating:
- 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;
- Set up Yum sources, and basic applications such as network cards, using YUM-Y update
- 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
- Yum-y Install httpd php php-devel php-mysql mariadb
- Systemctl Start httpd
- vim/var/www/html/index.php---<?php phpinfo ();?>
- Systemctl Reload httpd
- To test whether the PHP load was successful:
-
- Yum-y Install mariadb Mariadb-server---Installs MARIADB client and server
- Mysql-uroot-p---log on to the local MySQL server to perform the following actions
- New library wpress--> create database wpress;
- new WordPress Dedicated user and authorization-->
grant select , update , alter,insert , create,delete on wpress. * to wpuser " @" 192.168.142. % " identified by '
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
- Configure HTTPD2 server, install httpd mariadb PHP php-mysql for testing
- Server for NFS configuration:
- Yum-y Install Nfsd-utils--Installing an NFS shared environment
- mkdir -pv/share/wp I use this directory for NFS shared directories
- Edit/etc/exports defines the shared file system /share/wp 192.168. 142.0/(Rw,no_root_squash)
- Systemctl start NFS start service
- Use showmount-e localhost to see if sharing is successful
[Email protected] ~]# showmount -for localhost:192.168. 142.0/
- 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 ...
- 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;
- 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:
- 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;
- NFS Jumbo card, poor performance;
- 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;
- To the opening of the structure of the content: httpd server only provide httpd services, not static resources;
- A few points to note:
- MARIADB Authorization for Wpuser requires DELETE permission;
- NFS Build installation package is nfs-utils;
- 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