安装 apache PHP7.2 maridb
安装apache
这个比较简单 安装、启动、自启
yum install httpd
systemctl start httpd.service
systemctl enable httpd.service
安装7.1
CentOs 7.X
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum search php71w #查看
yum install php71w php71w-fpm php71w-cli php71w-common php71w-devel php71w-gd php71w-pdo php71w-mysql php71w-xml
yum -y install php71w-process //这个是WorkerMan的posix
安装php7.2
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum -y install php72-php php72-php-common php72-php-devel php72-php-gd php72-php-mysqlnd php72-php-pecl-mysql php72-php-pecl-memcached php72-php-pecl-memcache php72-php-pecl-redis php72-php-opcache
配置全局变量
vim /etc/profile
在最后面加上 如果不知道php在哪,先查一下
export PATH=$PATH:/opt/remi/php72/root/usr/bin/php
source /etc/profile
我设置后是要用 php72 -v 这样用着好不爽。所以在 cd /usr/local/bin/ 目录下,ln -s /opt/remi/php72/root/usr/bin/php php 建一个PHP的快捷方式,指向php72命令
安装composer
安装 mysql
1.创建MariaDB.repo文件
vi /etc/yum.repos.d/MariaDB.repo
插入以下内容:
# MariaDB 10.1 CentOS repository list - created 2016-12-01 03:36 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
国内可用
[mariadb]
name = MariaDB
baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.1/centos7-amd64/
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
系统及版本选择:https://downloads.mariadb.org/mariadb/repositories/#mirror=tuna
2.运行安装命令安装MariaDB
yum -y install MariaDB-server MariaDB-client
首先下载安装包,然后进行自动安装,安装成功之后启动MariaDB服务。
systemctl start mariadb #启动服务
systemctl enable mariadb #设置开机启动
systemctl restart mariadb #重新启动
systemctl stop mariadb.service #停止MariaDB
初始化
mysql_secure_installation
首先是设置密码,会提示先输入密码
Enter current password for root (enter for none):<–初次运行直接回车
设置密码
Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
New password: <– 设置root用户的密码
Re-enter new password: <– 再输入一次你设置的密码
其他配置
Remove anonymous users? [Y/n] <– 是否删除匿名用户,回车
Disallow root login remotely? [Y/n] <–是否禁止root远程登录,回车,
Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车
Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车
初始化MariaDB完成,接下来测试登录
mysql -uroot -ppassword
- 配置MariaDB的字符集
文件/etc/my.cnf
vi /etc/my.cnf
在[mysqld]标签下添加
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
文件/etc/my.cnf.d/client.cnf
vi /etc/my.cnf.d/client.cnf
在[client]中添加
default-character-set=utf8
文件/etc/my.cnf.d/mysql-clients.cnf
vi /etc/my.cnf.d/mysql-clients.cnf
在[mysql]中添加
default-character-set=utf8
全部配置完成,重启mariadb
systemctl restart mariadb
之后进入MariaDB查看字符集
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 14
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)]> show variables like "%character%";show variables like "%collation%";
+--------------------------+----------------------------+
| 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.01 sec)
+----------------------+-------------------+
| Variable_name | Value |
+----------------------+-------------------+
| collation_connection | utf8_general_ci |
| collation_database | latin1_swedish_ci |
| collation_server | latin1_swedish_ci |
+----------------------+-------------------+
3 rows in set (0.00 sec)
- ROOT远程连接
进入mysql里面 的mysql表里操作
update user set host = '%' where user = 'root' and host='localhost';
FLUSH PRIVILEGES;//刷新用户权限
远程连接后用软件操作。 操作后可以改回去,这样,外网就没法连数据库了,用的时候再改过来
update user set host = 'localhost' where user = 'root' and host='%';
FLUSH PRIVILEGES;//刷新用户权限
一些操作
httpd 的配置
在httpd.conf 中添加
<VirtualHost *:80>
ServerName wyx2013.cn
ServerAlias www.wyx2013.cn
DocumentRoot "/var/www/html/public/"
<Directory "/var/www/html">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
配置 https
申请证书
用各平台免费的就好
环境
yum 安装openssl和openssl-devel,httpd-devel
重点来了 一定要装 mod_ssl
yum install mod_ssl
这样/etc/httpd/conf.d/ 下会多一个ssl.conf 根据 阿里去提示配置后重启
在ssl.conf中添加或修改
DocumentRoot "/var/www/html/public/"

浙公网安备 33010602011771号