#! /bin/sh # chkconfig: 2345 55 25 # Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and # run 'update-rc.d -f nginx defaults', or use the appropriate command on your # distro. For CentOS/Redhat run: 'chkconfig --add nginx'
### BEGIN INIT INFO # Provides: nginx # Required-Start: $all # Required-Stop: $all # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts the nginx web server # Description: starts nginx using start-stop-daemon ### END INIT INFO
# Author: licess # website: http://lnmp.org
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/ NAME=nginx NGINX_BIN=/usr/local/nginx/sbin/$NAME CONFIGFILE=/usr/local/nginx/conf/$NAME.conf PIDFILE=/usr/local/nginx/logs/$NAME.pid case "$1" in start) echo -n "Starting $NAME... "
if netstat -tnpl | grep -q nginx;then echo "$NAME (pid `pidof $NAME`) already running." exit 1 fi
$NGINX_BIN -c $CONFIGFILE
if [ "$?" != 0 ] ; then echo " failed" exit 1 else echo " done" fi ;;
stop) echo -n "Stoping $NAME... "
if ! netstat -tnpl | grep -q nginx; then echo "$NAME is not running." exit 1 fi
$NGINX_BIN -s stop
if [ "$?" != 0 ] ; then echo " failed. Use force-quit" exit 1 else echo " done" fi ;;
status) if netstat -tnpl | grep -q nginx; then PID=`pidof nginx` echo "$NAME (pid $PID) is running..." else echo "$NAME is stopped" exit 0 fi ;;
force-quit) echo -n "Terminating $NAME... "
if ! netstat -tnpl | grep -q nginx; then echo "$NAME is not running." exit 1 fi
kill `pidof $NAME`
if [ "$?" != 0 ] ; then echo " failed" exit 1 else echo " done" fi ;;
restart) $0 stop sleep 1 $0 start ;;
reload) echo -n "Reload service $NAME... "
if netstat -tnpl | grep -q nginx; then $NGINX_BIN -s reload echo " done" else echo "$NAME is not running, can't reload." exit 1 fi ;;
## 授予任何主机访问权限 ## 授予任何主机访问权限 ### % 为通配符,如果需要限制某IP段可以改为'root'@'192.168.%' mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
## 进入MariaDB $ mysql -u root -h 192.168.1.201 -p 3306 $ use mysql $ update user set password=password('123456') where user='root'; $ flush privileges; $ exit;
数据库卸载
1 2
$ yum -y remove mari* $ rm -rf /var/lib/mysql/*
Redis 安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
## 安装wget包,有可以忽略 $ yum -y install wget ## 下载Redis $ wget http://download.redis.io/releases/redis-4.0.8.tar.gz ## 解压Redis $ tar xzf redis-4.0.8.tar.gz ## 编译安装Redis $ cd redis-4.0.8 ## 安装make包,有可以忽略 $ yum install make $ make test $ make install ## 将Redis添加到服务 $ cd utils $ ./install_server.sh ## 查看Redis版本 $ redis-server -v
$ cd /etc/sysconfig/network-scripts ## 对ifcfg-xxx网络配置文件进行修改 $ vi ifcfg-xxx ## 重启网络服务 $ service network restart
ifconfig: command not found
解决:
1
$ yum install net-tools
Nginx 安装
执行 ./configure 时候出错 1
1 2 3 4 5
checking for OS + Linux 2.6.32-642.el6.x86_64 x86_64 checking for C compiler ... not found
./configure: error: C compiler cc is not found
处理: 如果安装出现在下面的错误是缺少编译环境,安装编译源码所需的工具和库
1
$ yum -y install gcc
执行 ./configure 时候出错 2
1 2 3 4
./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using --without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using --with-pcre=<path> option.
nginx: [emerg] getgrnam("root") failed in /usr/local/nginx/conf/nginx.conf:1
可以修改/usr/local/nginx/conf/nginx.conf
添加
1
$ user root owner;
Redis安装
编译问题 cc: command not found
1 2 3 4 5 6 7 8
[root@localhost redis-4.0.8]# make install cd src && make install make[1]: Entering directory `/root/redis-4.0.8/src' CC adlist.o /bin/sh: cc: command not found make[1]: *** [adlist.o] Error 127 make[1]: Leaving directory `/root/redis-4.0.8/src' make: *** [install] Error 2
解决:
1
$ yum install gcc
编译问题 fatal error: jemalloc/jemalloc.h: No such file or directory
1 2 3 4 5 6 7 8 9 10 11 12
[root@localhost redis-4.0.8]# make install cd src && make install make[1]: Entering directory `/root/redis-4.0.8/src' CC adlist.o In file included from adlist.c:34:0: zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory #include <jemalloc/jemalloc.h> ^ compilation terminated. make[1]: *** [adlist.o] Error 1 make[1]: Leaving directory `/root/redis-4.0.8/src' make: *** [install] Error 2
解决:
1
$ make MALLOC=libc
编译问题 You need tcl 8.5 or newer in order to run the Redis test
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
[root@localhost redis-4.0.8]# make install cd src && make install make[1]: Entering directory `/root/redis-4.0.8/src'
Hint: It's a good idea to run 'make test' ;)
INSTALL install INSTALL install INSTALL install INSTALL install INSTALL install make[1]: Leaving directory `/root/redis-4.0.8/src' [root@localhost redis-4.0.8]# make test cd src && make test make[1]: Entering directory `/root/redis-4.0.8/src' You need tcl 8.5 or newer in order to run the Redis test make[1]: *** [test] Error 1 make[1]: Leaving directory `/root/redis-4.0.8/src' make: *** [test] Error 2