首先要明白:Linux在启动的时候会去执行/etc/rc.local脚本的文件vim
因此咱们须要这样作:服务器
Bash索引
[root@m /]# vim /etc/rc.localit
而后将sphinx建立索引和启动的命令放在这个文件里,以下:权限
Bashgrep
touch /var/lock/subsys/local #create index /usr/local/bin/indexer -c /usr/local/etc/sphinx.conf --rotate --all #open searchd /usr/local/bin/searchd -c /usr/local/etc/sphinx.confim
至此,咱们看似完工了,其实忽略了一个大问题(这个问题研究了好半天):系统要执行这些命令,就必需要给这个文件可执行的权限脚本
Bashsphinx
[root@m etc]# chmod +x rc.localtouch
而后重启服务器,查看sphinx是否启动
Bash
[root@m etc]# ps aux | grep searchd
重启以后,sphinx启动!