centos7虚拟机中安装nginx+php+mysql
2017-03-12 12:27
459 查看
准备工作一、配置防火墙(iptables安装与配置) 1、禁用/停止自带的firewalld服务
#停止firewalld服务 systemctl stop firewalld #禁用firewalld服务 systemctl mask firewalld2、安装iptable iptable-service #先检查是否安装了iptablesservice iptables status#安装iptablesyum install -y iptables#升级iptables(安装的最新版本则不需要)yum update iptables #安装iptables-servicesyum install iptables-services
3、设置现有规则vim /etc/sysconfig/iptables 开启80端口、3306、22端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT :wq保存退出,重新启动防火墙 service iptables restart
二、配置selinux
vi /etc/selinux/config
设置SELINUX = disabled //如没有就添加
#重启系统
shutdown -r now
三、安装第三方yum源
#安装下载工具yum install wget#下载wget http://www.atomicorp.com/installers/atomic #安装sh ./atomic#更新yum源yum check-update
开始安装
一. 安装nginx
#删除系统自带的软件包yum remove httpd* php*#安装nginxyum install -y nginx#设置nginx开机启动chkconfig nginx on#启动nginxservice nginx start
二. 安装PHP
检查当前安装的PHP包yum list installed | grep php如果有安装的PHP包,先删除他们, 如:
yum remove php.x86_64 php-cli.x86_64 php-common.x86_64配置安装包源:
# CentOs 7.Xrpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm[/code] 如果想删除上面安装的包,重新安装rpm -qa | grep webstaticrpm -e [上面搜索到的包即可]执行安装yum -y install php56w.x86_64yum -y --enablerepo=webtatic install php56w-develyum -y install php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64 php56w-opcache.x86_64安装PHP FPM4000yum -y install php56w-fpm#设置php-fpm开机启动systemctl enable php-fpm#启动php-fpmsystemctl restart php-fpm注:如果想更换到php5.5或5.4版本, 直接把上面的56w换成55w或者54w就可以了三. 安装 MySQL
安装yum install mysql mysql-server(如果安装不成功,需要 下载mysql的repo源) 成功安装之后重启mysql服务(centos7以将mysql转为mariadb的安装了) systemctl restart mariadb.service 2.为root账户设置密码 mysql_secure_installation四. 配置nginx,php
1.配置nginx vi /etc/nginx/nginx.confserver {listen 80;server_name example.com;location / {root /usr/share/nginx/html/test/;try_files $uri $uri/ /index.php?$query_string;index index.php index.html index.htm;}error_page 404 /404.html;location = /404.html {root /usr/share/nginx/html/test/;}error_page 500 502 503 504 /50x.html;location = /50x.html {root /usr/share/nginx/html/test/;}location ~ \.php$ {root /usr/share/nginx/html/test/;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}}重启nginxsystemctl restart nginx.service2.配置php-fpm修改user和group[/code]vi /etc/php-fpm.d/www.conf
user = nginx`group = nginx重启php-fpm服务systemctl restart php-fpm.service测试是否成功vi /usr/share/nginx/html/test/index.php<?phpphpinfo();?>curl 127.0.0.1 (查看是否配置成功)
相关文章推荐
- 虚拟机上CentOS 7.0编译安装Nginx+MySQL+PHP(一)
- 虚拟机上CentOS 7.0编译安装Nginx+MySQL+PHP(二)
- centos安装nginx+mysql+php+fastcgi+memcache最简单方法
- Centos 5.5 Nginx+php+mysql成功安装案例
- CentOS上yum安装nginx+mysql+php+php-fastcgi [经本人整理后亲自测试]
- CentOS 编译 nginx+php+mysql 安装手记
- 在CentOs 5.1中使用rpm安装NGINX+php+mysql(一)
- 1分钟完美安装最新 CentOS + Nginx + PHP-FPM + MySQL
- CentOS5.5安装Nginx、PHP(FastCGI)、MySQL --搭建LNMP环境安装wordpress
- 1分钟完美安装最新 CentOS + Nginx + PHP-FPM + MySQL
- CentOS 编译 nginx+php+mysql 安装手记
- Centos-5.5-64位安装nginx-0.8.54+php-5.3.4+mysql-5.5.8+memcache-2.2.6(转)
- 在CentOs 5.1中使用rpm安装NGINX+php+mysql
- CentOS上yum安装nginx+mysql+php+php-fastcgi [经本人整理后亲自测试]
- centos 5.6安装nginx+mysql+php(php-fpm)+phpmyadmin总结
- Centos 5.5 Nginx+php+mysql成功安装案例
- 详解 CentOS 安装配置 Nginx 0.8.33+PHP 5.3.1+php-fpm+MySQL 全过程【转】
- 三、CentOS下安装nginx、php和mysql
- centos安装nginx+mysql+php+fastcgi+memcache最简单方法
- CentOS 5.5一键安装nginx+mysql+php