centos7+php+nginx+mysql安装

前端之家收集整理的这篇文章主要介绍了centos7+php+nginx+mysql安装前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
MysqL安装:

1、下载MysqL的repo源


wgethttp://repo.MysqL.com/MysqL-community-release-el7-5.noarch.rpm

2、安装MysqL-community-release-el7-5.noarch.rpm包



rpm-ivhMysqL-community-release-el7-5.noarch.rpm


备注:安装这个包后,会获得两个MysqL的yumrepo源:/etc/yum.repos.d/MysqL-community.repo,/etc/yum.repos.d/MysqL-community-source.repo

3、安装MysqL:



yuminstallMysqL-server


4、启动服务



systemctlstartMysqLd


PHP安装:

官网下载:http://PHP.net/downloads.PHP

1、版本下载

http://cn2.PHP.net/get/PHP-7.1.0.tar.gz/from/this/mirror
2、解压

tar-zxvfPHP-7.1.0.tar.gz
3、进入目录


cdPHP-7.1.0
4、下载扩展库

yuminstall-ylibxml2-develPHP-mcryptlibmcryptlibmcrypt-developensslopenssl-devellibcurllibcurl-develzlibzlib-devellibjpeglibjpeg-develfreetypefreetype-devellibpnglibpng-devel
5、编译安装


./configure--prefix=/usr/local/PHP7\
--with-config-file-path=/usr/local/PHP7/etc\
--with-mcrypt=/usr/include\
--with-MysqL\
--with-gd\
--with-iconv\
--with-zlib\
--enable-xml\
--enable-bcmath\
--enable-shmop\
--enable-sysvsem\
--enable-inline-optimization\
--enable-mbregex\
--enable-fpm\
--enable-mbstring\
--enable-ftp\
--enable-gd-native-ttf\
--with-openssl\
--enable-pcntl\
--enable-sockets\
--with-xmlrpc\
--enable-zip\
--enable-soap\
--without-pear\
--with-gettext\
--enable-session\
--with-curl\
--with-jpeg-dir\
--with-freetype-dir\
--enable-opcache

make
makeinstall

6、配置:


cpPHP.ini-development/usr/local/PHP7/lib/PHP.ini
cp/usr/local/PHP7/etc/PHP-fpm.conf.default/usr/local/PHP7/etc/PHP-fpm.conf
cp/usr/local/PHP7/etc/PHP-fpm.d/www.conf.default/usr/local/PHP7/etc/PHP-fpm.d/www.conf
7、添加服务


vim/etc/systemd/system/PHP-fpm.service

[Unit]
Description=ThePHPFastCGIProcessManager
After=syslog.targetnetwork.target

[Service]
Type=simple
PIDFile=/run/PHP-fpm.pid
ExecStart=/usr/local/PHP7/sbin/PHP-fpm--nodaemonize--fpm-config/usr/local/PHP7/etc/PHP-fpm.conf
ExecReload=/bin/kill-USR2$MAINPID
ExecStop=/bin/kill-SIGINT$MAINPID

[Install]
WantedBy=multi-user.target
8、启动PHP-fpm


systemctlstartPHP-fpm.service
9、添加到开机启动


systemctlenablePHP-fpm.service
备注:systemctl指令


systemctlenable*.service#开机运行服务
systemctldisable*.service#取消开机运行
systemctlstart*.service#启动服务
systemctlstop*.service#停止服务
systemctlrestart*.service#重启服务
systemctlreload*.service#重新加载服务配置文件
systemctlstatus*.service#查询服务运行状态
systemctl--Failed#显示启动失败的服务


Nginx安装配置:

1、下载安装包


wgethttp://Nginx.org/download/Nginx-1.10.1.tar.gz
2、解压


tar-zvxfNginx-1.10.1.tar.gz
3、进入目录


cdNginx-1.10.1
4、编译安装


./configure--prefix=/usr/local/Nginx-1.10.1\
--with-http_ssl_module\
--with-http_stub_status_module

make
makeinstall



ln-s/usr/local/Nginx-1.10.1//usr/local/Nginx


5、添加启动脚本


vim/etc/init.d/Nginx

复制代码
#!/bin/bash
#
#Nginx-thisscriptstartsandstopstheNginxdaemon
#
#chkconfig:-8515
#description:NginxisanHTTP(S)server,HTTP(S)reverse\
#proxyandIMAP/POP3proxyserver
#
#processname:Nginx
#config:/etc/Nginx/Nginx.conf
#pidfile:/var/run/Nginx/Nginx.pid

#Sourcefunctionlibrary.
./etc/rc.d/init.d/functions

#Sourcenetworkingconfiguration.
./etc/sysconfig/network

#Checkthatnetworkingisup.
["$NETWORKING"="no"]&&exit0

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/Nginx.lock

start(){
[-x$Nginx]||exit5
[-f$Nginx_CONF_FILE]||exit6
echo-n$"Starting$prog:"
daemon$Nginx-c$Nginx_CONF_FILE
retval=$?
echo
[$retval-eq0]&&touch$lockfile
return$retval
}

stop(){
echo-n$"Stopping$prog:"
killproc$prog-QUIT
retval=$?
echo
[$retval-eq0]&&rm-f$lockfile
return$retval
}

restart(){
configtest||return$?
stop
sleep1
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/null2>&1
}

case"$1"in
start)
rh_status_q&&exit0
$1
;;
stop)
rh_status_q||exit0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q||exit7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q||exit0
;;
*)
echo$"Usage:$0{start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit2
esac

猜你在找的CentOS相关文章