构建LNMP环境

搭建基础环境:Centos7.2   ,下列内容为脚本内容。


#! /bin/bash

#

#基础工作

chkconfig iptables off

getenforce

mkdir /save


#下载atomic yum源

yum install wget

wget /save/http://www.atomicorp.com/installers/atomic

sh ./save/atomic


#安装开发包和库文件

yum check-update


#安装开发包和库文件

yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel


#卸载已有软件

yum remove httpd mysql php php-fpm


#安装nginx

yum -y install nginx

chkconfig --levels 235 nginx on

mv /etc/nginx/nginx.conf /etc/nginx/nginx.confbak

mv /etc/nginx/nginx.conf /save

cp /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf


sed -i 45s'/index.html/index.php index.html/'  /etc/nginx/nginx.conf

sed -i 65,71s/\#//g /etc/nginx/nginx.conf

sed -i 66s'@html@/usr/share/nginx/html@'    /etc/nginx/nginx.conf

sed -i 69s'@scripts@usr/share/nginx/html@'  /etc/nginx/nginx.conf


#安装mysql

wgethttp://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

rpm -ivh mysql-community-release-el7-5.noarch.rpm

yum -y install mysql mysql-community-server mysql-devel

chkconfig --levels 235 mysqld on

#>mysql set password = password('新密码');

#grant all privileges on *.* to root@"localhost" identified by "新密码"; 设置用户 root 可以在本地被访问:




#安装php

yum -y install php lighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap php-tidy php-common php-devel php-fpm


chkconfig --levels 235 php-fpm on

echo "cgi.fix_pathinfo = 1" >> /etc/php.ini


systemctl start nginx

systemctl start mysql

systemctl start php-fpm




以上为脚本内容。

创建测试文档

vi /usr/share/nginx/html/info.php


                   $conn=mysql_connect('host','user','password');    #用于测试是否能链接数据库

                   if($conn)

                         echo "Success...";

                   else

                         echo "Failur...";

                    phpinfo();                                   #用于测试nginx是否能调用php解释器

?>


验证:

访问http://localhost:80/info.php

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 地址:https://help.aliyun.com/document_detail/50700.html?spm...
    Freeasthew_a098阅读 1,521评论 0 0
  • 昨晚阿里云不知搞得啥活动,就入手了一台香港的云服务器,买了三年,价格也是很便宜,今天就给它搭建了一个lnmp环境,...
    nooops阅读 3,926评论 0 0
  • 系统环境 所需软件官方下载地址: 一、 安装开发包环境: 二、 关闭iptables和Selinux(生产...
    莫名其妙的一生阅读 5,121评论 0 4
  • 每天早晚接送孩子加自己上班,来回差不多要花费1小时。孩子们在车上的时候,我们听儿童歌曲,中文的、英文的,有时也放莫...
    叫我哆啦美阅读 3,089评论 31 16
  • 今日是全蜀州锦官城会试发捷报的大喜日子,太守早已写好了请柬,请蜀郡的今科举子们在太守府吃饭。 家不在锦官城的考生清...
    柳汀雪阅读 1,664评论 0 1