ubuntu server conf

来源:互联网 发布:网络电视怎么重新搜台 编辑:程序博客网 时间:2024/06/05 08:03

ubuntu server conf


linux user manager

$sudo adduser newuserHow To Grant a User Sudo Privileges,Search for the line that looks like this$visudo->root    ALL=(ALL:ALL) ALLBelow this line, copy the format you see here, changing only the word "root" to reference the new user that you would like to give sudo privileges to:->root    ALL=(ALL:ALL) ALL->newuser ALL=(ALL:ALL) ALLHow To Delete a User#deluser newuseror#deluser --remove-home newuseror#sudo deluser --remove-home newuser#visudo->root    ALL=(ALL:ALL) ALL->newuser ALL=(ALL:ALL) ALL   # DELETE THIS LINE

Install Nginx, MySQL, PHP (LEMP) Stack On Ubuntu 16.04

Note: Depending on your installation you may need to remove apache2. You can do that by running the commands:$sudo apt remove apache2*$sudo apt autoremoveInstalling Nginx on Ubuntu 16.04$sudo apt install nginx$sudo service nginx startInstalling MySQL on Ubuntu 16.04#sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu trusty universe'#sudo apt-get update#sudo apt install mysql-server-5.6 * see note below if you get an error#sudo apt install mysql-client-5.6#sudo mysql_secure_installation#dpkg -l | grep mysql-serverInstalling PHP7 on Ubuntu 16.04$sudo apt install php7.0 php7.0-fpm php7.0-mysql$apt install libapache2-mod-php7.0 php7.0 php7.0-fpm php7.0-mysql php7.0-cli php7.0-json php7.0-opcache php7.0-readline php7.0-intl php7.0-xml php7.0-mbstring$sudo apt-get install curl$sudo mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.old$sudo nano /etc/nginx/sites-available/default-->server {        listen       80;        server_name  your_site_name.com;        root /usr/share/nginx/html;        index index.php index.html;        location / {                try_files $uri $uri/ =404;        }        error_page 404 /404.html;        error_page 500 502 503 504 /50x.html;        location = /50x.html {                root /var/www/html;        }        location ~ \.php$ {                try_files $uri =404;                fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;                fastcgi_index index.php;                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;                include fastcgi_params;        }}$sudo service nginx restart

nginx + fpm conf

