当前位置: 首页 > Linux

个人服务器常用基本配置

时间:2023-04-06 02:05:08 Linux

买了一台服务器,系统是CentOS7.2。我做了一些基本的设置,记录在这里。更新yum源码仓库yumupdate安装Gityum源码仓库最新版本的Git是1.8.3.1,不过官方最新版本已经到了2.9.2。如果要安装最新版本的Git,只能下载源码安装。可以通过info命令查看源码仓库中的git信息$yuminfogit在开始编译安装git之前,需要安装一些依赖$yuminstallcurl-develexpat-develgettext-developenssl-develzlib-devel$yuminstallgccperl-ExtUtils-MakeMaker下载源码压缩包,解压后编译安装$wgethttps://www.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz-Ogit.tar.gz$tar-zxfgit.tar.gz$cdgit.tar.gz$makeprefix=/usr/localall$sudomakeprefix=/usr/localinstall所有版本都可以在这里找到。安装fish-shellCentOS6和CentOS7使用的源不同,需要注意://CentOS7$cd/etc/yum.repos.d/$wgethttps://download.opensuse.org/repositories/shells:fish:release:2/CentOS_7/shells:fish:release:2.repo$yuminstallfish//CentOS6$cd/etc/yum.repos.d/$wgethttps://download.opensuse.org/repositories/shells:fish:release:2/CentOS_6/shells:fish:release:2.repo$yuminstallfish安装oh-my-fishcurl-Lhttps://get.oh-my.fish|fishinstalloh-my-fishclearance$omfinstallclearance安装Node.js安装Node.js的方法有很多种:更新yum源,使用yum安装,下载源码,编译安装,使用nvm安装,我选择使用nvm在服务器上安装和管理Node。wget-qO-https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh|bashnvm不能在fish-shell下使用,需要做一些其他的工作。您可以使用bass使fish-shell使用bash环境中的工具。//先安装fishermancurl-Lo~/.config/fish/functions/fisher.fish--create-dirshttps://git.io/fisher//安装bassfisheredc/bass编辑fish配置文件~/.config/fish/config.fish(不存在则创建一个文件),添加bass命令函数nvmbasssource的打包代码~/.nvm/nvm.sh';'nvm$argvend现在你可以在fish-shell中使用nvm了。//安装nodev8.10.0nvminstall8.10.0//设置npm的淘宝源npmconfigsetregistryhttps://registry.npm.taobao.org--globalnpmconfigsetdisturlhttps://npm.taobao.org/dist--全局安装Python3CentOS7系统自带Python2.7.5。我需要安装最新的Pythonv3.x版本。安装前需要提前安装好几个依赖工具。$yuminstallgcczlib-devel之前安装git的时候已经安装好了。所以下次下载源码,编译安装。$wgethttps://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz-Opython3.6.tar.xz$tarxJfpython3.6.tar.xz$cdpython3.6.tar.xz$./configure//因为我用的是fish-shell。其实就是`make&&makeinstall`$make;并makeinstall//在bash中检查安装结果。输出`/usr/local/bin/python3`$whichpython3installMySQLMySQL被Oracle收购后,存在关闭MySQL的潜在风险,因此社区采用分支来避免这种风险。MariaDB的目的就是要完全兼容MySQL,包括API和命令行,这样很容易成为MySQL的替代品。可以在Wiki-MariaDB上找到更多详细信息。MySQL被Oracle收购后,CentOS镜像仓库默认提供的数据库也改为MariaDB。所以从官方网站安装它。$wgethttp://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm$rpm-ivhmysql-community-release-el7-5.noarch.rpm$yum安装mysql-community-server//安装成功后重启mysql服务。$servicemysqlrestartsetencoding在/etc/my.cnf中设置默认编码[client]default-character-set=utf8[mysqld]default-storage-engine=INNODBcharacter-set-server=utf8collat??ion-server=utf8_general_ci#noCase-sensitivecollat??ion-server=utf8_bin#区分大小写collat??ion-server=utf8_unicode_ci#比utf8_general_ci更准确安装Nginxyum在线安装会将nginx安装文件放在系统的不同位置,可以通过命令rpm-qlnginx>$查看安装路径rpm-qlnginx/etc/logrotate.d/nginx/etc/nginx/etc/nginx/conf.d/etc/nginx/conf.d/default.conf/etc/nginx/conf.d/ssl.conf/etc/nginx/conf.d/virtual.conf/etc/nginx/fastcgi.conf/etc/nginx/fastcgi.conf.default/etc/nginx/fastcgi_params/etc/nginx/fastcgi_params.default/etc/nginx/koi-utf/etc/nginx/koi-win/etc/nginx/mime.types/etc/nginx/mime.types.default/etc/nginx/nginx.conf/etc/nginx/nginx.conf.default/etc/nginx/scgi_params/etc/nginx/scgi_params.default/etc/nginx/uwsgi_params/etc/nginx/uwsgi_params.default/etc/nginx/win-utf/etc/rc.d/init.d/nginx/etc/sysconfig/nginx/usr/lib/perl5/vendor_perl/auto/nginx/usr/lib/perl5/vendor_perl/auto/nginx/nginx.so/usr/lib/perl5/vendor_perl/nginx.pm/usr/sbin/nginx/usr/share/doc/nginx-1.0.15/usr/share/文档/nginx-1.0.15/CHANGES/usr/share/doc/nginx-1.0.15/LICENSE/usr/share/doc/nginx-1.0.15/README/usr/share/man/man3/nginx.3pm。gz/usr/share/man/man8/nginx.8.gz/usr/share/nginx/html/404.html/usr/share/nginx/html/50x.html/usr/share/nginx/html/index。html/usr/share/nginx/html/nginx-logo.png/usr/share/nginx/html/poweredby.png/usr/share/vim/vimfiles/ftdetect/nginx.vim/usr/share/vim/vimfiles/indent/nginx.vim/usr/share/vim/vimfiles/syntax/nginx.vim/var/lib/nginx/var/lib/nginx/tmp/var/log/nginx源码包安装他的所有文件(包括配置文件)、库文件、资源文件等)都在同一个目录下。当我们要卸载的时候,直接删除这个文件即可,不会有垃圾文件。我将通过编译源代码安装它$yum-yinstallgccgcc-c++makelibtoolzlibzlib-developensslopenssl-develpcrepcre-devel$wgethttp://nginx.org/download/nginx-1.12.2.tar.gz$tar-zxvfnginx-1.12.2.tar.gz//默认安装到/usr/local/nginx,可以通过--prefix指定安装目录。我在这里明确声明。$./configure--prefix=/usr/local/nginx--with-http_stub_status_module--with-http_ssl_module$制作;并makeinstallnginx几个常用的命令/usr/local/nginx/sbin/nginx#启动/usr/local/nginx/sbin/nginx-sstop#停止