LNMP快速安装

最近需要用到几台LNMP系统的服务器,把步骤记录一下。

环境:CentOS 6.4


1.更新YUM源:

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

cd /etc/yum.repos.d/

wget https://mirrors.163.com/.help/CentOS6-Base-163.repo

rpm -Uvh https://mirrors.ustc.edu.cn/fedora/epel/6/i386/epel-release-6-8.noarch.rpm 安装epel源

rpm -Uvh https://rpms.famillecollet.com/enterprise/remi-release-6.rpm 安装remi源


2.重建缓存 && 更新系统 && 重启系统

yum makecache

yum upgrade

reboot


3.安装PHP、mysql、nginx

yum install php php-fpm php-bcmath php-gd php-mbstring php-mcrypt php-mysql mysql-server nginx


4.设置mysql root密码

/usr/bin/mysqladmin -u root password '******'


5.设置服务开机启动

chkconfig --levels 234 mysqld on;chkconfig --levels 234 php-fpm on;chkconfig --levels 234 nginx on


6.修改nginx的配置文件

将/etc/nginx/conf.d/default.conf文件中的“/scripts”替换为“$document_root”,不然nginx无法将php代码传给php-fpm


7.测试PHP

在/usr/share/nginx/html/目录下创建phpinfo.php文件。内容如下:

<?php

phpinfo();

?>

注意,第一行的php三个字母必须要打。找个浏览器打开看看。能看到phpinfo()函数的输出,就证明一切OK了。

评论

© edwinz | Powered by LOFTER