博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LEMP
阅读量:7210 次
发布时间:2019-06-29

本文共 6762 字,大约阅读时间需要 22 分钟。

  hot3.png

在 CentOS 7 系统上:

$ sudo rpm --import http://nginx.org/keys/nginx_signing.key
$ sudo rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
$ sudo yum install nginx
$ sudo systemctl start nginx
$ sudo systemctl enable nginx
$ sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
$ sudo firewall-cmd --reload
#--sql
$ sudo yum install mariadb-server
$ sudo systemctl start mariadb
$ sudo systemctl enable mariadb
$ sudo mysql_secure_installation
#--php
$ sudo yum  install  php php-fpm php-mysql    php-curl php-mbstring  php-gd
$ sudo systemctl start php-fpm
$ sudo systemctl enable php-fpm
在 CentOS 6 系统上:
$ sudo rpm --import http://nginx.org/keys/nginx_signing.key
$ sudo rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
$ sudo yum install nginx
$ sudo service nginx start
$ sudo chkconfig nginx on
$ sudo iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
$ sudo service iptables save
#--mysql
$ sudo yum install mysql-server
$ sudo service mysqld start
$ sudo chkconfig mysqld on
#--mariadb
#cat /etc/yum.repos.d/mariadb.repo
# MariaDB 5.5 CentOS repository list - created 2014-03-04 11:20 UTC  
# http://mariadb.org/mariadb/repositories/  
[mariadb]  
name = MariaDB  
baseurl = http://yum.mariadb.org/5.5/centos6-amd64  
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB  
gpgcheck=1

#--php#默认会把apache当成依赖条件自动安装

$ sudo yum --enablerepo=remi install php php-fpm php-mysql  php-curl  php-mbstring  php-gd
$ sudo chkconfig php-fpm on
$ sudo service php-fpm start
在 CentOS 6 系统中,安装 REMI仓库中最新的 php-mysql 模块时,MySQL 的服务端包和客户端包会被当做一部分依赖包而自动的更新。
在 CentOS 6 和 CentOS 7 中,在安装 PHP 包的同时会把 Apache web 服务器(即 httpd)当做它的依赖包一起安装。这会跟 nginx web 服务器起冲突。这个问题会在下一节来讨论。
取决于您的使用情况,可以使用 yum 命令来定制您的 PHP 引擎,也许会想安装下面的任意一个扩展 PHP 模块包。
php-cli: PHP 的命令行界面。从命令行里测试 PHP 时非常有用。
php-gd: PHP 的图像处理支持。
php-bcmath: PHP 的数学支持。
php-mcrypt: PHP 的加密算法支持 (例如 DES、Blowfish、CBC、 CFB、ECB ciphers 等)。
php-xml: PHP 的 XML 解析和处理支持。
php-dba: PHP 的数据抽象层支持。
php-pecl-apc: PHP 加速器/缓存支持。
-------------------------------------------------------------------------------

#Ubuntu  安装nginx1.10.x

vi /etc/apt/sources.list ,添加以下两行

deb http://nginx.org/packages/ubuntu/ trusty nginx
deb-src http://nginx.org/packages/ubuntu/ trusty nginx

#

wget http://nginx.org/keys/nginx_signing.key

apt-key add nginx_signing.key

apt-get update

apt-get install nginx

#

#gpg --keyserver keyserver.ubuntu.com --recv-key ABF5BD827BD9BF62

#gpg -a --export ABF5BD827BD9BF62 | apt-key add -

#---------------------------------------------------------------------------

$ sudo vi /etc/nginx/conf.d/default.conf

server {
    listen       80  default;

    server_name _;    

    server_name www.example.com   blog.example.com 

    #rewrite ^.* permanent;

     return 500;  #禁止IP访问

    root   /usr/share/nginx/html;

    index  index.php index.html index.htm;
 
    location / {
    }
 
    # redirect server error pages to the static page /50x.html
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
    }
 
    # nginx passes PHP scripts to FastCGI server via a TCP/9000 socket
    # this setting much be consistent with /etc/php-fpm.d/www.conf
    # try_files prevents nginx from passing bad scripts to FastCGI server
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass 127.0.0.1:9000;
         #fastcgi_pass  unix:/var/run/php5-fpm.sock
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}
----------------------------------------------根据需要修改
vi /etc/php5/fpm/pool.d/www.conf
listen = /var/run/php5-fpm.sock
改成
listen =  127.0.0.1:9000

******************************************************************************

#apt-get  install  nginx 或 apache2

#apt-get install   mariadb-server  或 mysql-server

#apt-get install php5-fpm  php5-mysql   php5-cgi  php5-dev   php5-gd  php5-curl  php5-cli

