This howto guide explains more deeply on how to install LEMP (Linux,Nginx,MySQL,PHP)
on pre-installed Linux servers and installation instructions can be used on various Linux distribution such asRHEL
6.2/6.1/6/5.8,CentOS
6.2/6.1/6/5.8andFedora
12,13,14,15,16,17,18servers usingRemiandNginxrepositories
withYUMcommand.
In this guide we use latestMySQL
5.5.29andPHP
5.4.11versions withPHP-FPMmodules
with Nginx. So, before moving further for installation let’s discuss aboutNginxandPHP-FPM.
Setup LEMP Stack in Linux
What is Nginx?
Nginx(Engine
X) is open source robust light and high performance Web server, reverse proxy sever and also mail proxy server forHTTP,SMTP,POP3andIMAPprotocols.
To know more about features visithttp://wiki.nginx.org/Overview
What is PHP-FPM?
PHP-FPMstands
forFastCGI
Process Manageris an alternativePHP
FastCGIimplementation with some additional useful features for heavily loaded websites. For more information visithttp://php-fpm.org/
Install
LEMP (Linux, Nginx, MySQL, PHP) onRHEL
6.2/6.1/6/5.8,CentOS
6.2/6.1/6/5.8andFedora
12,13,14,15,16,17,18
Step 1: Installing Remi Repository
## Install Remi Repository on Fedora 18, 17, 16, 15 ##
# rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
# rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm
## Fedora 18 ##
# rpm -Uvh http://rpms.famillecollet.com/remi-release-18.rpm
## Fedora 17 ##
# rpm -Uvh http://rpms.famillecollet.com/remi-release-17.rpm
## Fedora 16 ##
# rpm -Uvh http://rpms.famillecollet.com/remi-release-16.rpm
## Fedora 15 ##
# rpm -Uvh http://rpms.famillecollet.com/remi-release-15.rpm
## Fedora 14 ##
# rpm -Uvh http://rpms.famillecollet.com/remi-release-14.rpm
## Fedora 13 ##
# rpm -Uvh http://rpms.famillecollet.com/remi-release-13.rpm
## Fedora 12 ##
# rpm -Uvh http://rpms.famillecollet.com/remi-release-12.rpm
## Install Remi Repository on RHEL/CentOS 6.3-6.0 ##
# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
## Install Remi Repository on RHEL/CentOS 5.4-5.0 ##
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
Step 2: Installing Nginx Repository
Nginxrepository
only needed inRHEL/CentOSdistributions.
So, create a file called/etc/yum.repos.d/nginx.repoand
add the following lines to it.
For RHEL 6.3/6.2/6.1/6/5.8
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/rhel/$releasever/$basearch/
gpgcheck=0
enabled=1
For CentOS 6.3/6.2/6.1/6/5.8
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
Step 3: Installing Ngnix, MySQL 5.5.29, PHP 5.4.11 & PHP-FPM
## Installing on Fedora 12, 13, 14, 15, 16, 17, 18 ##
# yum --enablerepo=remi install nginx mysql mysql-server php php-common php-fpm
## Installing on RHEL/CentOS 5-6 ##
# yum --enablerepo=remi,remi-test install nginx mysql mysql-server php php-common php-fpm
Step 4: Installing PHP 5.4.11 Modules
## Installing on Fedora 12, 13, 14, 15, 16, 17, 18 ##
# yum --enablerepo=remi install php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml php-pecl-apc php-cli php-pear php-pdo
## Installing on RHEL/CentOS 5-6 ##
# yum --enablerepo=remi,remi-test install php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml php-pecl-apc php-cli php-pear php-pdo
Step 5: Stopping Apache Service
ApacheandNginxboth
services are bind to same port (i.e.
80). So, you must stop turn-offApachein
order to useNginx.
# chkconfig --levels 235 httpd off
# /etc/init.d/httpd stop
Step 6: Starting/Stopping Nginx MySQL and PHP-FPM
## Enable Nginx, MySQL and PHP-FPM on Boot ##
# chkconfig --add nginx
# chkconfig --add mysqld
# chkconfig --add php-fpm
## Enable Nginx, MySQL and PHP-FPM on Run Levels ##
# chkconfig --levels 235 nginx on
# chkconfig --levels 235 mysqld on
# chkconfig --levels 235 php-fpm on
## Nginx Startup Commands ##
# /etc/init.d/nginx start
# /etc/init.d/nginx stop
# /etc/init.d/nginx status
## MySQL Startup Commands ##
# /etc/init.d/mysqld start
# /etc/init.d/mysqld stop
# /etc/init.d/mysqld status
## PHP-FPM Startup Commands ##
# /etc/init.d/php-fpm start
# /etc/init.d/php-fpm stop
# /etc/init.d/php-fpm status
Step 7: Configuring Nginx and PHP-FPM
Creating Website Directory
Creating a directory structure for your website under/srv/www/.
In my case I usedwww.tecmint.com.
This way you can create for your real site.
## public_html directory and logs directory ##
# mkdir -p /srv/www/tecmint/public_html
# mkdir /srv/www/tecmint/logs
# chown -R nginx:nginx /srv/www/tecmint
Creating Website Logs
Creating log directories under/var/log.
## public_html directory and logs directory ##
# mkdir -p /srv/www/tecmint/public_html
# mkdir -p /var/log/nginx/tecmint
# chown -R nginx:nginx /srv/www/tecmint
# chown -R nginx:nginx /var/log/nginx
Configuring Virtual Host Directories
Creating virtual host directoires under/etc/nginx.
# mkdir /etc/nginx/sites-available
# mkdir /etc/nginx/sites-enabled
Add following line of code to/etc/nginx/nginx.conffile
at the end, before closing (http
block) tag.
## Load virtual host conf files. ##
include /etc/nginx/sites-enabled/*;
For reference see below red line of code, how i added to the file/etc/nginx/nginx.conf.
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
Creating Virtual Host file for Tecmint
Add the following lines of code to/etc/nginx/sites-available/tecmintfile.
This is a basic virtual host config file.
server {
server_name tecmint;
access_log /srv/www/tecmint/logs/access.log;
error_log /srv/www/tecmint/logs/error.log;
root /srv/www/tecmint/public_html;
location / {
index index.html index.htm index.php;
}
location ~ .php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /srv/www/tecmint/public_html$fastcgi_script_name;
}
}
Linking Tecmint Virtual Host
Linkingtecmintvirtual
host to/etc/nginx/sites-enabled.
# cd /etc/nginx/sites-enabled/
# ln -s /etc/nginx/sites-available/tecmint
Restarting Nginx Service
We need here restart forNginxservice
to reflect all the configuration which we have done above.
# /etc/init.d/nginx restart
Adding Virtual Domain to Host File
Add the newly created virtual host domain to your local host file/etc/hosts.
127.0.0.1 localhost.localdomain localhost tecmint
Step 8: Testing Nginx, MySQL, PHP and PHP-FPM
Create a file calledphpinfo.phpunder/srv/www/tecmint/public_html/and
add the following lines of code to it. For example (/srv/www/tecmint/public_html/phpinfo.php).
<?php
phpinfo ();
?>
Now access the page with web browser usinghttp://tecmint/phpinfo.phpand
verify all versions.
That’s It! for now, If you’re having any problems in installation and configuration, please feel free to ask your questions using our comment form below.
分享到:
相关推荐
CentOS7安装nginx&&php7整合包
使用Alpine linux,Nginx,MySQL和PHP的Docker-compose项目。 几分钟即可轻松上手和运行 安装 使用DECK 从DECK市场安装lemp-stack并按照GUI上的说明进行操作 从Docker终端 git clone ...
LEMP是Linux,Nginx(发音为Engine X),MariaDB/MySQL和PHP的首字母缩写。 Nginx是一款开源,强大且高性能的Web服务器,它还可以兼作反向代理。 MariaDB是用于存储用户数据的数据库系统,而PHP是用于开发和支持...
用法docker run -d --name=lemp \ -v /path/to/www/:/var/www/ \ -v /path/to/mysql:/var/lib/mysql \ -p port_of_nginx:80 \ stenote/docker-lemp:latest细节MySQL 用户:root (无密码)SSH协议我们目前不支持SSH...
docker-koken-lemp, 使用 Docker Nginx MySQL和 PHP 5的Koken映像 这个官方的Koken Docker 映像安装了最新版本的 Koken插件和所有必要的系统需求。特性自动设置并配置Koken数据库,并在安装过程中跳过该步骤。添加一...
ansible-lemp-centos7 用于 PHP 开发的完整网络堆栈 - LEMP - Centos 7、Nginx、Percona 数据库、PHP-FPM 5 要求Vagrant 与 Virtual Box Ansible 获取 Centos 7 盒您可以创建干净 - 新鲜的 centos 7 基本框。...
nginx-php5 包括与主管一起运行的 nginx 和 php5 建造 $ sudo docker build -t yourname/nginx-php . 跑步 Nginx 将在 /var/www 中查找文件,因此您需要将您的应用程序映射到该目录。 sudo docker run -d -p ...
CentOS 6和7服务器安装和配置 请在执行任何脚本之前下载所有文件。 它们之间有几个依赖关系。 您可以使用: sudo yum install wget unzip -y wget https://github.com/simplyjarod/server/archive/master.zip unzip...
该存储库包含一些由docker-compose配置,用于启动LEMP (Linux, Nginx, MariaDB, PHP)堆栈。 细节 使用以下版本。 PHP 7.2(FPM)-可选MySQLi驱动程序(来自php.Dockerfile的注释行) Nginx 1.13.6 的MariaDB ...
##LEMPU 在 Userland 中安装 LEMP 或 LAMP(Nginx、MySQL、PHP)的脚本。 它不是防弹的,但它被设计为尽可能不引人注目和通用。 ###安装运行脚本并跟随助手: mkdir installLEMPU;cd installLEMPU; wget -q ...
厨师长厨房设置可与Nginx,MySQL和PHP配合使用的Ubuntu Server。要求Ubuntu 12.04用法要使用此厨房做饭,您必须遵循四个简单的步骤。1.准备本地工作副本git clone git://github....
正常安装本地 Bitnami NGINX 堆栈 在apps下创建一个wordpress目录 在新的wordpress目录下创建一个htdocs目录 在htdocs目录下解压你的 WordPress tar.gz 或 zip git clone这个 repo 到wordpress下的conf 编辑 .conf...
部署大麻堆栈LEMP(Linux,Nginx,MySQL,PHP或Python或Perl)
码头工人-Laravel 一个非常简化的Docker Compose工作流,它为本地Laravel开发设置了一个容器的LEMP(Linux,NGINX,MySQL,PHP)网络。港口项目中使用的端口: 软件港口Nginx的8080 phpmyadmin 8081 MySQL的3306 PHP...
其实Nginx的发音是Engine-X = E,LEMP包是由Linux、nginx、MariaDB/MySQL和PHP组成的,那么看来LEMP和LNMP是一样的,而现在业内习惯性的称作LEMP。MariaDB是一款社区支持驱动的MySQL数据库的分支,其功能更多性能更...
metowolf/docker-lemp yeszao/dnmp cnlh/nps DimitarPetrov/stegify tldr-pages/tldr flyzy2005/ss-fly ToyoDAdoubi/doubi import-yuefeng/ShadowsocksDocker SpaceVim/SpaceVim instantbox/instantbox facert/...
(Linux、Nginx/Tengine/OpenResty、生产环境下MySQL/MariaDB/Percona、PHP、JAVA),适用于CentOS 6 ~ 7(包括 redhat)、Debian 6 ~ 9、Ubuntu 12 ~ 18、Fedora 27~28 的 32 和 64。 脚本属性: 持续更新,提供...
vagrant-lemp, 使用 trusty64,php5,mysql和 Nginx 进行简单的Vagrant设置 vagrant简介这个项目自动设置电磁脉冲开发环境。要求CYGWIN 或者任何其他可以用于 vagrant ssh 命令的ssh终端 shell如何构建虚拟机构建...
Docker中的LEMP堆栈 从https://hub.docker.com/r/sumitk1/lemp/下载工作映像 或者 $ docker pull sumitk1/lemp 要从头开始构建图像- $ git clone https://github.com/sumitk1/docker-lemp.git $ cd docker-lemp ...