個(gè)人筆記

[配置環(huán)境變量]

1. vim /etc/profile 末尾加入 export PATH="$PATH:命令路徑"
2. source /etc/profile  環(huán)境變量立即生效   

[php安裝]

1. 擴(kuò)展

    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. 測(cè)試 php composer.phar

3. 移動(dòng)到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. 啟動(dòng)Mysql服務(wù): systemctl start mysqld

5. 設(shè)置開機(jī)啟動(dòng): systemctl enable mysqld; systemctl daemon-reload

6. 修改root本地登錄密碼: grep "A temporary password is generated for root@localhost" /var/log/mysqld.log (查看默認(rèn)密碼)

7. 更改root賬戶臨時(shí)密碼: ALTER USER 'root'@'localhost' IDENTIFIED BY 'Waizsy@9083';

8. 遠(yuǎn)程訪問(wèn): 修改mysql庫(kù)user表 update user set host = '%' where user = 'root'; GRANT ALL ON *.* TO 'root'@'%'; FLUSH PRIVILEGES 

9. mysql8.0密碼策略默認(rèn)為caching_sha2_password。與5.7策略caching_sha_password有所不同 (現(xiàn)在有很多語(yǔ)言及連接工具不支持); 
    
    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   查看防火墻狀態(tài)

2. systemctl stop firewalld.service 關(guān)閉防火墻

3. systemctl disable firewalld.service 禁止firewall開機(jī)啟動(dòng)

[mysql主從配置]

1.  配置主庫(kù):
    
    vim /etc/my.cnf
    
    [mysqld]
        log-bin=mysql-bin           #同步的日志路徑及文件名,一定注意這個(gè)目錄要是mysql有權(quán)限寫入的(配置不成功就用默認(rèn))
        server-id=1                 #master端的ID號(hào)
        binlog-do-db=test           #要同步的數(shù)據(jù)庫(kù)名
        binlog-ignore-db = mysql    #不同步mysql庫(kù)
    
    重啟服務(wù):service mysqld restart
    查看bin-log: show master status;
    
2.  創(chuàng)建訪問(wèn)用戶:

    CREATE USER 'salveUsers'@'%' IDENTIFIED BY 'salveUsers@1234';                           #創(chuàng)建用戶

    GRANT ALL PRIVILEGES ON *.* TO 'salveUsers'@'%'  IDENTIFIED BY 'salveUsers@1234';       #授權(quán)給從數(shù)據(jù)庫(kù)服務(wù)器權(quán)限     
    
3. 配置從庫(kù)
    
    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;        #啟動(dòng)slave進(jìn)程
    
    show slave status\G #查看slave進(jìn)程狀態(tài) Slave_IO_Running: Yes; Slave_SQL_Running: Yes  表示配置正確

[同步主庫(kù)已有數(shù)據(jù)到從庫(kù)]

1. 主庫(kù)
    flush tables with read lock;   #停止主庫(kù)的數(shù)據(jù)更新操作

    mysqldump -uroot -ptest123 cmdb > cmdb.sql  #導(dǎo)出數(shù)據(jù)庫(kù)
    
    unlock tables;  #主庫(kù)解鎖

2. 從庫(kù)
    
    stop slave;     #停止slave進(jìn)程
    
    導(dǎo)入數(shù)據(jù)
     
    start slave;    #啟動(dòng)slave進(jìn)程

[nginx安裝]

1. touch nginx.repo    [nginx安裝說(shuō)明](http://nginx.org/en/linux_packages.html)

2. 添加以下內(nèi)容
```
    [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. 新建代碼存放目錄: 主服務(wù)器: /www/default/code     從服務(wù)器: /www/default/code

3. 配置nginx

```
#主服務(wù)器: 192.168.204.128:9000;
#從服務(wù)器: 192.168.204.129:9000;

upstream myServer{
    least_conn;    #把請(qǐng)求轉(zhuǎn)發(fā)給連接數(shù)較少的后端服務(wù)器
    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;
}
```
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容