server { listen 80; server_name dev.myproj.com; location ~ \.php$ { root  /var/www/myproj/www; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location / { root  /var/www/myproj/www; index  index.php; }}server{listen 80;server_name local.emp.clcw.com.cn;index index.php index.html index.htm;access_log /var/log/nginx/local.emp.clcw.com.cn.log;root /home/vagrant/www/emp.clcw.com.cn;location /{    if (!-e $request_filename){        rewrite ^/index.php(.*)$ /index.php?s=$1 last;        rewrite ^(.*)$ /index.php?s=$1 last;        break;    }}location ~ .*\.(php|php5)?${    fastcgi_pass 127.0.0.1:9001;    #fastcgi_pass unix:/var/run/php5-fpm.sock;    fastcgi_index index.php;    include fastcgi_params;}        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$        {         if (-f $request_filename) {          expires -1s;          break;          }        }location ~ /\.ht{    deny all;}}

create git repository

  • 文档 https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-init

Start using Git on the command line

The most common use case for  git init --bare is to create a remote central repository:$ssh <user>@<host> cd path/above/repo git init --bare my-project.gitor$git init --bare mautic.gitInitializes a new Git repository and copies files from the  <template_directory> into the repository.$git init <directory> --template=<template_directory>$git clone ssh://john@example.com/path/to/my-project.gitCloning to a specific folder$git clone <repo> <directory>Cloning a specific tag$git clone -branch <tag> <repo>Shallow clone$git clone -depth=1 <repo>clone only the new_feature branch from the remote Git repository.$git clone -branch new_feature git://remoterepository.gitThis means that a repository will be set up with the history of the project that can be pushed and pulled from, but cannot be edited directly.$git clone --bareGit URLs, Git has its own URL syntax which is used to pass remote repository locations to Git commands.Git URL protocols:-SSH$ssh://[user@]host.xz[:port]/path/to/repo.git/$git clone ssh://coober@192.168.0.62/var/workspace/git_respository/mautic.git-GIT$git://host.xz[:port]/path/to/repo.git/- HTTPhttp[s]://host.xz[:port]/path/to/repo.git/

git config

Usage$git config user.emailgit config levels and files:    - --local    Local configuration values are stored in a file that can be found in the repo's .git directory: .git/config    - --global    Global configuration values are stored in a file that is located in a user's home directory. ~ /.gitconfig    - --systemWriting a value$git config --global user.email "your_email@example.com"$git config --global merge.tool kdiff3$ git config --global color.ui falseAliases$git config --global alias.ci commit$git config --global alias.amend git ci --amend$git --version$git config --global --list$git pull REMOTE NAME-OF-BRANCH -uCreate a branch$git checkout -b NAME-OF-BRANCH$git checkout NAME-OF-BRANCH$git status$git add CHANGES IN RED$git commit -m "DESCRIBE THE INTENTION OF THE COMMIT"$git push REMOTE NAME-OF-BRANCHDelete all changes in the Git repository, but leave unstaged things$git checkout .Delete all changes in the Git repository, including untracked files$git clean -fMerge created branch with master branch$git checkout NAME-OF-BRANCH$git merge masterMerge master branch with created branch$git checkout master$git merge NAME-OF-BRANCH

GitLab Installation

官网 https://about.gitlab.com/installation/#ubuntu
文档 https://docs.gitlab.com/ee/README.html

1. Install and configure the necessary dependencies$sudo apt-get install curl openssh-server ca-certificates postfix2. Add the GitLab package server and install the package$curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash$sudo apt-get install gitlab-ceIf you are not comfortable installing the repository through a piped script, you can find the entire script here and select and download the package manually and install using:dpkg -i gitlab-ce-XXX.deb3. Configure and start GitLabsudo gitlab-ctl reconfigure4. Browse to the hostname and loginThe default account's username is root. Provide the password you created earlier and login. After login you can change the username if you wish

GitLab start stop

文档 https://docs.gitlab.com/ee/administration/restart_gitlab.html

Omnibus GitLab restart$sudo service gitlab-ctl status restart stop start$sudo gitlab-ctl restart nginxgitlab-ctl stop unicorngitlab-ctl stop sidekiq$sudo gitlab-ctl kill <service>Reconfigure Omnibus GitLab with:$sudo gitlab-ctl reconfigure

GitLab User Account

文档 https://docs.gitlab.com/ee/ssh/README.html

Before generating a new SSH key pair check if your system already has one at the default location by opening a shell, or Command Prompt on Windows, and running the following command:Windows Command Prompt:$type %userprofile%\.ssh\id_rsa.pubGit Bash on Windows / GNU/Linux / macOS / PowerShell:$cat ~/.ssh/id_rsa.pubGenerating a new SSH key pair$ssh-keygen -t rsa -C "your.email@example.com" -b 4096Note: If you want to change the password of your SSH key pair, you can use$ssh-keygen -p <keyname>.

GitLab server conf

文档

conf in:/etc/gitlab/gitlab.rbinstall in:/var/opt/gitlab/git-data/#grep -v '#' gitlab.rb |grep -v ^$->external_url 'http://192.168.0.62:8081'->gitlab_rails['gitlab_shell_ssh_port'] = 81->nginx['listen_addresses']= ['192.168.0.62']access gitlab from browserhttp://192.168.0.62:8081Username: rootPassword: 5iveL!fe  12345678change password for root:gitlab-rails console production->user = User.where(id: 1).first   or  user = User.find_by(email: 'admin@local.host')->user.password = 'secret_pass'->user.password_confirmation = 'secret_pass'->user.save!--gitlab backup---------0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:createwrite conf /etc/gitlab/gitlab.rb->gitlab_rails['backup_path'] = '/mnt/backups'recovergitlab-rake gitlab:backup:restore BACKUP=1393513186

create database db_linkall_demo default charset utf8 collate utf8_general_ci;

->grant all privileges on db_linkall_demo.* to dbuser@localhost identified by ‘111111’;
->flush privileges;

原创粉丝点击