准备新的虚拟机,修改主机名并配置yum源(所需包 lnmp+wordpress.zip)

  1. hostnamectl set-hostname lnmp
  2. vi /etc/yum.repos.d/local.repo //配置yum源
  3. [centos]
  4. name=centos
  5. baseurl=file:///opt/centos
  6. gpgcheck=0
  7. enabled=1
  8. [lnmp]
  9. name=lnmp
  10. baseurl=file:///root/lnmp
  11. gpgcheck=0
  12. enabled=1
  13. 先下载解压缩
  14. yum insatall -y unzip
  15. 下载所需要的依赖
  16. yum -y install nginx mariadb-server mariadb php-fpm php-mysql

NGINX

  1. ystemctl start nginx && systemctl enable nginx
  2. # vi /etc/nginx/conf.d/default.conf
  3. location / {
  4. root /usr/share/nginx/html;
  5. index index.php index.html index.htm;
  6. }
  7. location ~ \.php$ {
  8. root /usr/share/nginx/html;
  9. fastcgi_pass 127.0.0.1:9000;
  10. fastcgi_index index.php;
  11. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  12. include fastcgi_params;
  13. }
  14. # systemctl restart nginx //重启服务

MYAQL

  1. systemctl start mariadb && systemctl enable mariadb //启动数据库
  2. # mysql_secure_installation //初始化数据库
  3. # mysql -uroot -p123456 //登录数据库
  4. > create database wordpress; //创建数据库服务
  5. > grant all privileges on *.* to root@localhost identified by '123456' with grant option; //授权所有用户拥有本地数据库的所有权限。
  6. > grant all privileges on *.* to root@"%" identified by '123456' with grant option; //授权用户可进行远程登录

PHP

  1. vi /etc/php-fpm.d/www.conf
  2. 39 user = nginx
  3. 40 ; RPM: Keep a group allowed to write in log dir.
  4. 41 group = nginx
  5. systemctl start php-fpm && systemctl enable php-fpm

Wordpress

  1. unzip wordpress-4.7.3-zh_CN.zip
  2. cd /usr/share/nginx/html
  3. rm -rf *
  4. cp -rvf /root/wordpress* ./
  5. cp wp-config-sample.php wp-config.php
  6. chmod 777 *
  7. vi wp-config.php
  8. // ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
  9. /** WordPress数据库的名称 */
  10. define('DB_NAME', 'wordpress');
  11. 使用Curl命令,返回前端页面
  12. /** MySQL数据库用户名 */
  13. define('DB_USER', 'root');
  14. /** MySQL数据库密码 */
  15. define('DB_PASSWORD', '123456');
  16. /** MySQL主机 */
  17. define('DB_HOST', '127.0.0.1');