1. 程式人生 > >基於 LAPM 搭建 wordpress blog

基於 LAPM 搭建 wordpress blog

- - -  LAMP

Linux作為作業系統ApacheNginx作為 Web 伺服器,MySQL 作為資料庫,PHP/Perl/Python作為伺服器端指令碼直譯器。由於這四個軟體都是免費或開放原始碼軟體(FLOSS),因此使用這種方式不用花一分錢(除開人工成本)就可以建立起一個穩定、免費的網站系統,被業界稱為“LAMP“或“LNMP”組合。

一   安裝服務

[[email protected]@HuangKai ~]# yum install -y httpd php php-mysql mariadb-server

二   編輯httpd的配置檔案

[[email protected]
@HuangKai ~]# vim /etc/httpd/conf.d/vhost.conf
  1 <VirtualHost *:80>    
  2     ServerName  mage.com
  3     DocumentRoot "/app/blog/htdocs" 
  4     CustomLog "logs/blog.mage.com_access_log" combined  
  5     <Directory "/app/blog/htdocs">
  6     Require all granted
  7     </Directory>
  8 </VirtualHost>
[[email protected]@HuangKai ~]# systemctl restart httpd

三   編輯MySQL的配置檔案 

  1 [mysqld]
  2 datadir=/var/lib/mysql
  3 log_bin=/mysql/logbin
  4 skip_name_resolve      ------- 新增跳過域名解析引數
  5 innodb_file_per_table
  6 socket=/var/lib/mysql/mysql.sock
  7 # Disabling symbolic-links is recommended to prevent assorted security risks
  8 symbolic-links=0
  9 # Settings user and group are ignored when systemd is used.
 10 # If you need to run mysqld under a different user or group,
 11 # customize your systemd unit file for mariadb according to the
 12 # instructions in http://fedoraproject.org/wiki/Systemd
 13 
 14 [mysqld_safe]
 15 log-error=/var/log/mariadb/mariadb.log
 16 pid-file=/var/run/mariadb/mariadb.pid
 17 
 18 # 
 19 # include all files from the config directory
 20 #
 21 !includedir /etc/my.cnf.d
[[email protected]@HuangKai ~]# systemctl restart mariadb.service 

 四   建立httpd配置檔案裡所指定的目錄,然後把下好的wordpress包解壓過來

[[email protected]@HuangKai ~]# mkdir -pv /app/blog/
mkdir: created directory ‘/app/blog’
[[email protected]@HuangKai ~]# tar -xvf wordpress-4.9.4-zh_CN.tar.gz -C /app/blog/
[[email protected]@HuangKai blog]# ln -sv wordpress htdocs
‘htdocs’ -> ‘wordpress’
[[email protected]@HuangKai blog]# ll
total 4
lrwxrwxrwx. 1 root   root         9 Oct 21 18:03 htdocs -> wordpress
drwxr-xr-x. 5 nobody nfsnobody 4096 Feb  8  2018 wordpress
[[email protected]@HuangKai blog]# cd htdocs/
[[email protected]@HuangKai htdocs]# ls
index.php        wp-admin              wp-content         wp-load.php      wp-signup.php
license.txt      wp-blog-header.php    wp-cron.php        wp-login.php     wp-trackback.php
readme.html      wp-comments-post.php  wp-includes        wp-mail.php      xmlrpc.php
wp-activate.php  wp-config-sample.php  wp-links-opml.php  wp-settings.php
[[email protected]@HuangKai blog]# setfacl -m u:apache:rwx htdocs/

五   建立資料庫和賬戶 

[[email protected]@HuangKai blog]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database wpdb;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all on wpdb.* to 'wpuser'@'172.18.7.%' identified by 'wppass';
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> quit
Bye

六   分別在Windows和Linux下的houst檔案裡寫入  172.18.7.117   mage.com

 

 

[[email protected]@HuangKai htdocs]# vim /etc/hosts

172.18.7.117 mage.com

 七   最後關閉防火牆和selinux即可

[[email protected]@HuangKai htdocs]# systemctl stop firewalld 
[[email protected]@HuangKai htdocs]# setenforce 0

 

 

 這樣就成功的搭建了一個自己的部落格網站,當然這是虛擬機器上的操作。有興趣的朋友也可以買個雲伺服器搭建一個真實的個人部落格網站