进入官网下载stable版(稳定版)
#linux软件安装时,除了二进制包外可能还需要该软件的-devel包
[pikaqiu@bogon nginx]$ wget http://nginx.org/download/nginx-1.8.0.tar.gz
配置参数,http_stub_status_module为nginx的统计模块(有openssl,zlib,prec的前置条件,且安装路径分别为:/usr/local/web/openssl,默认路径(未手动指定),/usr/local/web/prec)
./configure --prefix=/usr/local/web/nginx/ --with-http_stub_status_module --with-pcre=/root/soft/pcre-8.38 --with-openssl=/usr/local/web/openssl/include/openssl --with-zlib=/usr/local/web/zlib/include
注:nginx1.10.0安装时,配置里的pcre必须为pcre的源码目录,如果with-pcre里的路径为安装后的目录时,会报找不到文件夹的错误;zlib必须默认安装,且configure时不能加zlib的with项,如果安装时手动指定了目录,就算安装时在with里指定了安装目录,也会产生一个make: *** No rule to make的make错误;另外,zilb和nginx的gzip压缩有关,nginx默认安装时如果没有安装zlib,configure时会产生一个需要zlib的错误,但错误提示里有一个用with配置将zlib关闭的选项;
#启用该统计模块时需配置nginx的配置文件,示例(该示例中只允许192.168.0.101该IP访问该模块):
location /status {
stub_status on;
access_log off;
allow 192.168.0.101;
deny all;
}
启动nginx
#直接执行sbin目录下的nginx就能启动ngninx,另外,netstat -antp可以查看端口被哪个程序占用
[root@bogon pikaqiu]# /usr/local/nginx/sbin/nginx [root@bogon pikaqiu]# netstat -antp
nginx信号控制
Nginx中使用信号来控制Nginx停止、平滑重启,Nginx支持以下几种信号:
1)TERM,INT快速关闭 SIGINT SIGTERM 即:NGX_TERMINATE_SIGNAL and SIGINT
2)QUIT 从容关闭 SIGQUIT 即 NGX_SHUTDOWN_SIGNAL
3)HUP 平滑重启,重新加载配置文件 SIGHUP 即NGX_RECONFIGURE_SIGNAL
4)USR1 重新打开日志文件,在切割日志时用途较大 SIGUSR1 即NGX_REOPEN_SIGNAL
5)USR2 平滑升级可执行程序 SIGUSR2 即NGX_CHANGEBIN_SIGNAL
6)WINCH 从容关闭工作进程
nginx平滑重启
[root@bogon html]# ps aux|grep nginx root 8572 0.0 0.0 24308 752 ? Ss 13:39 0:00 nginx: master process /usr/local/nginx/sbin/nginx nobody 8573 0.0 0.0 26820 1748 ? S 13:39 0:00 nginx: worker process root 9125 0.0 0.0 112656 968 pts/0 S+ 14:04 0:00 grep --color=auto nginx [root@bogon html]# kill -QUIT 8572 [root@bogon html]# ps aux|grep nginx root 9136 0.0 0.0 112656 968 pts/0 S+ 14:05 0:00 grep --color=auto nginx [root@bogon html]# /usr/local/nginx/sbin/nginx
配置文件更改过后HUP
[root@bogon html]# ps aux|grep nginx root 9149 0.0 0.0 24308 764 ? Ss 14:06 0:00 nginx: master process /usr/local/nginx/sbin/nginx nobody 9150 0.0 0.0 26820 1508 ? S 14:06 0:00 nginx: worker process root 9186 0.0 0.0 112656 964 pts/0 S+ 14:08 0:00 grep --color=auto nginx [root@bogon html]# kill -HUP 9149
利用logs/nginx.pid获取nginx正在使用的进程号
[root@bogon logs]# kill -HUP `cat /usr/local/nginx/logs/nginx.pid`
MYSQL安装(rpm方式)(5.6.17下载地址:http://www.360sdn.com/opensource-datasource/2014/0410/2940.html)
检测并删除已有的MYSQL
[root@iZ28mhfkaunZ mysql]# rpm -qa|grep -i mysql [root@iZ28mhfkaunZ mysql]# rpm -e mysql
MYSQL安装,server为服务器,devel为所需的库和包含文件。如果你想要编译其他MySQL客户程序, 例如Perl模块。client客户端;
[root@iZ28mhfkaunZ mysql]# rpm -ivh MySQL-server-5.6.17-1.linux_glibc2.5.x86_64.rpm [root@iZ28mhfkaunZ mysql]# rpm -ivh MySQL-devel-5.6.17-1.linux_glibc2.5.x86_64.rpm [root@iZ28mhfkaunZ mysql]# rpm -ivh MySQL-client-5.6.17-1.linux_glibc2.5.x86_64.rpm
配置文件复制
[root@iZ28mhfkaunZ mysql]# cp /usr/share/mysql/my-default.cnf /etc/my.cnf
MYSQL的默认安装路径
[root@iZ28mhfkaunZ mysql]# find / -name mysql /usr/bin/mysql /usr/include/mysql /usr/include/mysql/mysql /usr/lib64/mysql /usr/share/mysql /etc/logrotate.d/mysql /etc/rc.d/init.d/mysql /root/soft/mysql /var/lib/mysql /var/lib/mysql/mysql
注:如果安装时出现如下情况,说明系统已经安装了其他版本的mysql-libs包导致不兼容;需先删除mysql-libs,再进行安装
[root@iZ28mhfkaunZ mysql]# rpm -ivh MySQL-server-5.6.17-1.linux_glibc2.5.x86_64.rpm Preparing... ################################# [100%] file /usr/share/mysql/charsets/README from install of MySQL-server-5.6.17-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.40-1.el7_0.x86_64 file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.6.17-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.40-1.el7_0.x86_64
[root@iZ28mhfkaunZ mysql]# yum list | grep mysql [root@iZ28mhfkaunZ mysql]# yum remove mysql-libs
初始化MySQL及设置密码
[root@iZ28mhfkaunZ mysql]# /usr/bin/mysql_install_db [root@iZ28mhfkaunZ mysql]# service mysql start [root@iZ28mhfkaunZ mysql]# cat /root/.mysql_secret #冒号后面的为密码 # The random password set for the root user at Thu May 19 14:18:36 2016 (local time): YfhsJippgttAsFT0 [root@iZ28mhfkaunZ mysql]# mysql -uroot -pYfhsJippgttAsFT0 mysql> SET PASSWORD=PASSWORD('001020');Query OK, 0 rows affected (0.00 sec) #重设当前账号的密码
设置允许远程登陆
mysql> use mysql Database changed mysql> select host,user,password from user; +--------------+------+-------------------------------------------+ | host | user | password | +--------------+------+-------------------------------------------+ | localhost | root | *BBB8EB4152EEBB848CB1CFC6B622E68560B6942C | | iz28mhfkaunz | root | *B65B90BD55CF595D88D65B2B06683C557739BDD9 | | 127.0.0.1 | root | *B65B90BD55CF595D88D65B2B06683C557739BDD9 | | ::1 | root | *B65B90BD55CF595D88D65B2B06683C557739BDD9 | +--------------+------+-------------------------------------------+ 4 rows in set (0.00 sec) mysql> update user set password=password('001020') where user='root'; Query OK, 3 rows affected (0.00 sec) Rows matched: 4 Changed: 3 Warnings: 0 mysql> update user set host='%' where user='root' and host='localhost'; Query OK, 1 row affected (0.02 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
添加开机启动,centos7里rc.local默认是没有执行权限的,需手动添加,否则开机时不会执行
[root@iZ28mhfkaunZ rc.d]# vim /etc/rc.d/rc.local /usr/local/web/nginx/sbin/nginx service mysql start [root@iZ28mhfkaunZ rc.d]# chmod +x ./rc.local
修改字符集和数据存储路径(参考用)
[client] password = 123456 port = 3306 default-character-set=utf8 [mysqld] port = 3306 character_set_server=utf8 character_set_client=utf8 collation-server=utf8_general_ci #(注意linux下mysql安装完后是默认:表名区分大小写,列名不区分大小写; 0:区分大小写,1:不区分大小写) lower_case_table_names=1 #(设置最大连接数,默认为 151,MySQL服务器允许的最大连接数16384; ) max_connections=1000 [mysql] default-character-set = utf8 #查看字符集 show variables like '%collation%'; show variables like '%char%';
1