【161110】服务器管理记录

15 Practical Linux cURL Command Examples

typically:

curl -O [url]

MySQL: allow remote connection

allow connection from arbitrary hostname:

mysql>GRANT ALL PRIVILEGES ON . TO ‘[username]‘@’%’ IDENTIFIED BY ‘[password]’ WITH GRANT OPTION;
mysql>FLUSH RIVILEGES

allow connection from specific hostname:

mysql>GRANT ALL PRIVILEGES ON . TO ‘[username]‘@’[hostname]’ IDENTIFIED BY ‘[password]’ WITH GRANT OPTION;
mysql>FLUSH RIVILEGES

How to locate MySQL configuration file?

The file might be in 5 (or more?) locations
/etc/my.cnf
/etc/mysql/my.cnf
$MYSQL_HOME/my.cnf
[datadir]/my.cnf
~/.my.cnf

How to locate Nginx configuration file?

The primary configuration file is /etc/nginx/nginx.conf.
Other possible locations include /opt/nginx/conf/.

How to locate Apache configuration file?

Usually /etc/httpd/conf/httpd.conf.

Create an info.php to reveal Apache environment (risky).

< ?php
phpinfo();
?>

Install Apache2, PHP5 And MySQL Support On CentOS 6.5 (LAMP)

the Apache service is located at /etc/init.d/httpd.

How To Install Linux, nginx, MySQL, PHP (LEMP) stack on CentOS 6

【160226】服务器管理记录

【160221】服务器管理记录

  • MySQL:show columns of a certain datatable:

    show full columns from [tablename];

  • Nginx:remove root directory

    root /usr/share/nginx/html;

    location / {

    fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;

    }

    /etc/init.d/nginx restart

  • Nginx:add rewrite rules for redirecting,map port 8080 into 80.

    server {
    listen 8080;
    server_name localhost_redirect;
    rewrite ^/(.+)/.* /$1 last;
    location / {
    proxy_pass http://127.0.0.1:80;
    proxy_set_header Host $host:80;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    }

【160124】服务器管理记录

  • Ubuntu 解决语言设置错误的问题,并正常输入输出中文
    安装localepurge管理语言文件

    sudo apt-get install localepurge

    当然也可以使用以下命令再次进行配置:

    sudo dpkg-reconfigure localepurg

    在本地对fish-shell进行配置:

    set -U LANG en_US.UTF-8
    set -U LC_ALL en_US.UTF-8

  • Apache: Set Up Mod_Rewrite

    sudo a2enmod rewrite

  • MySQL user management

    • enter interactive mode

      mysql -u [username] -h [hostname] -p

    • show all users

      select * {host,user,…} from mysql.user

    • add a user

      create user [username]@[hostname] identified by ‘[password]’

    • delete a user

      drop user [username]@[hostname]

    • give privileges (users not existed will be created)

      grant {all privileges,select,usage,…} on *.* to [username]@[hostname] identified ‘[password]’

    • retrieve privileges

      revoke {all privileges,select,usage,…} on *.* from [username]@[hostname] identified ‘[password]’

    • show privileges

      show grants for [username]@[hostname];

    All sorts of privileges

【160123】服务器管理记录

  • Ubuntu Server用户管理

    • List all

      cut -d: -f1 /etc/passwd

    • Create

      sudo useradd [username]
      sudo passwd [username]

    • Delete

      sudo userdel [username]
      sudo rm -rf /home/[username]

    • List UIDs

      awk -F: ‘//home/ {printf “%s:%s\n”,$1,$3}’ /etc/passwd

  • 使用vsftpd搭建ftp服务

    • Install

      sudo apt-get update
      sudo apt-get install vsftpd

    • Configure

      sudo nano /etc/vsftpd.conf

      Disallow anonymous, unidentified users to access files via FTP; change the anonymous_enable setting to NO:

    anonymous_enable=NO

      Disallow anonymous, unidentified users to access files via FTP; change the anonymous_enable setting to
    

Allow local uses to login by changing the local_enable setting to YES:
> local_enable=YES

    If you want local user to be able to write to a directory, then change the write_enable setting to YES:
> write_enable=YES

    [Solve `530 Login incorrect`](http://askubuntu.com/questions/413677/vsftpd-530-login-incorrect):
> pam_service_name=ftp

    [Solve `550 failed to change directory`](http://my.oschina.net/aiguozhe/blog/100161)
> chroot_local_user=NO

- Run
> sudo service vsftpd restart[/start/stop]