Install wordpress using LAMP in CentOS
Functions:
Three virtual machines are required. One is used as the MySQL database, and the other is used as the NFS. The other creates a virtual host and works as a workpress host, allowing dynamic data of the two hosts to access the same database and static data to access the same NFS server.
HOST 1: 172.16.18.1 (WordPress1) 172.16.18.1 (WordPress2)
Host 2: 172.16.18.5 (NFS)
Host 3: 172.16.249.124 (MySQL)
Environment setup:
(1): Configure NFS
Service end Configuration:
Server IP: 172.16.18.5
Install NFS-utils on the nfs server
Edit the configuration file:/etc/exports
/Nfsserver 172.16.0.0/16 (rw, async, no_root_squash)
Create a shared directory/nfsserver
Mkdir/nfsserver
Rwx permissions for apache users in the shared directory:
Setfacl-m u: apache: rwx/nfsserver
Restart service: service nfs restart
Client:
Create a/web/nfs mount directory:
Showmount-a 172.16.18.5 view the shared NFS service.
Mount-t nfs 172.16.18.5:/nfsserver/web/nfs
Create the wp1 and wp2 directories in the nfs shared directory.
Mkdir/nfsserver/{wp1, wp2}
(2): create two virtual hosts:
First, make sure that the httpd service on the local machine is normal: You can compile and install the latest Apache version, or directly install the rpm package.
Compile the configuration file httpd. conf.
The virtual host is accessed by IP address. The address is (host1) 172.16.18.1 and (host2) 172.16.18.2.
We use http2.4 as an example to configure: Add a virtual host. For detailed compilation and installation steps, see the previous blog.
ServerAdminaolens@aolens.comDocumentRoot/web/nfs/wp1ServerNamewww. workpress1.comErrorLog/var/log/httpd/logs/var/log/httpd/workpress1.accesscommen <Directory "/web/nfs/wp1"> Requireallgranted </Directory> </VitualHost> <VirtualHost172.16.18.2: 80> ServerAdminaolens@aolens.comDocumentRoot/web/nfs/wp2ServerNamewww. workpress2.comErrorLog/var/log/httpd/workpress2.errCustomLog/var/log/httpd/workpress2.accesscommen <Directory "/web/nfs/wp2"> Requireallgranted </Directory> </VirtualHost>
Logout # DocumentRoot "path/"
Configure local IP Address: 172.16.18. {1, 2}
Start service httpd2.4 restart
Create index.html under/web/nfs/javaswp1,wp2.pdf
Wp1/index.html Access:
(3) install the php Module
Install php and let php run based on modules.
Configure apache,/etc/http2.4/httpd. conf to enable Apache to recognize php
1. Add the following two rows:
AddType application/x-httpd-php. php
AddType application/x-httpd-php-source. phps
2. Locate DirectoryIndex index.html
To:
DirectoryIndex index. php index.html
Then restart httpd or re-load the configuration file to test whether php can be used normally.
(4): Install the database:
On centos7, select yum package for installation.
Configuration file:
Cpsupport-files/mysql. server/etc/rc. d/init. d/mysqldchkconfig -- addmysqldchkconfig -- listmysqldcpsupport-files/my-large.cnf/etc/my. cnf # vim/etc/my. cnf Add the following parameter to specify the data DIRECTORY datadir =/mydata/data
Log on to mysql, create a user, and grant all permissions to all databases.
Grant all on *. * 'wp3' @ '192. 16. %. % 'identified by 'wp3'
Disable firewall: systemctl stop firewalld
[Root @ localhostmysql] # mysqlWelcometotheMariaDBmonitor. commandsendwith; or \ g. yourMariaDBconnectionidis2Serverversion: 5.5.39-MariaDBMariaDBServeCopyright (c) 2000,2014, Oracle, MontyProgramAbandothers. type 'help; 'or' \ H' forhelp. type '\ C' toclearthur ecurrentinputstatement.
[Root @ localhost ~] # MysqlMariaDB [mysql]> grantallon *. * to 'wp3 '@ '192. 16. %. %' identifiedby 'wp3 ';
Ii. install WordPress
Copy the wordpress package to/web/nfs/{wp1, wp2}
Unzip. Copy wp-config-sample.php as wp-config.php
Vim wp-config.php.
The configurations of wp1 and wp2 are the same.
Access OK!
This article is from the "aolens Cheng Chao" blog, please be sure to keep this http://aolens.blog.51cto.com/7021142/1541287