apache2#apt-get install php5 libapache2-mod-php5  libapache2-mod-auth-mysql php5-mysql php5-gd  php5-curl  php5-dev

sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

1.nginx虚拟主机模板

vi    ./sites-enabled/t2

#---------------------------配置一-----------------------------------------server {        server_name www.t2.com;        listen 80;        root /data/www/t2;        index index.php index.html index.htm;        location / {                try_files $uri $uri/ =404;        }        location ~ \.php$ {        try_files $uri =404;        fastcgi_pass 127.0.0.1:9001;        #fastcgi_pass  unix:/var/run/php5-fpm.sock        fastcgi_index index.php;        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;        include fastcgi_params;        }        #location /RequestDenied {        #       proxy_pass http://127.0.0.1:8080;            #}        #error_page 404 /404.html;        #        #error_page 500 502 503 504 /50x.html;        #location = /50x.html {        #       root /usr/share/nginx/html;        #}}#---------------------------配置二------------------------------------------server { listen 80; server_name ~^(.+)?\.howtocn\.org$; index index.html; if ($host = test.com){ rewrite ^ http://www.test.com permanent; } root /data/wwwsite/test.com/$1/; } #实现一个server可以配置多个二级域名;#例如kkk.test.com会自动的匹配到/data/wwwsite/test.com/kkk/目录下

2.设置apache虚拟主机的配置模板:

#yum install httpd

添加/etc/httpd/conf/httpd.conf

 

LoadModule php5_module modules/libphp5.soAddType application/x-httpd-php .php .phtmlAddType application/x-httpd-php-source .phps#-----追加DirectoryIndex index.html index.html.var index.php

 

sudo vi sites-enabled/t2.conf

#sudo apt-get install php5 libapache2-mod-php5#sudo apt-get install libapache2-mod-auth-mysql#sudo apt-get install php5-mysql#sudo vi sites-enabled/t2.conf#注意创建apache虚拟主机的文件必须以.conf结尾,(nginx虚拟文件没有限制)
        ServerName www.t2.com        ServerAdmin webmaster@localhost        DocumentRoot /data/www/t2        DirectoryIndex index.php  #默认首页        #ErrorLog ${APACHE_LOG_DIR}/error.log        #CustomLog ${APACHE_LOG_DIR}/access.log combined        #网站根目录访问权限(apache2.4)        
        Options Indexes FollowSymLinks        AllowOverride None        Require all granted        

3.apache2的负载

   ServerName www.test.com   ProxyPass /  balancer://mytest    
      BalancerMember http://192.168.0.1:8081/ loadfactor=1 route=node1      BalancerMember http://192.168.0.2:8081/ loadfactor=1 route=node2      BalancerMember http://192.168.0.3:8081/ loadfactor=1 route=node3      BalancerMember http://192.168.0.4:8081/ loadfactor=1 route=node4      ProxySet lbmethod=byrequests   

4.windos php环境:

确认windos已安装:vcredist_86或vcredist_64下载的php版本(windos一般NTP非线程安全):http://php.net/downloads.php下载nginx版本(windos版本):http://nginx.org/en/download.html直接解压就OK,nginx+php和linux一样,运行fastcgis:c:/php/php-cgi.exe -b 127.0.0.1:9000 -c c:/php/php.inid:/nginx-1.9.0/nginx.exe

 

转载于:https://my.oschina.net/jk409/blog/350289

你可能感兴趣的文章
Entity Framework Core 1.1 升级通告
查看>>
MySQL:procedure, function, cursor,handler
查看>>
委托的多种写法
查看>>
关于优酷视频代码播放的若干事情……
查看>>
异步与并行~List<T>是线程安全的吗?
查看>>
CentOS7安装mysql提示“No package mysql-server available.”
查看>>
gulp同步执行任务
查看>>
(轉貼) C++,C#,Java功能比較 (.NET) (C#) (C/C++)
查看>>
Dockerfile详解(三)
查看>>
【转】启动 Eclipse 弹出“Failed to load the JNI shared library jvm.dll”错误的解决方法!...
查看>>
Bellman - Ford, SPFA 学习笔记(含有负权的单源最短路径)
查看>>
(转)关于NAND flash的MTD分区与uboot中分区的理解
查看>>
遍历文件Java中遍历出指定目录中的所有文件
查看>>
[MSP430] 对MSP430单片机__delay_cycles精确延时的说明及改正
查看>>
52. 模版和设计元素——Lotus Notes的代码重用
查看>>
如何成为一名Top DevOps Engineer
查看>>
xml转成数组,原来这么简单!
查看>>
linux下oracle11g R2的启动与关闭监听、数据库
查看>>
C# 元数据描述
查看>>
浅谈神经网络算法
查看>>