LAMP网站架构的基础构思及搭建解析——CentOS7.0
admin
2023-05-28 04:41:31
0次

LAMP的定义:

lamp:指Linux(操作系统)、Apache(HTTP 服务器)、MySQL/MariaDB(数据库软件) 、以及PHP/perl/python(j脚本语言)所组成的架构,一般用于建立web应用平台。


环境:本地系统操作,无防火墙影响。

系统:CentOS7.0 

ip:172.25.254.3

[root@localhost /]cat /etc/yum.repo/server.repo     ——配置yum仓库(本地)

[base]

name=server

baseurl=file:///mnt 

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       

$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


相关内容

热门资讯

空调连续工作多久需要停机休息 空调连续工作的时间取决于多个因素,包括空调的型号、功率、使用环境和维护情况等。一般来说,空调可以连续...
空调哪个符号是除湿的 空调除湿功能通常用一个水滴形状的符号表示。不同品牌和型号的空调遥控器可能会有所差异,但一般来说,除湿...
格力空调多长时间加一次氟利昂 1、一般情况下,空调对氟利昂的使用量是非常小的,所以在空调使用了四年左右的时候再考虑加也没问题。2、...
空调用多长时间需要加氟一次 一般情况下是五年。当出现以下这几种情况时,空调才需要加氟。1、空调的室内机和室外机各有两个接口,当接...
格调生活·C标思享荟:卡萨帝在... 9月12日的郑州龙湖金融岛,夜风轻拂,灯光璀璨。“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑...
品牌价值破千亿、高端份额持续领... 9月12日,“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑州站”在郑州龙湖金融岛举办。2026...
空调主板坏了修800还是换新的 空调主板坏了是修还是换新,需要考虑多个因素,以下是一些建议:1. 维修成本:如果维修费用较低,比如 ...
空调开多久需要休息多长时间 问题:空调开多久需要休息多长时间回答:1、在使用空调的过程中,一般空调开7~8个小时左右需要休息2~...
中央空调多长时间清洗一次 1、一般空调开机前清洗一次即可,空调开机中间时段再清洗一次,空调关机时清洗一次,这样比较合理。2、空...
中央空调氟利昂多久加一次 看空调制热和制冷程度,很多人的观点认为氟利昂必须一年放一次,其实这个观点是错误的,理解上面有点偏差,...