Nginx 的支持高并发, 强大的负载均衡, 低资源消耗 使它成为了 Linux web 服务端的首选, 尤其对于小内存的 VPS, 这点更为明显, 使它完胜 Apache.
下面就介绍 LNMP 的安装.
Nginx 的支持高并发, 强大的负载均衡, 低资源消耗 使它成为了 Linux web 服务端的首选, 尤其对于小内存的 VPS, 这点更为明显, 使它完胜 Apache.
下面就介绍 LNMP 的安装.
执行下面的命令来安装 MySQL:
1 | yum install mysql mysql-server |
然后启动 MySQL 服务器:
1 | service mysqld start |
运行下面的命令来为 root 用户设置一个密码(否则的话任何人都可以访问你的MySQL数据库!):
1 | mysqladmin -u root -p password 12345678 |
Enter password: 输入root当前密码以确认修改,一般root初始密码为空(上面的12345678为你想要的密码)
有人说用 Socket 请求 http 服务效率要比 HttpWebRequest 高很多, 但是又没有提供源码或者对比测试结果. 我对此很好奇, 到底能差多少? 所以决定自己写个类实现 Socket 请求 http 的功能.
当前服务器环境: Centos 6
PPTP的配置主要有下面五个步骤:
1 | modprobe ppp-compress-18 && echo MPPE is ok |
安装前确保添加了 epel 源, 如果没有, 请参考 <<CentOS 添加常用 yum 源>>.
使用 top 命令查看进程内存使用量
1 | top |
按 Shift + m, 以内存使用量排序, 可以看到 apache 有多个进程, 占用了很多内存, 记录下单个进程占用最多内存数, 我的是 40M.
所有操作均需 root 权限
首先用 fdisk -l 查看硬盘分区情况
1 | fdisk -l |
1 2 3 4 5 6 7 8 9 | Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00097743 Device Boot Start End Blocks Id System /dev/sda1 * 1 2481 19922944 83 Linux |
只有一个分区.
新建一个分区, 用于 swap 交换.
1 | fdisk /dev/sda |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | [root@itnmg ~]# fdisk /dev/sda WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition 删除一个分区 l list known partition types m print this menu 显示帮助菜单 n add a new partition 新建一个分区 o create a new empty DOS partition table p print the partition table 显示分区表 q quit without saving changes 不保存退出 s create a new empty Sun disklabel t change a partition's system id 改变分区类型 u change display/entry units v verify the partition table w write table to disk and exit 保存退出 x extra functionality (experts only) Command (m for help): |
我们常用的的就是中文标出来那些了.
如果要 Linux 执行计划任务, 需要安装 crontabs 服务
1 2 3 | yum install crontabs systemctl enable crond systemctl start crond |
然后编辑 /etc/crontab 文件
1 | nano /etc/crontab |
mailto 选项, 指定接收 cron 日志的邮箱, 可选项.
目前已知的提供免费 ssl 证书的只有一家. StartSSL.com, ssl 证书分为 4 类
Class 1, Class 2, Class 3, Extended Validation, 对于申请者的验证严格程序依次递增, 同时安全性也随之增强. 免费的属于 Class 1 类型.
要让 Apache 支持安全链接,即 https 访问,要有 ssl 证书及 mod_ssl.so 模块.
Apache 及其它服务安装请参考<<CentOS LAMP,vsFTP,smtp 等环境配置详解>>
1 | yum install mod_ssl |
安装完成后会在 /etc/httpd/conf.d 目录中多出个 ssl.conf 配置文件.
首先使用 ps -ef 命令确定要杀死进程的 PID, 如果想查找某个进程名字, 加上 grep 命令, 例如
1 | ps -ef | grep httpd |
得到 pid 之后, 可以使用 kill 命令结束进程
1 | kill -l pid |
通常这个命令足够用了, 如果有多个相同名字的进程, 则可能存在父子进程关系, 此时用 killall, killall 命令不需要 pid 参数, 它使用进程名字.
1 | killall httpd |