资讯专栏INFORMATION COLUMN

LAMP+LNMP安装注意问题及安装

BlackHole1 / 1828人阅读

摘要:一安装注意事项必须先安装再安装支持需要生成文件,需要编译时添加该语句配置文件修改注意事项修改为允许修改为设置默认首页文件,增加添加增加同时连接数设置工作目录说明搜索修改为搜索修改为设置默认文档索修改为增加类型在后面添加修改配置文

一、LAMP安装注意事项

必须先安装apache再安装 php,apache支持php需要生成libphp5.so 文件,需要编译时添加该语句 --with-apxs2=/usr/local/apache/bin/apxs

apache配置文件修改注意事项
2.1. AllowOverride None  #修改为:AllowOverride All (允许.htaccess)
2.2.DirectoryIndex index.html #修改为:DirectoryIndex index.html index.htm Default.html Default.htm index.php(设置默认首页文件,增加index.php)
2.3.MaxKeepAliveRequests 500 #添加MaxKeepAliveRequests 500 (增加同时连接数)
2.4.设置工作目录 #说明: 搜索DocumentRoot, 修改为 DocumentRoot "/var/www/html" 搜索, 修改为 "/var/www/html">
2.5. 设置默认文档 : 索, 修改为 DirectoryIndex index.html index.php
2.6.增加php类型 AddType application/x-gzip .gz .tgz在后面添加 AddType application/x-httpd-php .html .php
2.6.#修改配置文件 vi /etc/httpd/httpd.conf
#查找ServerName,将注释去掉 ServerName www.example.com:80 www.example.com->需要改的ip
2.7.#添加到自启动
echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.sysinit #将apache添加到系统服务中
cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
vi /etc/rc.d/init.d/httpd
#在#!/bin/sh后添加下面两行(包含"#")
# chkconfig:2345 85 15
# description:Apache
#添加执行权限 chmod 755 /etc/init.d/httpd
#添加到系统服务中 chkconfig --add httpd
#开启apache service httpd start

*注:设置SELinux为permissive模式 命令行下 setenforce 0 立即生效,重启失效 修改配置文件后, 重启apache才能生效

二、LNMP安装
必须开启 --enbale-fpm

groupadd www
useradd -s /sbin/nologin -g www www

./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_spdy_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module  

make && make install
   软连接
ln -sf /usr/local/nginx/sbin/nginx /usr/bin/nginx

修改配置文件支持php
可把 root 改为想要的目录
打开一下 #

#location ~ .php$ {
#            root           /home/wwwroot/;
#            fastcgi_pass   127.0.0.1:9000;
#            fastcgi_index  index.php;
#            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
#            include        fastcgi_params;
#        }

like this:


 location ~ .php$ {
            root           /home/wwwroot/;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

也可以把给段配置改为改
*$document_root指 定义的根目录

location ~.php{
fastcgi_pass unix:/tmp/php-fcgi.sock; //下面解释
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi.conf;
}

*fastcgi_pass 里的 127.0.0.1:9000; 可改为unix:/tmp/php-fcgi.sock;
需要更改 php-fpm.conf 需要添加
group=www
user=www
listen=/tmp/php-fcgi.sock
listen.owner= www
listen.group =www

还要建立 /tmp/php-fcgi.sock; touch /tmp/php-fcgi.sock

chown www:www /tmp/php-fcgi.sock 赋予其权限

nginx -s reload

php-fpm 重启

配置文件 :


server{

listen 8080;
server_name 192.168.139.134:8080;
index  index.html index.htm index.php;
root   /home/wwwroot/demo;

location ~.php{

fastcgi_pass unix:/tmp/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi.conf;

}

}

location ~ .*.(gif|jpg|jpeg|png|bmp|swf|mp4)$
        {
            expires    30d;

        }

        location ~ .*.(js|css)?$
        {
            expires    12h;
        }

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

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /home/wwwroot/;
            index  index.html index.htm index.php;
   }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ .php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ .php$ {
            root           /home/wwwroot/;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache"s document root
        # concurs with nginx"s one
        #
        #location ~ /.ht {
        #    deny  all;
        #}
    }

    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
 #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

