快速部署LNMP环境,这种适合对php版本和mysql版本没有要求,对数据存放没有要求的用户,yum安装基本5分钟能够将环境所需的所有软件都能搞定,快速部署
yum install wget #下载wget工具 wget http://www.atomicorp.com/installers/atomicsh ./atomic #更新yum软件包 yum check-update
4.安装开发包和库文件
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
5.安装nginx
yum install nginx service nginx start chkconfig --levels 235 nginx on
6.安装mysql
yum install mysql mysql-server mysql-devel service mysqld start chkconfig --levels 235 mysqld on mysqladmin -u root password "123456" #为root用户设置密码 service mysqld restart
7.安装php
yum 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 #安装php和所需组件使PHP支持MySQL、FastCGI模式 service php-fpm start chkconfig --levels 235 php-fpm on
9.配置nginx支持php
cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak vi /etc/nginx/conf.d/default.conf
修改nginx配置文件,添加fastcgi支持
vi /etc/nginx/nginx.conf #加入index.php 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; }
将以上代码注释去掉,并修改成nginx默认路径,script改为实际路径 /usr/share/nginx/html
10.配置php
编辑文件php.ini
vi /etc/php.ini cgi.fix_pathinfo = 1
11.重启nginx php-fpm
service nginx restart service php-fpm restart
12.建立info.php文件
vi /usr/share/nginx/html/info.php <?php phpinfo(); ?>
13.测试nginx是否解析php
输入:http://IP/info.php
显示php界面说明解析成功