LAMP的定義:php
lamp:指Linux(操做系統)、Apache(HTTP 服務器)、MySQL/MariaDB(數據庫軟件) 、以及PHP/perl/python(j腳本語言)所組成的架構,通常用於創建web應用平臺。html
環境:本地系統操做,無防火牆影響。python
系統:CentOS7.0 mysql
ip:172.25.254.3linux
[root@localhost /]cat /etc/yum.repo/server.repo ——配置yum倉庫(本地)web
[base]sql
name=server數據庫
baseurl=file:///mnt vim
eabled=1服務器
gpgcheck=0
[root@localhost /]mount /dev/cdrom /mnt
[root@localhost /]yum -y install php php-mysql httpd mariadb-server ——安裝所需服務安裝包
[root@localhost /]cat /var/www/html/index.php ——配置主頁php文件
<?php
phpinfo();
?>
[root@localhost /]systemctl restart httpd ; systemctl enable httpd ;systemctl restart mariadb ;systemctl enable mariadb ——重啓服務,並保證永久生效
[root@localhost /]firefox localhost
[root@localhost /]mysql
MariaDB [(none)]> GRANT ALL ON testdb.* TO testuser@'%' IDENTIFIED BY 'testpass';
——容許testuser用戶以任何形式登陸
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> FLUSH PRIVILEGES; ——當即生效
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye
[root@localhost /]# mysql -u testuser -h 172.25.254.3 -p ——測試testuser登陸testdb數據庫
Enter password:testpass
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.44-MariaDB MariaDB Server
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>exit
Bye
[root@localhost /]vim /var/www/html/index.php
<?php
$conn = mysql_connect(「172.25.254.3」,」testuser」,」testpass」); ——配置php與數據庫鏈接
if ($conn)
echo 「OK」;
else
echo 「NO」;
?>
[root@localhost /]setenforce 0 ——關閉selinux
[root@localhost /]firefox localhost ——測試頁面顯示「OK」,則配置成功
上傳博客wordpress-3.3.1-zh_CN.zip到根目錄
[root@localhost /]unzip wordpress-3.3.1-zh_CN.zip ——解壓開發好的博客壓縮包
[root@localhost /]# ls
bin etc lib64 opt run sys var
boot home media proc sbin tmp wordpress
dev lib mnt root srv usr wordpress-3.3.1-zh_CN.zip
[root@localhost /]# mv wordpress /var/www/html/ ——移動到/var/ww/html可供web訪問
[root@localhost /]# cd /var/www/html/
[root@localhost html]# cd wordpress/
[root@localhost wordpress]# ls
index.php wp-config-sample.php wp-pass.php
license.txt wp-content wp-register.php
readme.html wp-cron.php wp-settings.php
wp-activate.php wp-includes wp-signup.php
wp-admin wp-links-opml.php wp-trackback.php
wp-app.php wp-load.php xmlrpc.php
wp-blog-header.php wp-login.php
wp-comments-post.php wp-mail.php
[root@localhost wordpress]# cp wp-config-sample.php wp-config-sample.php.back ——備份
[root@localhost wordpress]# mv wp-config-sample.php wp-config.php ——更名爲配置文件名
[root@localhost wordpress]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.44-MariaDB MariaDB Server
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> GRANT ALL ON wpdb.* TO wpuser@'%' IDENTIFIED BY 'wppass';
Query OK, 0 rows affected (0.02 sec)
MariaDB [(none)]> create database wpdb;
Query OK, 1 row affected (0.02 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye
[root@localhost wordpress]# vim wp-config.php ——更改配置文件,博客與數據庫相關聯
// ** MySQL 設置 - 具體信息來自您正在使用的主機 ** //
/** WordPress 數據庫的名稱 */
define('DB_NAME', 'wpdb');
/** MySQL 數據庫用戶名 */
define('DB_USER', 'wpuser');
/** MySQL 數據庫密碼 */
define('DB_PASSWORD', 'wppass');
/** MySQL 主機 */
define('DB_HOST', '172.25.254.3');
火狐訪問主機:localhost/wordpress,按需求安裝wordpress