663424 发表于 2017-2-10 17:15:18

LAMP网站架构的基础构思及搭建解析——CentOS7.0

                      LAMP的定义:lamp:指Linux(操作系统)、Apache(HTTP 服务器)、MySQL/MariaDB(数据库软件) 、以及PHP/perl/python(j脚本语言)所组成的架构,一般用于建立web应用平台。
环境:本地系统操作,无防火墙影响。系统:CentOS7.0 ip:172.25.254.3cat /etc/yum.repo/server.repo   ——配置yum仓库(本地)name=serverbaseurl=file:///mnt eabled=1gpgcheck=0mount /dev/cdrom /mnt         yum -y install php php-mysql httpd mariadb-server   ——安装所需服务安装包cat /var/www/html/index.php      ——配置主页php文件 <?phpphpinfo();?>systemctl restart httpd ; systemctl enable httpd ;systemctl restart mariadb ;systemctl enable mariadb                  ——重启服务,并保证永久生效firefox localhost         mysqlMariaDB [(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 # 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 ServerCopyright (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)]>exitByevim /var/www/html/index.php       <?php$conn = mysql_connect(“172.25.254.3”,”testuser”,”testpass”);——配置php与数据库连接if ($conn)echo “OK”;elseecho “NO”;?>setenforce 0               ——关闭selinuxfirefox localhost            ——测试页面显示“OK”,则配置成功
上传博客wordpress-3.3.1-zh_CN.zip到根目录unzip wordpress-3.3.1-zh_CN.zip         ——解压开发好的博客压缩包# lsbin    etc   lib64   opt   run   sysvarboot   home   media   proc   sbintmpwordpressdev    lib   mnt    root   srv   usrwordpress-3.3.1-zh_CN.zip# mv wordpress /var/www/html/   ——移动到/var/ww/html可供web访问# cd /var/www/html/# cd wordpress/# lsindex.php          wp-config-sample.php         wp-pass.phplicense.txt         wp-content               wp-register.phpreadme.html         wp-cron.php            wp-settings.phpwp-activate.php      wp-includes            wp-signup.phpwp-admin         wp-links-opml.php         wp-trackback.phpwp-app.php         wp-load.php            xmlrpc.phpwp-blog-header.php    wp-login.phpwp-comments-post.php   wp-mail.php# cp wp-config-sample.php wp-config-sample.php.back   ——备份# mv wp-config-sample.php wp-config.php   ——改名为配置文件名# mysqlWelcome to the MariaDB monitor.Commands end with ; or \g.Your MariaDB connection id is 10Server version: 5.5.44-MariaDB MariaDB ServerCopyright (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)]> exitBye# 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]
查看完整版本: LAMP网站架构的基础构思及搭建解析——CentOS7.0