PHP 实验练习环境搭建 LAMP

LAM(mariaDB)P

服务器IP192.168.100.30
LinuxCentos7.5 1804 /2G/4vcpu/40GB
Apache端口8080 /var/www/html
MariaDB端口3306,编码:utf-8 , user:root ,password:000000
PHPphp-5.4

安装相关yum源软件包

yum -y install httpd mariadb-server mariadb phph php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml  php-xmlrpc 

修改相关配置文件

  • character_set_client为客户端编码方式
  • character_set_connection为建立连接使用的编码
  • character_set_database数据库的编码
  • character_set_results结果集的编码
  • character_set_server数据库服务器的编码
  • Latin1是ISO-8859-1的别名,有些环境下写作Latin-1。ISO-8859-1编码是单字节编码,向下兼容ASCII,其编码范围是0x00-0xFF,0x00-0x7F之间完全和ASCII一致,0x80-0x9F之间是控制字符,0xA0-0xFF之间是文字符号。
  • UTF-8(8位元,Universal Character Set/Unicode Transformation Format)是针对Unicode的一种可变长度字符编码。它可以用来表示Unicode标准中的任何字符,而且其编码中的第一个字节仍与ASCII相容,使得原来处理ASCII字符的软件无须或只进行少部分修改后,便可继续使用。因此,它逐渐成为电子邮件、网页及其他存储或传送文字的应用中,优先采用的编码。
  • 对应用程序来说,强制将它们发起的数据库链接设置成UTF8编码有什么办法?
    每个链接建立时先执行set names utf8;
    [mysqld]
    init-connect=‘set names utf8’
    语句set names UTF8是什么作用?
    比如一个set names语句相当于执行了以下三行语句
    SET character_set_client = charset_name
    SET character_set_results = charset_name
    SET character_set_connection = charset_name
[root@localhost ~]# mysql -uroot -p000000
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.65-MariaDB MariaDB Server

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

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

MariaDB [(none)]>   SHOW VARIABLES LIKE 'character%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | latin1                     |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | latin1                     |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

MariaDB [(none)]>exit;

[root@localhost ~]# sed -i '/\[mysqld\]/a\character_set_server=utf8' /etc/my.cnf
[root@localhost ~]# sed -i '/\[mysqld\]/a\init_connect="SET NAMES utf8"' /etc/my.cnf

[root@localhost ~]# systemctl restart mariadb
[root@localhost ~]# mysql -h localhost -P3306 -uroot   -p'000000' -se "show variables like 'char%'";
Variable_name   				Value
character_set_client    		utf8
character_set_connection        utf8
character_set_database  		utf8
character_set_filesystem        binary
character_set_results   		utf8
character_set_server    		utf8
character_set_system    		utf8
character_sets_dir      		/usr/share/mysql/charsets/



[root@localhost ~]# vi /etc/httpd/conf/httpd.conf
##修改一下参数
ServerName localhost:8080
Listen 8080

启动相关服务

systemctl restart httpd  
systemctl restart mariadb

在相应目录下编写脚本测试文件

[root@localhost ~]# cat /var/www/html/test.php
<?php
        phpinfo();
?>
[root@localhost ~]#

在浏览器访问网址

http://192.168.100.30:8080/test.php

在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

啊酒弟弟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值