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;
# }
#}
}