装完并无任何设置,这篇记录一下设置。先设置 nginx 吧,nginx 网上多如繁星的设置但大都比较简单,属于基础设置,所以此处只贴出设置后的结果,用红色框表示一些本身改动或须要注意的地方php
nginx 的基础设置很简单,设置个三次以上都能直接记住了。本身配置了一下 关于400、500系列错误的默认显示路径,40四、403错误都显示 40x.html,500 的几个错误都显示 50x.html 错误,这样页面就能本身定义了。好比如今 404 就会显示这样一个页面html
由于是编译安装,所以安装后是这样启动的linux
cd /usr/local/nginx sudo ./nginx
今天在写配置时发现网上神句没法启动nginx
sudo systemctl start nginx
百度大法让写一个脚本,好吧,写,打开 vimvim
#!/bin/sh # # nginx - this script starts and stops the nginx daemon # # chkconfig: - 85 15 # description: Nginx is an HTTP(S) server, HTTP(S) reverse \ # proxy and IMAP/POP3 proxy server # processname: nginx # config: /etc/nginx/nginx.conf # config: /etc/sysconfig/nginx # pidfile: /var/run/nginx.pid # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0 nginx="/usr/local/nginx/sbin/nginx" prog=$(basename $nginx) NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx lockfile=/var/lock/subsys/nginx start() { [ -x $nginx ] || exit 5 [ -f $NGINX_CONF_FILE ] || exit 6 echo -n $"Starting $prog: " daemon $nginx -c $NGINX_CONF_FILE retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval } stop() { echo -n $"Stopping $prog: " killproc $prog -QUIT retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval killall -9 nginx } restart() { configtest || return $? stop sleep 1 start } reload() { configtest || return $? echo -n $"Reloading $prog: " killproc $nginx -HUP RETVAL=$? echo } force_reload() { restart } configtest() { $nginx -t -c $NGINX_CONF_FILE } rh_status() { status $prog } rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart|configtest) $1 ;; reload) rh_status_q || exit 7 $1 ;; force-reload) force_reload ;; status) rh_status ;; condrestart|try-restart) rh_status_q || exit 0 ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" exit 2 esac #!/bin/sh # # nginx - this script starts and stops the nginx daemon # # chkconfig: - 85 15 # description: Nginx is an HTTP(S) server, HTTP(S) reverse \ # proxy and IMAP/POP3 proxy server # processname: nginx # config: /etc/nginx/nginx.conf # config: /etc/sysconfig/nginx # pidfile: /var/run/nginx.pid # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0 nginx="/usr/local/nginx/sbin/nginx" prog=$(basename $nginx) NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx lockfile=/var/lock/subsys/nginx start() { [ -x $nginx ] || exit 5 [ -f $NGINX_CONF_FILE ] || exit 6 echo -n $"Starting $prog: " daemon $nginx -c $NGINX_CONF_FILE retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval } stop() { echo -n $"Stopping $prog: " killproc $prog -QUIT retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval killall -9 nginx } restart() { configtest || return $? stop sleep 1 start } reload() { configtest || return $? echo -n $"Reloading $prog: " killproc $nginx -HUP RETVAL=$? echo } force_reload() { restart } configtest() { $nginx -t -c $NGINX_CONF_FILE } rh_status() { status $prog } rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart|configtest) $1 ;; reload) rh_status_q || exit 7 $1 ;; force-reload) force_reload ;; status) rh_status ;; condrestart|try-restart) rh_status_q || exit 0 ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" exit 2 esac
而后执行centos
:w /etc/init.d/nginx :q sudo chmod 755 /etc/init.d/nginx sudo chkconfig --add nginx
完成后,能够用如下命令对 nginx 进行操做(还有插曲)php-fpm
#启动 nginx 服务 sudo service nginx start #中止 nginx 服务 sudo service nginx stop #无间断服务重启 sudo service nginx reload
先往下继续吧,安装 php-fpm 组件ui
sudo yum install php-fpm
编辑一下 /etc/php.ini (吐槽下 linux 下的配置文件在这个位置?)this
#自愿是否先备份一下 sudo cp /etc/php.ini /etc/php.ini.backup sudo vim /etc/php.ini /cgi.fix_pathinfo 找到后去掉前面的分号 ;
:wq
配置 www.confcentos7
#自愿备份一下 www.conf sudo cp /etc/php.fpm.d/www.conf /etc/php-fpm.d/www.conf.backup sudo vim /etc/php.fpm.d/www.conf #将 user = xxxx 改成 user = 已经存在的有权限的用户 #将 grouip = xxx 改成 group = 已经存在的有权限的组 #以上两句是百度出来的,在虚拟机上我改成了当前用户名
依次启动 php-fpm 和 (重)启动 nginx
sudo systemctl start php-fpm #设置php-fpm开机启动 #sudo systemctl enable php-fpm sudo systemctl restart nginx
这里的插曲在于我用 kill -quit nginx 退出以后再用 service start nginx 时遇到了错误提示
而后用 systemctl start nginx 启动了,但一下子也会出现提示
暂时还不明因此,但 php 能够运行了
一些记录和连接: