上篇文章是對mysql的安裝,接着上篇文章,這篇文章安裝nginx服務mysql
默認狀況Centos7中無Nginx的源,最近發現Nginx官網提供了Centos的源地址。所以能夠以下執行命令添加源:nginx
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install -y nginx
systemctl start nginx.service systemctl enable nginx.service
http://ip 默認80端口
若沒法訪問 ,須要在iptable上添加80端口,若是用的阿里雲或騰訊雲還須要添加安全組web
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
service iptables save
service iptables restart
service iptables status
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
執行如下命令查看服務狀態sql
systemctl status nginx
nginx.service - nginx - high performance web server Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled) Active: failed (Result: exit-code) since 四 2019-05-30 14:34:48 CST; 1min 35s ago Docs: http://nginx.org/en/docs/ Process: 6051 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE) Main PID: 1542 (code=killed, signal=KILL) 5月 30 14:34:45 iz2ze3bc56k6c8wubzxn9kz nginx[6051]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) 5月 30 14:34:46 iz2ze3bc56k6c8wubzxn9kz nginx[6051]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) 5月 30 14:34:46 iz2ze3bc56k6c8wubzxn9kz nginx[6051]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) 5月 30 14:34:47 iz2ze3bc56k6c8wubzxn9kz nginx[6051]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) 5月 30 14:34:47 iz2ze3bc56k6c8wubzxn9kz nginx[6051]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) 5月 30 14:34:48 iz2ze3bc56k6c8wubzxn9kz systemd[1]: nginx.service: control process exited, code=exited status=1 5月 30 14:34:48 iz2ze3bc56k6c8wubzxn9kz nginx[6051]: nginx: [emerg] still could not bind() 5月 30 14:34:48 iz2ze3bc56k6c8wubzxn9kz systemd[1]: Failed to start nginx - high performance web server. 5月 30 14:34:48 iz2ze3bc56k6c8wubzxn9kz systemd[1]: Unit nginx.service entered failed state. 5月 30 14:34:48 iz2ze3bc56k6c8wubzxn9kz systemd[1]: nginx.service failed.
能夠看到以上錯誤是由於端口被佔用的緣由centos
查看nginx服務 ps -ef | grep nginx 殺死進程 pkill -9 nginx 再啓動就能夠了 systemctl start nginx