zoukankan      html  css  js  c++  java
  • 搭建LAMP及wordpress

    author:JevonWei
    版权声明:原创作品


    • 安装软件包

        [root@danran ~]# yum -y install httpd mariadb-server mariadb php php-mysql 
        [root@danran ~]# systemctl restart httpd
        [root@danran ~]# systemctl start mariadb
        [root@danran ~]# ss -ntl \确认mysql数据库端口336是否打开
        [root@danran ~]# httpd -M \确认php_module模块是否加载
        iptables -F \关闭防火墙
        setenfore 0 
      
    • 设置数据库安全规则

        [root@danran ~]# mysql_secure_installation 
      
    • 安装phpmyadmin数据库管理工具

        phpmyadmin下载 https://www.phpmyadmin.net/
      
        [root@danran ~]# unzip phpMyAdmin-4.4.14.1-all-languages.zip 
        [root@danran ~]# mv phpMyAdmin-4.4.14.1-all-languages /var/www/html/pma
        [root@danran ~]# cd /var/www/html/pma
        [root@danran pma]# ls
        [root@danran pma]# mv config.sample.inc.php config.inc.php  \移动phpmyadmin数据库管理工具的配置文件
        [root@danran ~]# openssl rand -base64 21 \生成一个加密口令
        	sKvkcC9wjYjBKrihpINfXD5FMxmS
      
        [root@danran pma]# vim /var/www/html/pma/config.inc.php \修改配置文件,添加COOKIE的加密口令,即将openssl rand -base64 21生成的口令添加进去
        	$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
        	添加openssl rand -base64 21生成的密码口令后      
        	$cfg['blowfish_secret'] = 'sKvkcC9wjYjBKrihpINfXD5FMxmS'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
        浏览器键入本机IP地址:即192.168.198.128/pma登录phpmyadmin工具的界面时,提示如下错误,则表明缺失mbstring软件包
        	phpMyAdmin - Error
        	The mbstring extension is missing. Please check your PHP configuration.
      
        [root@danran pma]# yum -y install php-mbstring \安装缺失的php-mbstring程序包
        [root@danran pma]# systemctl restart httpd
      
        浏览器输入本机IP地址:即192.168.198.128/pam登录php数据库管理界面,创建数据库及用户,并赋予权限 
        	创建blogdb数据库,wpuser@127.0.0.1用户,并授予wpuser用户管理blogdb数据库的所有权限
        	登录检测
            	[root@danran pma]# mysql -uwpuser -h127.0.0.1 -p
      
    • 安装wordpress

        wordpress官网下载 
        https://cn.wordpress.org/
      
        [root@danran ~]# tar xf wordpress-4.8-zh_CN.tar.gz 
        [root@danran ~]# mv wordpress /var/www/html/blog \复制解压文件到/var/www/html目录下并重命名为blog
        [root@danran ~]# cd /var/www/html/blog
        [root@danran blog]# ls
        	index.php             wp-config-sample.php  wp-mail.php
        	license.txt           wp-content            wp-settings.php
        	readme.html           wp-cron.php           wp-signup.php
        	wp-activate.php       wp-includes           wp-trackback.php
        	wp-admin              wp-links-opml.php     xmlrpc.php
        	wp-blog-header.php    wp-load.php
        	wp-comments-post.php  wp-login.php
        法一、图形界面自动生成wp-config.php文件
        浏览器键入IP地址:即http://192.168.198.128/blog登录wordpress配置数据库名称,用户名、密码即数据库主机,如下图
      

    image
    image

    	如图显示。没有权限,故需执行如下命令添加apache用户对/var/www/html/blog具有所有权限
    	[root@danran html]# setfacl -m u:apache:rwx /var/www/html/blog
    	重新登录http://192.168.198.128/blog ,配置wordpress数据库信息,如下
    

    image
    image
    信息配置完毕

    	[root@danran blog]# vim /var/www/html/blog/wp-config.php \以上过程是用来自动生成此文件
        	define('DB_NAME', 'blogdb');
    
        	/** MySQL数据库用户名 */
        	define('DB_USER', 'wpuser');
    
        	/** MySQL数据库密码 */
        	define('DB_PASSWORD', 'danran');
    
        	/** MySQL主机 */
        	define('DB_HOST', '127.0.0.1');
    
        	/** 创建数据表时默认的文字编码 */
        	define('DB_CHARSET', 'utf8mb4');
    
        	/** 数据库整理类型。如不确定请勿更改 */
        	define('DB_COLLATE', '');
    
    	法二、手动创建/var/www/html/blog/wp-config.php文件
     
    	[root@danran blog]# cp /var/www/html/blog/wp-config-sample.php /var/www/html/blog/wp-config.php \复制wp-config.php模板文件并命名
    	vim /var/www/html/blog/wp-config.php \依次修改如下信息,eg数据库名称,数据库用户名,数据库密码及Mysql主机
        	// ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
        	/** WordPress数据库的名称 */
       	 	define('DB_NAME', 'database_name_here');
    
        	/** MySQL数据库用户名 */
        	define('DB_USER', 'username_here');
    
        	/** MySQL数据库密码 */
        	define('DB_PASSWORD', 'password_here');
    
        	/** MySQL主机 */
        	define('DB_HOST', 'localhost');
    
        	/** 创建数据表时默认的文字编码 */
        	define('DB_CHARSET', 'utf8');
    
        	/** 数据库整理类型。如不确定请勿更改 */
        	define('DB_COLLATE', '');
    
    	登录192.168.198.128/blog设置wprdpress博客的站点信息。如下
    

    image
    image
    安装完成

    	登录数据库查看
    	mysql -uwpuser -h127.0.0.1 -p
    	MariaDB [(none)]> use blogdb;
    	MariaDB [blogdb]> show tables; \博客中的数据都保存在以下表中
    	+-------------------------+
    	| Tables_in_blogdb        |
    	+-------------------------+
    	| jevoncommentmeta        |
    	| jevoncomments           |
     	| jevonlinks              |
    	| jevonoptions            |
    	| jevonpostmeta           |
    	| jevonposts              |
    	| jevonterm_relationships |
    	| jevonterm_taxonomy      |
     	| jevontermmeta           |
    	| jevonterms              |
    	| jevonusermeta           |
    	| jevonusers              |
    	+-------------------------+
    	12 rows in set (0.00 sec)
    
    • 登录博客

        192.168.198.128/blog 
      

    编译安装xcache,加速缓存器

    	[root@danran xcache-3.2.0]# yum -y groupinstall "Development" Tools
    
    	下载xcache
    	[root@danran ~]# tar xvf xcache-3.2.0.tar.gz 
    	[root@danran xcache-3.2.0]# phpize \生成configure文件
    	Can't find PHP headers in /usr/include/php
    	The php-devel package is required for use of this command.
    	[root@danran xcache-3.2.0]# phpize \生成configure文件
    	Configuring for:
    	PHP Api Version:         20100412
    	Zend Module Api No:      20100525
    	Zend Extension Api No:   220100525
    	[root@danran xcache-3.2.0]# ll configure
    	-rwxr-xr-x. 1 root root 414469 Aug  4 20:14 configure
    	[root@danran xcache-3.2.0]# ./configure --enable-xcache --with-php-config=/usr/bin/php-config  
    	[root@danran xcache-3.2.0]# make && make install \默认安装在/usr/lib64/php/mpdules下
    	[root@danran xcache-3.2.0]# cp /root/xcache-3.2.0/xcache.ini /etc/php.d/ \复制配置文件到/etc/目录下
    	[root@danran xcache-3.2.0]# systemctl restart httpd
    danran
  • 相关阅读:
    ZOJ 3949 Edge to the Root( 树形dp)
    CCF201812-3 CIDR合并
    CF700E E. Cool Slogans
    BZOJ4552: [Tjoi2016&Heoi2016]排序
    BZOJ3238: [Ahoi2013]差异
    BZOJ4566: [Haoi2016]找相同字符
    Codeforces Global Round 1 A~F
    (HDU)1555-- How many days? (多少天)
    (HDU)1491-- Octorber 21st (校庆)
    (HDU)1465-- 不容易系列之一
  • 原文地址:https://www.cnblogs.com/JevonWei/p/7287354.html
Copyright © 2011-2022 走看看