个人笔记
2019-07-01 本文已影响0人
Marius66
[配置环境变量]
1. vim /etc/profile 末尾加入 export PATH="$PATH:命令路径"
2. source /etc/profile 环境变量立即生效
[php安装]
1. 扩展
yum -y install gcc gcc-c++ libmcrypt-devel mcrypt mhash gd-devel ncurses-devel libxml2-devel bzip2-devel libcurl-devel curl-devel libjpeg-devel libpng-devel freetype-devel net-snmp-devel openssl-deve python-devel zlib-devel freetype libxslt-devel bison autoconf re2c
yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
2. 编译
./configure --prefix=/data/php/php7.2 --with-config-file-path=/data/php/etc --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip
3. 安装
make && make install
[composer]
1. 下载 curl -sS https://getcomposer.org/installer | php
2. 测试 php composer.phar
3. 移动到php bin目录
4. 使用 composer install ###安装 composer update ### 更新
[mysql]
1. 下载mysql源: wget https://repo.mysql.com/mysql80-community-release-el7.rpm
2. 安装mysql源: yum -y localinstall mysql80-community-release-el7.rpm
3. 在线安装MySQL: yum -y install mysql-community-server
4. 启动Mysql服务: systemctl start mysqld
5. 设置开机启动: systemctl enable mysqld; systemctl daemon-reload
6. 修改root本地登录密码: grep "A temporary password is generated for root@localhost" /var/log/mysqld.log (查看默认密码)
7. 更改root账户临时密码: ALTER USER 'root'@'localhost' IDENTIFIED BY 'Waizsy@9083';
8. 远程访问: 修改mysql库user表 update user set host = '%' where user = 'root'; GRANT ALL ON *.* TO 'root'@'%'; FLUSH PRIVILEGES
9. mysql8.0密码策略默认为caching_sha2_password。与5.7策略caching_sha_password有所不同 (现在有很多语言及连接工具不支持);
9.1 ALTER USER 'root'@'%' IDENTIFIED BY 'Waizsy@9083' PASSWORD EXPIRE NEVER;
9.2 ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Waizsy@9083';
9.3 FLUSH PRIVILEGES; (配置生效)
[liunx防火墙]
1. firewall-cmd --state 查看防火墙状态
2. systemctl stop firewalld.service 关闭防火墙
3. systemctl disable firewalld.service 禁止firewall开机启动
[mysql主从配置]
1. 配置主库:
vim /etc/my.cnf
[mysqld]
log-bin=mysql-bin #同步的日志路径及文件名,一定注意这个目录要是mysql有权限写入的(配置不成功就用默认)
server-id=1 #master端的ID号
binlog-do-db=test #要同步的数据库名
binlog-ignore-db = mysql #不同步mysql库
重启服务:service mysqld restart
查看bin-log: show master status;
2. 创建访问用户:
CREATE USER 'salveUsers'@'%' IDENTIFIED BY 'salveUsers@1234'; #创建用户
GRANT ALL PRIVILEGES ON *.* TO 'salveUsers'@'%' IDENTIFIED BY 'salveUsers@1234'; #授权给从数据库服务器权限
3. 配置从库
CHANGE MASTER TO MASTER_HOST='192.168.204.128',MASTER_PORT=3306,MASTER_USER='salveUsers',MASTER_PASSWORD='salveUsers@1234',MASTER_LOG_FILE='mysql-bin.000001',MASTER_LOG_POS=155;
start slave; #启动slave进程
show slave status\G #查看slave进程状态 Slave_IO_Running: Yes; Slave_SQL_Running: Yes 表示配置正确
[同步主库已有数据到从库]
1. 主库
flush tables with read lock; #停止主库的数据更新操作
mysqldump -uroot -ptest123 cmdb > cmdb.sql #导出数据库
unlock tables; #主库解锁
2. 从库
stop slave; #停止slave进程
导入数据
start slave; #启动slave进程
[nginx安装]
1. touch nginx.repo [nginx安装说明](http://nginx.org/en/linux_packages.html)
2. 添加以下内容
```
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
```
3. yum install nginx
[php分布式配置]
1. php-fpm配置
```
listen = [::]:9000
```
2. 新建代码存放目录: 主服务器: /www/default/code 从服务器: /www/default/code
3. 配置nginx
```
#主服务器: 192.168.204.128:9000;
#从服务器: 192.168.204.129:9000;
upstream myServer{
least_conn; #把请求转发给连接数较少的后端服务器
server 127.0.0.1:9000;
server 192.168.204.129:9000;
}
server
{
listen 9083;
#listen [::]:80;
server_name 192.168.204.128 ;
index index.html index.htm index.php default.html default.htm default.php;
root /www/default/code;
location / {
index index.html index.php;
#include /www/default/conf/*.conf;
}
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
#include enable-php.conf;
location ~ \.php$ {
fastcgi_pass myServer; #主要配置这里
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log off;
}
```