LAMP的環境原理
LAMP:是由Linux、Apache(httpd)、MySQL/MariaDB和PHP/Perl/Python這些開源軟件所搭建起來的web應用平臺。平臺主機可以是獨立的也可以在一臺主機上
訪問流程:客戶端訪問web服務,web服務器遵循二八法則直接將大部分靜態訪問資源反饋給客戶,如果是動態資源則通過FastCGI協議調用php程序獲取數據庫的數據處理成為靜態資源在返回給客戶。
LAMP:web平臺的搭配:
web服務器 | 腳本 | 數據庫 |
---|---|---|
httpd / nginx | PHP:fpm | Mysql |
jsp:tomcat | MariaDB | |
Python:Django | … | |
ruby:ror |
使用一臺主機搭建 wordpress博客
1、安裝web服務器(httpd)
[root@ ~]# yum -y install httpd
配置:
[root@ ~]# vim /etc/httpd/conf/httpd.conf
ServerName www.example.com:80 去掉注釋
[root@ ~]# httpd -t 檢查語法錯誤
[root@ ~]# systemctl start httpd.service 啟動服務
[root@ ~]# ss -tnl 查看端口
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:80 *:*
LISTEN 0 128 *:22 *:*
2、安裝腳本php-fpm
[root@ ~]# yum -y install php
3、安裝數據庫,創建數據庫 wordpress,用戶名 admin,密碼 admin
[root@ ~]# yum -y install mariadb-server
[root@ ~]# mysql
...
...
MariaDB [(none)]> GRANT ALL ON wordpress.* TO 'admin'@'%' IDENTIFIED BY 'admin';
MariaDB [(none)]>exit
Bye
創建格式:GRANT ALL ON wordpress.* ‘user’@’IP’ IDENTIFIED BY ‘password’
IP域限制例如172.16.%.% ,172.16.1.% ;
測試:
[root@ ~]# mysql -uadmin -h192.168.1.2 -padmin
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
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)]> exit
Bye
4、安裝擴展php-mysql
[root@ ~]# yum -y install php-mysql
5、配置安裝 wordpress
1、wordpress博客是一個動態資源站點,當客戶端訪問時需要通過腳本服務器的php-fpm腳本來進行數據處理實現用戶與站點的交互。
服務器環境要求
* PHP 5.2.4或更新版本
* MySQL 5.0或更新版本
* Apache mod_rewrite模塊(可選,用于支持“固定鏈接”和“站點網絡”功能)
[root@ ~]# mkdir /wordpress
[root@ ~]# cd /wordpress
[root@ ~]# wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.zip
[root@ ~]# unzip wordpress-4.9.4-zh_CN.zip
[root@ ~]# cp -a wordpress /var/www/html/blog
[root@ ~]# cd /var/www/html/blog
[root@ ~]# cp wp-config-sample.php wp-config.php
[root@ ~]# vim wp-config.php
// ** MySQL 設置 - 具體信息來自您正在使用的主機 ** //
/** WordPress數據庫的名稱 */
define('DB_NAME', 'wordpress');
/** MySQL數據庫用戶名 */
define('DB_USER', 'admin');
/** MySQL數據庫密碼 */
define('DB_PASSWORD', 'admin');
/** MySQL主機 */
define('DB_HOST', '192.168.1.2');
6、瀏覽器打開進行安裝配置即可
- 登錄主頁:192.168.1.2/blog
- 登錄后臺:192.168.1.2/blog/wp-login.php
注意:跳過域名解析 -如果服務器設置了域名解析,修改配置文件
[root@ ~]# vim /etc/my.cnf.d/server.cnf
添加一項:
skip-name-resolve=ON 跳過主機名解析。
關閉SELinux
[root@localhost blog]# setenforce 0
[root@localhost blog]# getenforce
Permissive
馬哥筆記?網絡資料?網絡資料2?網絡資料3?百度百科?網絡資料4 php-fpm是什么
本文來自投稿,不代表Linux運維部落立場,如若轉載,請注明出處:http://www.www58058.com/101646