关于作者

My baby
☑阅读控 ☑80后 ☑看电影 ☑打篮球
#java #jquery #ubuntu #wordpress #php #mysql
来自天朝!
不大不小,而立之年!
不喜政治,但愿意关注时事!
我爱天朝,但天朝不爱我们!
PS:我就是希望她能回到我小时候那样子——上下学自己去,走几条马路就到学校,遇见陌生人也不害怕,不用家长去接,路上没那么多汽车,汽车知道避让行人,不用给老师送礼拍马屁,就这么简单。

蜘蛛网间

蜘蛛网与您分享网络间的爬行轨迹

阿里云服务器安装后-安装配置PHP-FPM

01/12/2016

1.更新缓存,安装PHP-FPM

tianyangtax@iZ25tc8mln7Z:~$ sudo apt-get update
tianyangtax@iZ25tc8mln7Z:~$ sudo apt-get upgrade
tianyangtax@iZ25tc8mln7Z:~$ sudo apt-get install php5 php5-cli php5-curl php5-fpm php5-intl php5-mcrypt php5-mysqlnd php5-gd

2.更新PHP-FPM配置文件

tianyangtax@iZ25tc8mln7Z:~$ sudo vim /etc/php5/fpm/php.ini
tianyangtax@iZ25tc8mln7Z:~$ sudo cat /etc/php5/fpm/php.ini
...
post_max_size = 1024M 
memory_limit = 2048M
upload_max_filesize = 1024M
...
tianyangtax@iZ25tc8mln7Z:~$ sudo vim /etc/php5/fpm/pool.d/www.conf
tianyangtax@iZ25tc8mln7Z:~$ sudo cat /etc/php5/fpm/pool.d/www.conf
...
listen = /var/run/php5-fpm.sock
...
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
...
tianyangtax@iZ25tc8mln7Z:~$ sudo service php5-fpm restart
php5-fpm stop/waiting
php5-fpm start/running, process 11930

3.更新NGINX站点配置文件以支持PHP

