本文共 3347 字,大约阅读时间需要 11 分钟。
CentOS-6 最小化系统部署lnmp环境
一:准备工作
yum install -y vimyum install -y wgetyum 阿里源wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
编写 nginx.repo 文件cat>>/etc/yum.repos.d/nginx.repo<
关闭防火墙和selinuxsed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/sysconfig/selinuxservice iptables stop
二:安装 nginx
yum install -y nginxservice nginx startnetstat -tunlp|grep 80ps -ef | grep nginx创建 php 测试文件vim /usr/share/nginx/html/index.php
注意:nginx -t 可以用来检测 nginx 配置是否正确,这里荐使用 systemctl status nginx.service 来检测
三:安装 php
yum install php-cli php-fpm -yyum install -y php-*service php-fpm startnetstat -tunlp|grep 9000修改vim /etc/nginx/conf.d/default.conf参数
location / { root /usr/share/nginx/html; index index.php index.html index.htm;}location ~ \.php$ { root /usr/share/nginx/html/; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name; include fastcgi_params;}
service nginx restartservice nginx reload修改php-fpm配置文件php-fpm配置文件位置:(vim /etc/php-fpm.d/www.conf) 修改user =nginxgroup=nginx可以把 php-fpm、nginx 放到开机自启中chkconfig php-fpm onchkconfig nginx on
四:安装 mydql
yum install mysql mysql-serverservice mysqld startnetstat -tunlp|grep 3306创建 mysql 密码#mysql即可进入mysqlmysql> use mysql;mysql> update user set password=password("123456") where user="root";mysql> flush privileges;mysql> quit
以下把自己的 php 项目放到根目录下就可以cd /usr/share/nginx/html/cd ..chmod -R 777 html如果报数据库的错库,可以重启虚拟机试试看init 6service iptables stopservice mysqld start
CentOS-7 最小化系统部署lnmp环境
一:准备工作
yum install -y vimyum install -y wget
编写 nginx.repo 文件cat>>/etc/yum.repos.d/nginx.repo<
关闭防火墙和selinuxsystemctl stop firewalld.servicesystemctl disable firewalld.servicesed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/sysconfig/selinux
二:安装 nginx
yum install -y nginxsystemctl start nginx.servicenetstat -tunlp|grep 80ps -ef | grep nginx创建 php 测试文件vim /usr/share/nginx/html/index.php
注意:nginx -t 可以用来检测 nginx 配置是否正确,这里荐使用 systemctl status nginx.service 来检测
三:安装 php
yum install php-cli php-fpmyum install -y php-*systemctl start php-fpm.servicenetstat -tunlp|grep 9000修改vim /etc/nginx/conf.d/default.conf参数
location / { root /usr/share/nginx/html; index index.php index.html index.htm;}location ~ \.php$ { root /usr/share/nginx/html/; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name; include fastcgi_params;}
systemctl reload nginx.service修改php-fpm配置文件php-fpm配置文件位置:(vim /etc/php-fpm.d/www.conf) 修改user =nginxgroup=nginx可以把 php-fpm、nginx 放到开机自启中chkconfig php-fpm onchkconfig nginx on
四:安装 mydql
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpmrpm -ivh mysql-community-release-el7-5.noarch.rpmyum install mysql-server -ysystemctl start mysqld.servicemysql -u rootchown -R root:root /var/lib/mysqlmysql -u root use mysql; update user set password=password("123456") where user="root"; flush privileges; exit;systemctl restart mysqld.servicenetstat -tunlp|grep 3306/etc/my.cnf文件的 skip-grant-tables 这一行,控制 MySQL 能否免密码登录
以下把自己的 php 项目放到根目录下就可以cd /usr/share/nginx/html/cd ..chmod -R 777 html如果报数据库的错库,可以重启虚拟机试试看init 6service iptables stopservice mysqld start
转载于:https://blog.51cto.com/12384628/2151037