lnmp环境搭建,及memcached安装

7 篇文章 0 订阅
2 篇文章 0 订阅

Memcached的编译

linux下需要gcc,make,cmake,autoconf,libtool等工具

安装

Yum install gcc make cmake autoconf libtool

编译memcached

Memcached 编译安装需要libevent 

 

libevent官网下载,并编译安装

在下载的libevent目录下执行

./Configure --prefix=/usr/local/libevent

b编译后安装

Make && make install

安装libevent

进入memcached目录

编译安装

./configure --prefix=/usr/local/memcached --with-libevent=/usr/libevent/

Make &&make install

进入到memcached 进行启动

启动执行

./memcached -u nobody -m 64 -p 11211 & 

Php需要编译安装memcache扩展

Php7扩展下载地址

https://github.com/websupport-sk/pecl-memcache/archive/php7.zip

其他版本php下载地址

http://pecl.php.net/package/memcache

 

 

Lnmp环境安装

首先需要先下载nginx 和 

安装nginx需要pcre依赖库

下载地址注意下载8.36

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

解压

编译安装nginx

./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/src/pcre

 

启动nginx

如果出错,首先查看是不是安装了apache,

执行

Pkill -9 httpd //apache杀掉

还有一种情况

访问不了

可能是防火墙的原因

执行service iptables stop //关闭防火墙(启动用 service iptables start

编译php

编译php需要安装一些工具

 

Yum install gd zlib-devel openssl  openssl -devel libxml2 libxml2-devel libjpeg-devel libpng libpng-devel

 

工具安装好后进入php目录

执行

编译安装

 ./configure --prefix=/usr/local/php \
--with-gd \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--enable-mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-openssl \
--enable-mbstring \
--enable-fpm

安装好后

进入安装目录

Cp /usr/local/src/php/php.ini-development /usr/local/php/lib/php.ini

 

2.cp /usr/local/php/etc/php-fpm.conf.default  /usr/local/php/etc/php-fpm.conf

如果是php7还应该在做一个动作

Cp /usr/local/php/etc/php-fpm.d/www.conf.defult/ /usr/local/php/etc/php-fpm.d/www.conf

 

启动

./sbin/php-fpm


Mysql 安装

下载解压

直接移动到想安装的目录

Cd mysql

 

创建mysql 用户

Groupadd mysql

Useradd -g mysql mysql

 

Chown -R mysql ./

Chgrp -R mysql ./

Scripts/mysql_install_db --user=mysql

Chown -R root  ./

Chown -R mysql ./data

 

启动mysql

./bin/mysqld_salfe user=mysql &

如果出错查看日志

Cd /var/run/

Mkdir mysql

Chown mysql mysqld

Chown mysql mysqld

登录mysql 

./bin/mysql

如果出错

执行

Ps aux|grep mysql

查看sock文件地址

创建软连接

解决方法1.Ln /var/lib/mysql/mysql.sock /tmp/mysql.sock

解决方法二 ./bin/mysql -S /var/lib/mysql/mysql.sock

修改密码

 

Use mysql

Show tables;

有一个user

Select delete from user where host!=’localhost’

Delete from user where name !=root

Updata user set password=password(‘12121’)

 

Flush privileges //刷新表使密码生效

Php连接mysql问题可能是/var/lib/mysql/mysql.sock中的 mysql文件夹对其他人没有读取执

行权限需要设置把mysql目录价o+rx

Ps aux|grep php 查看php相关信息





ng和php的整合

#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   html/wx/public;

            try_files $uri $uri/ /index.php?$query_string;//开启伪静态

            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;

        #}

 

        #  the PHP scripts to FastCGI server listening on 127.0.0.1:9000

 

 

        location ~ \.php$ {

           root           html/wx/public;

            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;

    #    }

    #}

 

}

 


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值