tianyangtax@iZ25tc8mln7Z:~$ sudo vim /etc/nginx/sites-available/default
tianyangtax@iZ25tc8mln7Z:~$ sudo cat /etc/nginx/sites-available/default
...
server {
...
    	index index.html index.htm index.php;
...
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
	#
	location ~ \.php$ {
		fastcgi_split_path_info ^(.+\.php)(/.+)$;
		# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
	
		# With php5-cgi alone:
		# fastcgi_pass 127.0.0.1:9000;
		# With php5-fpm:
		fastcgi_pass unix:/var/run/php5-fpm.sock;
		fastcgi_index index.php;
		include fastcgi_params;
	}

	# deny access to .htaccess files, if Apache's document root
	# concurs with nginx's one
	#
	location ~ /\.ht {
		deny all;
	}
...
tianyangtax@iZ25tc8mln7Z:~$ sudo service nginx restart
 * Restarting nginx nginx                     [ OK ]

4.测试服务器及PHP是否正常

 
tianyangtax@iZ25tc8mln7Z:~$ sudo vim /usr/share/nginx/html/phpinfo.php
tianyangtax@iZ25tc8mln7Z:~$ sudo cat /usr/share/nginx/html/phpinfo.php
< ?php
    phpinfo();

2016-01-12 20:58:31屏幕截图

阿里云服务器安装后-安装配置MYSQL

01/12/2016

1.更新缓存,安装MYSQL服务

tianyangtax@iZ25tc8mln7Z:~$ sudo apt-get update
tianyangtax@iZ25tc8mln7Z:~$ sudo apt-get upgrade
tianyangtax@iZ25tc8mln7Z:~$ sudo apt-get install mysql-server

2.MYSQL默认字符编码为 latin1

tianyangtax@iZ25tc8mln7Z:~$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 42
Server version: 5.5.46-0ubuntu0.14.04.2 (Ubuntu)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like "%char%";
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | latin1                     |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | latin1                     |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

mysql> quit
Bye

3.编辑配置文件 /etc/mysql/my.cnf

tianyangtax@iZ25tc8mln7Z:~$ sudo vim /etc/mysql/my.cnf
tianyangtax@iZ25tc8mln7Z:~$ sudo cat /etc/mysql/my.cnf
...
[mysqld]
...
#
# * UTF-8 Settings
#
character-set-server    = utf8
collation-server        = utf8_general_ci
skip-character-set-client-handshake
...

4.重启MYSQL服务

tianyangtax@iZ25tc8mln7Z:~$ sudo service mysql restart
mysql stop/waiting
mysql start/running, process 8649

5.编码成功变更为UTF8

tianyangtax@iZ25tc8mln7Z:~$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 36
Server version: 5.5.46-0ubuntu0.14.04.2 (Ubuntu)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like "%char%";
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

mysql> quit
Bye

阿里云服务器安装后-安装配置NGINX

01/12/2016

1.安装NGINX服务

tianyangtax@iZ25tc8mln7Z:~$ sudo apt-get update
tianyangtax@iZ25tc8mln7Z:~$ sudo apt-get upgrade
tianyangtax@iZ25tc8mln7Z:~$ sudo apt-get install nginx

2.配置NGINX基础设置

tianyangtax@iZ25tc8mln7Z:~$ sudo vim /etc/nginx/nginx.conf
tianyangtax@iZ25tc8mln7Z:~$ sudo cat /etc/nginx/nginx.conf
user www-data;
worker_processes 4;             ## 根据CPU核心数目设置
pid /run/nginx.pid;
worker_rlimit_nofile 65535;     ## 根据 rlimit -n 数目设置

events {
	use epoll;
	worker_connections 2048;
	multi_accept on;
}

http {

	##
	# Basic Settings
	##

	sendfile on;
	tcp_nopush on;
	tcp_nodelay on;
	keepalive_timeout 65;
	types_hash_max_size 2048;
	client_max_body_size 1024M;
	# server_tokens off;

	# server_names_hash_bucket_size 64;
	# server_name_in_redirect off;
	
	##
	# Fastcgi Settings
	##
	fastcgi_connect_timeout 1800;
    fastcgi_send_timeout 1800;
    fastcgi_read_timeout 1800;
    fastcgi_buffer_size 1024k;
    fastcgi_buffers 32 1024k;
    fastcgi_busy_buffers_size 2048k;
    fastcgi_temp_file_write_size 2048k;
	
	include /etc/nginx/mime.types;
	default_type application/octet-stream;

	##
	# Logging Settings
	##

	access_log /var/log/nginx/access.log;
	error_log /var/log/nginx/error.log;

	##
	# Gzip Settings
	##

	gzip on;
	gzip_disable "msie6";

	gzip_vary on;
	gzip_proxied any;
	gzip_comp_level 6;
	gzip_buffers 16 8k;
	gzip_http_version 1.1;
	gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

	##
	# nginx-naxsi config
	##
	# Uncomment it if you installed nginx-naxsi
	##

	#include /etc/nginx/naxsi_core.rules;

	##
	# nginx-passenger config
	##
	# Uncomment it if you installed nginx-passenger
	##
	
	#passenger_root /usr;
	#passenger_ruby /usr/bin/ruby;

	##
	# Virtual Host Configs
	##

	include /etc/nginx/conf.d/*.conf;
	include /etc/nginx/sites-enabled/*;
}


#mail {
#	# See sample authentication script at:
#	# http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
# 
#	# auth_http localhost/auth.php;
#	# pop3_capabilities "TOP" "USER";
#	# imap_capabilities "IMAP4rev1" "UIDPLUS";
# 
#	server {
#		listen     localhost:110;
#		protocol   pop3;
#		proxy      on;
#	}
# 
#	server {
#		listen     localhost:143;
#		protocol   imap;
#		proxy      on;
#	}
#}

3.配置防火墙,打开WEB端口

tianyangtax@iZ25tc8mln7Z:~$ sudo ufw allow 80
Rule added
Rule added (v6)
tianyangtax@iZ25tc8mln7Z:~$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
2002                       ALLOW       Anywhere
21                         ALLOW       Anywhere
80                         ALLOW       Anywhere
2002 (v6)                  ALLOW       Anywhere (v6)
21 (v6)                    ALLOW       Anywhere (v6)
80 (v6)                    ALLOW       Anywhere (v6)

4.打开浏览器,测试NGINX服务
2016-01-12 20:21:40屏幕截图

阿里云服务器安装后-配置VSFTPD

01/11/2016

1.安装VSFTPD服务器

tianyangtax@iZ25tc8mln7Z:~$ sudo apt-get install vsftpd
tianyangtax@iZ25tc8mln7Z:~$ sudo netstat -npltu | grep 21
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      1550/vsftpd

2.启用 uper daemon 模式
uper daemon指的是有需要时由xinetd启动vsftpd服务。如果服务器不是那种长期开ftp,提供大量的上传下载服务的话,选择此模式。

tianyangtax@iZ25tc8mln7Z:~$ sudo vim /etc/vsftpd.conf
...
 14 listen=NO
 15 #
 16 # Fix some 530 bugs by royakon at 20160105
 17 seccomp_sandbox=NO
...
 28 # Uncomment this to allow local users to log in.
 29 local_enable=YES
 30 #
 31 # Uncomment this to enable any form of FTP write command.
 32 write_enable=YES
...
 71 xferlog_file=/var/log/vsftpd.log
...
tianyangtax@iZ25tc8mln7Z:~$ sudo apt-get install xinetd
tianyangtax@iZ25tc8mln7Z:~$ cd /etc/xinetd.d
tianyangtax@iZ25tc8mln7Z:/etc/xinetd.d$ sudo vim vsftpd
tianyangtax@iZ25tc8mln7Z:/etc/xinetd.d$ sudo cat vsftpd
service ftp
{
        socket_type             = stream
        wait                    = no
        user                    = root
        server                  = /usr/sbin/vsftpd
        log_on_success          += DURATION USERID
        log_on_failure          += USERID
        nice                    = 10
        disable                 = no
}
tianyangtax@iZ25tc8mln7Z:/etc/xinetd.d$ sudo service vsftpd stop
vsftpd stop/waiting
tianyangtax@iZ25tc8mln7Z:/etc/xinetd.d$ sudo service xinetd restart
xinetd stop/waiting
xinetd start/running, process 2986
tianyangtax@iZ25tc8mln7Z:/etc/xinetd.d$ sudo netstat -npltu | grep 21
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      2986/xinetd 

3.CHROOT运行模式, vsftpd.chroot_list 文档中的用户不chroot;本例中文件为空.

tianyangtax@iZ25tc8mln7Z:~/etc/xinet.d$ cd ~
tianyangtax@iZ25tc8mln7Z:~$ sudo vim /etc/vsftpd.conf
...
123 chroot_local_user=YES
124 chroot_list_enable=YES
125 allow_writeable_chroot=YES
126 # (default follows)
127 chroot_list_file=/etc/vsftpd.chroot_list
...
tianyangtax@iZ25tc8mln7Z:~$ sudo vim /etc/vsftpd.chroot_list
tianyangtax@iZ25tc8mln7Z:~$ cat /etc/vsftpd.chroot_list

4.配置UFW防火墙

tianyangtax@iZ25tc8mln7Z:/etc$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
2002                       ALLOW       Anywhere
2002 (v6)                  ALLOW       Anywhere (v6)

tianyangtax@iZ25tc8mln7Z:/etc$ sudo ufw allow 21
Rule added
Rule added (v6)
tianyangtax@iZ25tc8mln7Z:/etc$ sudo ufw status
\Status: active

To                         Action      From
--                         ------      ----
2002                       ALLOW       Anywhere
21                         ALLOW       Anywhere
2002 (v6)                  ALLOW       Anywhere (v6)
21 (v6)                    ALLOW       Anywhere (v6)

5.重启xinetd服务

tianyangtax@iZ25tc8mln7Z:/etc$ sudo service xinetd restart
xinetd stop/waiting
xinetd start/running, process 3073

2016-01-11 21:37:24屏幕截图

阿里云服务器安装后-挂载数据云盘

01/11/2016

1.查看分区挂载状态

tianyangtax@iZ25tc8mln7Z:~$ df -lh
Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G  4.0K  3.9G   1% /dev
tmpfs           799M  392K  799M   1% /run
/dev/xvda1       20G  2.0G   17G  11% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            5.0M     0  5.0M   0% /run/lock
none            3.9G     0  3.9G   0% /run/shm
none            100M     0  100M   0% /run/user

2.查看硬盘状态

tianyangtax@iZ25tc8mln7Z:/$ sudo fdisk -l

Disk /dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000da36d

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *        2048    41940991    20969472   83  Linux

Disk /dev/xvdb: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders, total 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/xvdb doesn't contain a valid partition table

3.硬盘分区

tianyangtax@iZ25tc8mln7Z:/$ sudo fdisk /dev/xvdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x5c4c4e94.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 
First sector (2048-419430399, default 2048): 
Last sector, +sectors or +size{K,M,G} (2048-419430399, default 419430399): 
Using default value 419430399

Command (m for help): wq
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

4.重新查看硬盘状态,可以发现 /dev/xvdb1 分区已经建立

tianyangtax@iZ25tc8mln7Z:/$ sudo fdisk -l

Disk /dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000da36d

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *        2048    41940991    20969472   83  Linux

Disk /dev/xvdb: 214.7 GB, 214748364800 bytes
86 heads, 25 sectors/track, 195083 cylinders, total 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x5c4c4e94

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdb1            2048   419430399   209714176   83  Linux

5.格式化分区

tianyangtax@iZ25tc8mln7Z:/$ sudo mkfs.ext4 /dev/xvdb1
mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
13107200 inodes, 52428544 blocks
2621427 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
1600 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 

6.查看分区UUID

tianyangtax@iZ25tc8mln7Z:/$ sudo blkid
/dev/xvda1: UUID="af414ad8-9936-46cd-b074-528854656fcd" TYPE="ext4" 
/dev/xvdb1: UUID="4d1d7add-8b92-4eb9-9c18-d81ef2b339d7" TYPE="ext4" 

7.编辑 /etc/fstab 挂载数据分区至 /mnt

tianyangtax@iZ25tc8mln7Z:/$ sudo vim /etc/fstab
tianyangtax@iZ25tc8mln7Z:/$ sudo cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
#                
UUID=af414ad8-9936-46cd-b074-528854656fcd / ext4 errors=remount-ro 0 1

# /mnt was on /dev/xvdb1 by royakon at 2016-01-11 20:43
UUID=4d1d7add-8b92-4eb9-9c18-d81ef2b339d7 /mnt ext4 defaults 0 0

8.重启后重新查看分区状态,可见数据云盘挂载成功.

tianyangtax@iZ25tc8mln7Z:~$ df -lh
Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G  4.0K  3.9G   1% /dev
tmpfs           799M  392K  799M   1% /run
/dev/xvda1       20G  2.0G   17G  11% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            5.0M     0  5.0M   0% /run/lock
none            3.9G     0  3.9G   0% /run/shm
none            100M     0  100M   0% /run/user
/dev/xvdb1      197G   60M  187G   1% /mnt
Newer Posts
Older Posts