centos安裝配置

2021-08-14 08:24:33 字數 3645 閱讀 3506

1. 最小化安裝

2. 配置hostname

hostnamectl status

hostnamectl set-hostname hostname

3. 關閉selinux

selinux的工作模式一共有三種 enforcing、permissive和disabled 

①enforcing  強制模式:只要是違反策略的行動都會被禁止,並作為核心資訊記錄

②permissive  允許模式:違反策略的行動不會被禁止,但是會提示警告資訊

③disabled  禁用模式:禁用selinux,與不帶selinux系統是一樣的,通常情況下我們在不怎麼了解selinux時,將模式設定成disabled,這樣在訪問一些網路應用時就不會出問題了。

getenforce 檢視當前模式

vi /etc/selinux/config

將selinux=enforcing改為selinux=disabled 

設定後需要重啟才能生效

4. centos/rhel 7.x rpm

rpm -uvh

rpm -uvh

yum公升級

yum -y update

5. 安裝軟體

php安裝

yum install -y php71w php71w-fpm php71w-cli php71w-process php71w-pecl-redis php71w-pdo php71w-mysql php71w-mcrypt php71w-mbstring php71w-gd php71w-devel php71w-pear nginx net-tools telnet libevent-devel subversion wget

nginx、redis、mariadb安裝

yum install -y nginx redis mariadb mariadb-server

其它常用工具

yum -y install gcc net-tools telnet libevent-devel subversion bind-utils wget policycoreutils-python sysstat lsof

4. 修改sshd的埠

vi /etc/ssh/sshd_config

port 2222

防火牆開放2222

firewall-cmd --zone=public --add-port=2222/tcp --permanent

firewall-cmd --reload

systemctl restart sshd

5. mariadb

systemctl enable mariadb

systemctl start mariadb

接下來進行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資料庫,回車

初始化mariadb完成,接下來測試登入

mysql -uroot -ppassword

完成。新增新使用者

grant all privileges on *.* to cxh@"%" identified by 'password' with grant option;

db轉到/data/db/mariadb/

1、建立/data目錄

mkdir -p /data/db/mariadb/

chmod -r 0777 /data/db/mariadb/

2、把mariadb服務停掉:

systemctl stop mariadb

3、把/var/lib/mysql整個目錄複製到/data

cp -r /var/lib/mysql/* /data/db/mariadb/

4、編輯mariadb的配置文件/etc/my.cnf

在[client]下新增:

把原來的socket=/var/lib/mysql/mysql.sock,前邊加#注釋掉,新增socket=/data/mysql.sock(以防有問題再改回來)。

在[mysqld]下新增:

把原來的socket=/var/lib/mysql/mysql.sock,前邊加#注釋掉,新增socket=/data/mysql.sock(以防有問題再改回來)。

datadir =/datal     (這行沒有,需要自己加上)

儲存後退出。

5、 chown -r mysql:mysql /data/mysql

6、重新啟動mariadb服務

systemctl start mariadb

如果需要安裝 swoole

pecl install swoole

#build process completed successfully

#installing '/usr/lib64/php/modules/swoole.so'

#install ok: channel:

#configuration option "php_ini" is not set to php.ini location

#you should add "extension=swoole.so" to php.ini

其它配置

1. 網絡卡配置

vi /etc/sysconfig/network-scripts/ifcfg-eth0

在ifcfg-***[最小數字序列]中修改如下專案,如果專案不存在,則手動新增

bootprot=static             //啟動型別 dhcp|static

ipaddr=192.168.1.204          //ip位址,要設定的靜態ip

netmask=255.255.255.0       //子網掩碼

network=192.168.1.0         //網路位址編號

gateway=192.168.1.1         //閘道器位址,為了訪問外網

onboot=yes                  //開機啟動

dns1=114.114.114.114        //dns伺服器位址,可以不用配置

dns2=192.168.8.95        //dns伺服器位址,可以不用配置

重新網路

systemctl restart network

2. 防火牆禁用

systemctl stop firewalld

systemctl disable firewalld

centos 安裝配置

安裝必要軟體 yum install gcc yum install gcc c yum install vim yum install wget yum insatll zip 網路配置 一 centos 修改ip位址 修改對應網絡卡的ip位址的配置檔案 如果只有一張網絡卡就是eth0,類推 vi...

centos安裝配置

使用vmware安裝磁碟分配 進入系統後配置網絡卡cd etc sysconfig network scripts pwdls vi ifcfg eth0 修改介面配置檔案 進入後做以下修改 hwaddr xx xx xx xx xx xx 注釋掉實體地址防止埠衝突 初始時會分配的 onboot y...

CentOS安裝配置vncserver

參考 安裝 yum install tigervnc server 配置 1 vncserver 設定密碼 確認密碼 2 vi etc sysconfig vncservers 配置內容示例 vncservers 1 root vncserverargs 1 geometry 800x600 dep...