include vhost/*.conf;
}

//nginx 负载均衡 反相代理

upstream redis { //redis自定义的 和下面 proxy_pass http://redis;名称对应
    server 192.168.244.129:8080;
     server 192.168.244.109:8080;
     #ip_hash;//
}
server {
    listen      8787; //主机端口
    server_name 192.168.0.123:8787; 主机端口 ip
    location / {
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_pass http://redis;

    }

location ~ .*.(gif|jpg|jpeg|png|bmp|swf|mp4)$
        {
            expires    30d;

        }

        location ~ .*.(js|css)?$
        {
            expires    12h;
        }

}

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/40138.html

相关文章

  • 一键安装LNMPLAMP Web环境实现Linux服务器部署 PHP MySQL Nginx/Ap

    摘要:目前,我们看到的老蒋采用的部署的环境,在镜像中配置,于是我们会称作为。有没有一件傻瓜式安装工具脚本呢这里老蒋要推荐的来自国内比较老牌且一直更新维护的一键安装包,我们可以较为直观且无人值守的安装需要的网站服务器环境。如今我们建站较多的还是会选择VPS云服务器,很少会去选择虚拟主机,固然前者有很多的优点。不过相比虚拟主机不同的是,VPS云服务器需要我们自己配置WEB环境,而且我们较多的还是会选择...

    IntMain 评论0 收藏0
  • LAMP+LNMP安装注意问题安装

    摘要:一安装注意事项必须先安装再安装支持需要生成文件,需要编译时添加该语句配置文件修改注意事项修改为允许修改为设置默认首页文件,增加添加增加同时连接数设置工作目录说明搜索修改为搜索修改为设置默认文档索修改为增加类型在后面添加修改配置文 一、LAMP安装注意事项 必须先安装apache再安装 php,apache支持php需要生成libphp5.so 文件,需要编译时添加该语句 --with...

    linkin 评论0 收藏0
  • 详细整理5款较为常用的Linux VPS服务器WEB一键安装工具

    摘要:第一个人记忆中这款工具至今估计有十年左右时间当初也是个人站长为方便自己使用环境配置开发的。第二一键脚本也是由于个人站长提供的,经过几年的改善目前也是比较完善。 早年我们如果在Linux服务器配置网站环境的时候一般如何操作的?安装cPanel面板?这个是要花钱的,记忆中好像每个月需要十多美元,对于普通的个人站长用户来说确实是不小的费用。即便我们用破解版也不行,因为这个牵扯到安全问题。那我...

    techstay 评论0 收藏0
  • LAMP Web一键安装脚本 – Linux服务器安装Apache/MySQL/PHP网站环境

    摘要:前面老蒋有在网站中分享到一键安装包在服务器中部署网站运行环境,且我也有在文章中有提到那脚本也是支持安装的。今天老蒋要介绍的这个脚本是只能安装一键安装脚本,相比上面的这个脚本更为轻便一些,没有附带太多的内置软件。前面老蒋有在网站中分享到LNMP一键安装包在Linux服务器中部署PHP+MySQL+Nginx 网站运行环境,且我也有在文章中有提到那脚本也是支持安装LAMP的。今天老蒋要介绍的这个...

    starsfun 评论0 收藏0
  • docker的简介-安装-pull-push-Dockfile

    摘要:安装还是在上,上建议别折腾。也就是说本地是空的。是否截断显示中间层镜像只是显示仓库一系列镜像的集合。的后台搜索然后直接上传镜像,会展开说。在本地构件一个新的镜像保存对容器修改,并再次使用。然后我们安装上了。 1.1docker概要 一个容器就是宿主机的一个进程。对,就是个进程。原理方面不大懂,但是看更多linux 进程 文件管理 网络 等方面应该会加深理解。namespace+cgro...

    why_rookie 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<