CentOS Linux release 7.9.2009 (Core) 上网设置及VNC服务安装

公司部分业务停用后留下装Linux的服务器,利用起来做点其他用途(node.js服务器)

参考文章:https://blog.csdn.net/SYQ20122012/article/details/124345024

 

一、解决上网

修改配置

/etc/sysconfig/network-scripts/ifcfg-T_QL(我的网络配置文件)

vi ifcfg-T_QL

NAME=T_QL
DEVICE=T_QL
DEVICETYPE=Team
ONBOOT=yes
UUID=62c70044-62d1-488a-a0f9-999999999999
BOOTPROTO=static

DEFROUTE=yes
IPADDR=X.X.2.200
NETMASK=255.255.255.0
DNS1=202.96.128.86
DNS2=8.8.4.4
GATEWAY=X.X.2.1
PREFIX=24
PEERROUTES=yes
DEFROUTE=yes
PEERDNS=no
IPV6INIT=no
IPV4_FAILURE_FATAL=no
TEAM_CONFIG='{"runner": {"name": "activebackup"}, "link_watch": {"name": "ethtool"}}'

二、安装vnc服务

1、安装startx

先安装,执行下列命令:

yum update (更新linux内核)

yum groupinstall "X Window System"

此时如果没安装Server with GUI,startx运行不了;yum grouplist  在可用环境分组显示有:

"Server with GUI"

yum groupinstall "Server with GUI"

安装完Server with GUI 就可以startx

(忽略)yum groupinstall "Desktop"

 

2. 安装vnc服务

安装: wget http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/attach/41181/cn_zh/1504062842088/install_vnc_server.sh

bash install_vnc_server.sh
 

配置:

设置密码:vncpasswd

登录配置(没有忽略):

/etc/systemd/system/vncserver@:1.service

修改配置文件
[root@test1 system]# cat vncserver@:1.service |grep -Ev “^$|^#”
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
User=root
ExecStartPre=/bin/sh -c ‘/usr/bin/vncserver -kill :1 > /dev/null 2>&1 || :’
ExecStart=/usr/sbin/runuser -l root -c “/usr/bin/vncserver :1”
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c ‘/usr/bin/vncserver -kill :1 > /dev/null 2>&1 || :’
[Install]
WantedBy=multi-user.target

 

*防火墙开放端口:

首先判断firewalld是否启动:

sudo firewall-cmd --state 如果not running

启动:

sudo systemctl start firewalld

开放端口

sudo firewall-cmd --permanent --zone=public --add-port=5901-5905/tcp

重新加载防火墙

sudo firewall-cmd --reload

可以使用下面命令查看端口号是否被加入
firewall-cmd --list-all-zones

启动VNC:

vncserver

三、window vnc客户端 输入ip:5901 即可登录linux服务器的gnome图形界面

四、其他:
安装完原来的php网站 用户不能登录,不论密码输入是否正确,都没有任何错误提示,自动跳转回到登录页面。
处理:
修改此目录的权限和属主:
# chown -R nobody:nobody /var/lib/php/session
(nobody权限很低,最好设置它为web运行账户!)
# chmod 777 /var/lib/php/session
(session目录至少设置770权限以上,否则phpmyadmin登录会有问题。)
五、安装Mysql
https://blog.csdn.net/SYQ20122012/article/details/124345024
1、下载安装包

wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
tar -zxvf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.26-linux-glibc2.12-x86_64 /usr/local/mysql

2、创建mysql用户

groupadd mysql
useradd -r -g mysql mysql
mkdir -p /data/mysql
chown mysql:mysql -R /data/mysql

3、创建文件目录

mkdir -p /home/data/mysql
chown mysql:mysql -R /home/data/mysql

4、配置mysql配置文件

vim /etc/my.cnf

"

[mysqld]
bind-address=0.0.0.0
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/home/data/mysql
socket=/home/data/mysql/mysql.sock
symbolic-links=0
lower_case_table_names = 1

[mysqld_safe]
log-error=/home/data/mysql/mariadb.log
pid-file=/home/data/mysql/mariadb.pid
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true
!includedir /etc/my.cnf.d

"

5、启动

rpm -qa|grep libaio

yum install libaio-devel.x86_64
cd /usr/local/mysql/bin/
./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/home/data/mysql --user=mysql --initialize
//\u8fd9\u91cc\u4e00\u5b9a\u8981\u4fdd\u6301\u597d\u521d\u59cb\u5316\u7684\u5bc6\u7801\uff0c\u5728\u8fd9\u4e2a\u547d\u4ee4\u6267\u884c\u5b8c\u6bd5\u4e4b\u540e\uff0c \u4f1a\u6709\u4e00\u4e2a [Note] A temporary password is generated for root@localhost: geM=Zb5uwffR \u5176\u4e2dgeM=Zb5uwffR\u5c31\u662f\u521d\u59cb\u5316\u5bc6\u7801\uff0c\u5343\u4e07\u4e0d\u8981\u5fd8\u8bb0
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
service mysql start
ps -ef|grep mysql //\u67e5\u770b\u8fdb\u7a0b

6、修改密码

cd /usr/local/mysql/bin
ln -s /home/data/mysql/mysql.sock /tmp/mysql.sock
./mysql -u root -p
//\u9700\u8981\u8f93\u5165\u5bc6\u7801\uff1ageM=Zb5uwffR
SET PASSWORD = PASSWORD('GqUoAnGm0bo=');
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
FLUSH PRIVILEGES;

7、修改访问权限

use mysql
update user set host = '%' where user = 'root'; #\u4f7froot\u80fd\u518d\u4efb\u4f55host\u8bbf\u95ee
FLUSH PRIVILEGES;

8、添加PATH 路径

\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u6765\u5c06mysql\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684PATH\u8def\u5f84\u4e0b\uff1a
echo 'export PATH="$PATH:/usr/local/mysql/bin"' >> ~/.bash_profile
\u4e4b\u540e\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7source\u547d\u4ee4\u6765\u4f7f\u914d\u7f6e\u6587\u4ef6\u751f\u6548\uff1a
source ~/.bash_profile

更改密码时:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
可能密码输入错误,或者看看
重启动
service mysql start
之后有更新后 /eyc/my.cnf 被改my.cnf.rpmsave ,再恢复
运行
service mysql start出现 ERROR! The server quit without updating PID file 
将 my.cnf

!includedir /etc/my.cnf.d 注释 # ,再启动即可




六、Nodejs 安装

wget https://nodejs.org/dist/v12.16.3/node-v12.16.3-linux-x64.tar.gz

tar -zxvf node-v12.16.3-linux-x64.tar.gz -C /usr/local/

cd /usr/local/

mv node-v12.16.3-linux-x64/ nodejs

ln -s /usr/local/nodejs/bin/node /usr/local/bin

ln -s /usr/local/nodejs/bin/npm /usr/local/bin

npm install --unsafe-perm

mkdir ~/.npm-global

npm config set prefix '~/.npm-global'

export PATH=~/.npm-global/bin:$PATH

npm config set registry https://registry.npm.taobao.org

source ~/.profile

安装cnpm

注意:npm命令运行出错 (bash: npm: 未找到命令…):

sudo ln -s /usr/local/nodejs/bin/* /usr/bin/



 

posted @ 2022-11-28 14:43  realhopezj  阅读(1519)  评论(0编辑  收藏  举报