通常是因为更新系统后,ca证书没有被更新,新的证书被命名为“.rpmnew”,解决办法是删掉旧证书,重新安装新的证书。
rm -f /etc/ssl/certs/ca-bundle.crt && yum reinstall -y ca-certificates
通常是因为更新系统后,ca证书没有被更新,新的证书被命名为“.rpmnew”,解决办法是删掉旧证书,重新安装新的证书。
rm -f /etc/ssl/certs/ca-bundle.crt && yum reinstall -y ca-certificates
dnf update -y
dnf install supervisor
sytemctl enable supervisord
vim /etc/supervisor/xxx.conf
[program:testprogram]
directory = /root/go/src/test
command = /root/go/src/test/bin/server
autostart = true
startsecs = 5
autorestart = true
startretries = 3
user = root
redirect_stderr = true
stdout_logfile = /var/log/supervisor/test.log
supervisorctl reload
supervisorctl start xxx
supervisorctl status
sudo yum install -y samba samba-client ## centos
sudo apt install smbclient samba ## ubuntu
[sambashare]
comment = Samba on Ubuntu
path = /home/username/sambashare
read only = no
browsable = yes
sudo systemctl enable smb ## centos
sudo systemctl start smb ## centos
sudo systemctl enable smbd ## ubuntu
sudo systemctl start smbd ## ubuntu
sudo smbpasswd -a username
打开资源管理器,地址栏输入"\ip",然后输入密码即可
https://www.postgresql.org/download/linux/redhat/
yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
yum install postgresql10-server
创建数据目录并修改权限
mkdir -p /data/postgresql/
chown postgres:postgres /data/postgresql/
复制开机启动文件
sudo cp /usr/lib/systemd/system/postgresql-10.service /etc/systemd/system/
修改开机启动文件
vim /etc/systemd/system/postgresql-10.service
找到
Environment=PGDATA=/var/lib/pgsql/10/data/
修改为
Environment=PGDATA=/data/postgresql/
/usr/pgsql-10/bin/postgresql-10-setup initdb
systemctl enable postgresql-10
systemctl start postgresql-10
systemctl status postgresql-10
vim /data/postgresql/pg_hba.conf
将
host all all 127.0.0.1/32 ident
修改为
host all all 127.0.0.1/32 md5
重新加载配置
systemctl restart postgresql-10
su - postgres
createuser dbuser
createdb -e -O dbuser dbname
su - postgres
psql
\password dbuser (输入两次密码)
psql -U dbuser -d dbname -h 127.0.0.1 (输入之前的密码)
data/postgresql.conf
修改listen_addresses = 'localhost'
为listen_addresses = 'localhost'
编辑data/pg_hba.conf
host all all 192.168.1.0/24 md5
Vagrant是一款基于命令行的虚拟机管理软件,可以用来快速部署统一的开发环境。
https://www.vagrantup.com/downloads.html
https://app.vagrantup.com/boxes/search
https://app.vagrantup.com/centos/boxes/7
vagrant init centos/7
vagrant up
config.vm.network "public_network", ip: "192.168.31.245"
config.vm.synced_folder "d:/data", "/data"
config.vm.synced_folder "d:/phpcode", "/phpcode"
官方box文件下载地址:http://cloud.centos.org/centos/7/vagrant/x86_64/images/
百度网盘box文件下载地址:
vagrant box add centos7 CentOS-7.box
vagrant init centos7
vagrant up
vagrant ssh
sudo passwd vagrant
sudo yum groupinstall "Development tools" -y
sudo yum install vim gcc kernel-devel kenel-devel-`uname -r`
sudo setenforce 0
sudo vi /etc/selinux/config
SELINUX=disabled
sudo systemctl disable firewalld
sudo systemctl stop firewalld
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum install yum-utils
sudo yum-config-manager --enable remi-php72
sudo yum update
sudo yum install php-gd php-pdo php-opcache php-fpm php-pecl-redis php-pecl-mysql php-pecl-mysql php-mbstring php-intl php-cli php-xml
sudo yum install nginx -y
sudo yum install mariadb mariadb-server -y
mkdir /data/log/nginx /data/run/nginx -p
sudo service nginx stop
sudo vim /etc/nginx/nginx.conf
nginx.conf配置修改如下:
user vagrant;
error_log /data/log/nginx/error.log;
pid /data/run/nginx/nginx.pid;
access_log /data/log/nginx/access.log main;
include /data/phpcode/projectname/vagrant/nginx/app.conf;
测试nginx配置
sudo nginx -t
修改nginx service配置:
sudo vim /usr/lib/systemd/system/nginx.service
nginx.service修改内容如下:
[Service]
PIDFile=/data/run/nginx/nginx.pid
重新加载service
sudo systemctl daemon-reload
sudo systemctl start nginx
mkdir /data/run/php-fpm/session /data/run/php-fpm/wsdlcache /data/run/php-fpm/opcache /data/log/php-fpm/ -p
sudo service php-fpm stop
sudo vim /etc/php-fpm.d/www.conf
配置内容
user = vagrant
group = vagrant
php_value[session.save_path] = /data/run/php-fpm/session
php_value[soap.wsdl_cache_dir] = /data/run/php-fpm/wsdlcache
php_value[opcache.file_cache] = /data/run/php-fpm/opcache
php_admin_value[error_log] = /data/log/php-fpm/www-error.log
slowlog = /data/log/php-fpm/www-slow.log
request_slowlog_timeout = 1
重启
sudo service php-fpm stop
mkdir /data/mysql /data/run/mariadb /data/log/mariadb -p
sudo service mariadb stop
sudo vim /etc/my.cnf
mysqld配置
[mysqld]
datadir=/data/mysql
socket=/usr/lib/mysql/mysql.sock
[mysqld_safe]
log-error=/data/log/mariadb/mariadb.log
pid-file=/data/run/mariadb/mariadb.pid
mysql client 配置
[client]
初始化数据库
sudo /usr/libexec/mariadb-prepare-db-dir mariadb.service
修改systemd配置
sudo vim /usr/lib/systemd/system/mariadb.service
配置内容
User=vagrant
Group=vagrant
重载systemd
sudo systemctl daemon-reload
sudo systemctl start mariadb
修改mysql账号密码
'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h localhost.localdomain password 'new-password'
# Alternatively you can run:
'/usr/bin/mysql_secure_installation'
下载安装文件
php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
安装
php composer-setup.php
删除安装文件
php -r "unlink('composer-setup.php');"
设置全局路径(windows请按参考文档设置)
sudo mv composer.phar /usr/bin/composer
配置使用国内镜像
composer config -g repo.packagist composer https://packagist.phpcomposer.com
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum update
yum install php71w-gd php71w-pdo php71w-opcache php71w-fpm php71w-pecl-redis php71w-mysql php71w-mcrypt php71w-mbstring php71w-intl php71w-cli
yum install nginx1w -y
systemctl enable nginx php-fpm
systemctl start nginx php-fpm
chown -R apache:apache /data/web/www.c4ys.com/
vim /etc/nginx/conf.d/www.c4ys.com.conf
server {
server_name www.c4ys.com c4ys.com;
root /data/phpproject/www.c4ys.com;
location / {
index index.html index.php;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
安装编译工具,头文件
yum install gcc gcc-c++ libffi-devel openssl-devel
安装certbot
yum install certbot python2-certbot-nginx
安装证书
certbot --nginx
安装服务端和客户端
wget -O /etc/yum.repos.d/mqtt.repo download.opensuse.org/repositories/home:/oojah:/mqtt/CentOS_CentOS-6/home:oojah:mqtt.repo
yum update
yum install mosquitto mosquitto-clients
chkconfig mosquitto on
service mosquitto start
给root设置一个密码,允许远程通过密码登录
chmod 400 xxx.pem
ssh -i xxx.pem ec2-user@host-ip
sudo passwd root
sudo su -
vim /etc/ssh/sshd_config
/etc/ssh/sshd_config内容如下
PermitRootLogin yes
PasswordAuthentication yes
UsePAM yes
然后
service sshd reload
amazon aws如果采用redhat需要额外收授权费,目前aws官方2014.3基于centos 6,许多软件版本较旧,可以通过epel软件仓库安装一些新软件
yum-config-manager --enable epel
yum update
yum groupinstall "Development tools" -y
yum install openssl-devel libxslt-devel libxml2-devel libffi-devel -y
vim /etc/yum.repos.d/MariaDB.repo
# MariaDB 5.5 CentOS repository list - created 2014-09-13 05:43 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
安装MariaDB客户端
yum install MariaDB-client mysql-devel -y
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum-config-manager --enable remi
yum install redis -y
vim /etc/yum.repos.d/mongodb.repo
[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
安装mongodb客户端
yum update
yum install mongodb-org-shell -y
# yum install centos-release-SCL (aliyun only)
yum install python27*
yum install freetype-devel libjpeg-devel libpng-devel
# scl enable python27 bash (aliyun only)
virtualenv --no-site-packages /data/pyenv
source /data/pyenv/bin/activate
pip install redis cryptography sqlalchemy flask simplejson mongoengine python-amazon-product-api scrapy mysql-python gunicorn gevent
#install glusterfs repo
wget -P /etc/yum.repos.d http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/glusterfs-epel.repo
#fix it for amazon linux
sed -i 's/$releasever/6/g' /etc/yum.repos.d/glusterfs-epel.repo
#install glusterfs
yum install -y glusterfs-fuse
#setup fstab
echo "172.31.42.77:/pcvol /data_pcvol glusterfs defaults,noatime 0 0" >> /etc/fstab
#mount
mkdir /data_pcvol
mount -a
ls /data_pcvol
lsblk
mkfs -t ext4 /dev/xvdf
echo '/dev/xvdf /data_log ext4 defaults,nofail 0 2' >> /etc/fstab
mkdir /data_log
mount -a
su -c 'rpm -Uvh http://mirrors.hust.edu.cn/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm'
su -c 'yum install epel-release-7-0.2'
su -c 'yum install mariadb mariadb-server php php-cli php-fpm php-pdo nginx'
CREATE USER 'th'@'%' IDENTIFIED BY '***';
GRANT ALL PRIVILEGES ON * . * TO 'th'@'%' IDENTIFIED BY '***';
flush privileges;