centos 6.5 安装lnmp(linux+nginx+mysql+php)
参考:http://www.cnblogs.com/AloneSword/archive/2013/03/18/2966750.html (总结并简要)
一安装cmake
wget -c http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz
tar zxvf cmake-2.8.5.tar.gz
cd cmake-2.8.5
.boostarp (有这个命令就执行,否则就跳过)
make
make install
cmake --version
二安装mysql
yum -y install gcc libxml2-dev curl screen \
libpng12-dev autoconf libpcre3-dev make bzip2 \
libevent-dev patch libjpeg62-dev libcurl4-openssl-dev \
libfreetype6-dev g++ libtool libncurses5-dev psmisc lrzsz \
openssl openssl-devel ncurses ncurses-devel
# 创建用户和组
groupadd mysql
useradd -g mysql -s /usr/sbin/nologin mysql
# 创建安装目录
mkdir /usr/local/ mysql
# 创建数据库目录
mkdir /usr/local/ mysql/data
# 解压
tar -zxvf mysql-5.5.17.tar.gz
cd mysql-5.5.17
# 编译及安装mysql
# cmake编译:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
PS: cmake的时候,参数可以不用那么多,只要一个-DCMAKE_INSTALL_PREFIX=/usr/local/mysql就行了,我们可以在 my.cnf里面配置。[mysqld]中的内容,看看你copy后的my.cnf有没有这些设置,有就不用了在设置了。
或
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_unicode_ci \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_DEBUG=0
# 安装mysql
make && make install
# 复制配置文件
cp support-files/my-medium.cnf /usr/local/mysql/my.cnf
或
cp support-files/my-medium.cnf /etc/my.cnf
# 设置权限
chmod +x /usr/local/mysql
chown -R mysql.mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/data
# 配置开机自启动
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfg mysqld on
# 修改my.cnf配置
vim /etc/my.cnf
# [mysqld] 添加:
datadir=/usr/local/mysql/data
default-storage-engine=MyISAM
# 以下可选:
log-error =/usr/local/mysql/data/error.log
pid-file = /usr/local/mysql/data/mysql.pid
user = mysql
tmpdir = /tmp
# 初始化数据库
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data &
# 启动MySQL
/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf &
或者:
/etc/init.d/mysql start (service mysql start)
# 测试MySQL是否启动
# 1)查看是否有进程mysql
ps -ef | grep mysql
# 2)查看端口是否运行
netstat -tnl | grep 3306
# 3)读取mysql版本信息
/usr/local/mysql/bin/mysqladmin version
初使密码
#> service mysqld stop
#>mysqld_safe --skip-grant-tables &
输入 mysql -uroot -p 回车进入
或
编辑my.cnf
在[mysqld] 配置部分添加一行
skip-grant-tables
>use mysql;
> update user set password=PASSWORD("newpass")where user="root";
更改密码为 newpassord
> flush privileges; 更新权限
> quit 退出
service mysqld restart
mysql -uroot -p新密码进入
或
//启动mysql server在后台运行
#./bin/mysqld_safe --user=mysql &
设置密码
# ./bin/mysqladmin -u root password 'passwd'
//进入mysql
# ./bin/mysql -u root -p
二安装php
参考:http://www.phperz.com/article/14/1207/39774.html
准备:
yum -y install gcc automake autoconf libtool make
./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt \
--enable-mbstring --disable-pdo --with-curl --disable-debug --disable-rpath \
--enable-inline-optimization --with-bz2 --with-zlib --enable-sockets \
--enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex \
--with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli \
--with-gd --with-jpeg-dir
cp php.ini.production /usr/local/php/etc
启动
/usr/local/php/sbin/php-fpm -t/usr/local/php/sbin/php-fpm -c /usr/local/php/etc/php.ini -y /usr/local/php/etc/php-fpm.conf -t报错:
configure: error: Please reinstall the BZip2 distribution
解决
yum -y install bzip2 bzip2-devel
报错:
configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/
解决
yum -y install libcurl licurl-devel
报错:
/usr/local/src/php-5.3.8/sapi/cli/php: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
make: *** [ext/phar/phar.php] Error 127
解决:
1.在/etc/ld.so.conf中加一行/usr/local/lib,
2.然后运行/sbin/ldconfig
还不行再加一个
find / -name "libmysqlclient.so.18"
echo "/usr/local/mysql/lib/" >> /etc/ld.so.conf
tail -1 /etc/ld.so.conf
ldconfig
这样就ok了它就能找到库文件了
添加环境变量
vim /etc/profile
export PATH="$PATH:/usr/local/php/sbin"
启动服务
/usr/local/php/sbin/php-fpm
报错:
三安装nginx
安装Nginx时报错
./configure: error: the HTTP rewrite module requires the PCRE library.
安装pcre-devel解决问题
yum -y install pcre-devel
加入环境变量
vim /etc/profile
export PATH="$PATH:/usr/local/nginx/sbin"
配置:
#vim /usr/local/nginx/conf/fastcgi_params
if ($fastcgi_script_name ~ "\..*\/.*\.php") {
return 404;
}
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;#脚本文件请求的路径
fastcgi_param QUERY_STRING $query_string; #请求的参数;如?app=
fastcgi_param REQUEST_METHOD $request_method; #请求的动作(GET,POST)
fastcgi_param CONTENT_TYPE $content_type; #请求头中的Content-Type字段
fastcgi_param CONTENT_LENGTH $content_length; #请求头中的Content-length字段。 fastcgi_param SCRIPT_NAME $fastcgi_script_name; #脚本名称
fastcgi_param REQUEST_URI $request_uri; #请求的地址不带参数
fastcgi_param DOCUMENT_URI $document_uri; #与$uri相同。
fastcgi_param DOCUMENT_ROOT $document_root; #网站的根目录。在server配置中root指令中指定的值
fastcgi_param SERVER_PROTOCOL $server_protocol; #请求使用的协议,通常是HTTP/.0或HTTP/1.1。 fastcgi_param GATEWAY_INTERFACE CGI/1.1;#cgi 版本
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;#nginx 版本号,可修改、隐藏 fastcgi_param REMOTE_ADDR $remote_addr; #客户端IP
fastcgi_param REMOTE_PORT $remote_port; #客户端端口
fastcgi_param SERVER_ADDR $server_addr; #服务器IP地址
fastcgi_param SERVER_PORT $server_port; #服务器端口
fastcgi_param SERVER_NAME $server_name; #服务器名,域名在server配置中指定的server_name #fastcgi_param PATH_INFO $path_info;#可自定义变量 # PHP only, required if PHP was built with --enable-force-cgi-redirect
#fastcgi_param REDIRECT_STATUS ; 在php可打印出上面的服务环境变量
如:echo $_SERVER['REMOTE_ADDR']
参考:http://www.cnblogs.com/rnckty/p/4832213.html
http://blog.hackroad.com/operations-engineer/linux_server/1453.html
centos 6.5 安装lnmp(linux+nginx+mysql+php)的更多相关文章
- centos7安装Lnmp(Linux+Nginx+MySql+Php+phpMyAdmin+Apache)
centos7安装Lnmp(Linux+Nginx+MySql+Php)及Apache Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx是一个高性能的HTTP和反向代理服务器,Ng ...
- centos6服务器YUM安装LNMP(LINUX+NGINX+MYSQL+PHP)
之前都用的lamp,这次配置一个lnmp来看看,试试Nginx是不是好用 关闭SELINUXvi /etc/selinux/config#SELINUX=enforcing #注释掉#SELINUXT ...
- 安装lnmp(linux nginx mysql php)
下载或者在云盘里找lnmp1.2-full.tar.gz 用 tar -zxvf lnmp1.2-full.tar.gz解压 进入 ,运行./install.sh安装.根据提示. 如果出现yum锁定, ...
- 阿里云Linux CentOS8.1 64位服务器安装LNMP(Linux+Nginx+MySQL+PHP)
LNMP环境和软件版本: 名称 版本号 查询命令 Linux系统 CentOS Linux release 8.1.1911 (Core) cat /etc/redhat-release Nginx ...
- LNMP(linux+nginx+mysql+php)服务器环境配置【转载】
本文转载自 园友David_Tang的博客,如有侵权请联系本人及时删除,原文地址: http://www.cnblogs.com/mchina/archive/2012/05/17/2507102.h ...
- LNMP(linux+nginx+mysql+php)服务器环境配置
一.简介 Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx,它的发音为 “engine X”, 是一个高性能的HTTP和反向代理服务器,同时也是一个IMAP/POP3/SMTP 代理服 ...
- 阿里云Linux CentOS8.1 64位服务器安装LNMP(Linux+Nginx+MySQL+PHP) 并发调试之Nginx配置
搭建好LNMP环境之后,接着要考虑的就是整个系统的并发能力了. 一.Nginx的配置 Nginx有很好的并发能力.但是要想使它的并发能力能够施展出来,需要在初步安装好的Nginx上做一些配置.主要需要 ...
- centos 7 搭建 LNMP ( Linux+Nginx+MySQL+PHP )
操作系统 | CentOS Linux release 7.6.1810 (Core) [root@localhost ~# cat /etc/redhat-release CentOS Linux ...
- LNMP(Linux+Nginx+MySQL+PHP)centos6.4安装
nginx命令 停止nginx服务:# /etc/init.d/nginx stop 启动nginx服务:# /etc/init.d/nginx start 编辑nginx配置文件:# vim /et ...
随机推荐
- flash 定义主舞台窗口大小
1:[SWF(width=100 height=100)] 写在主类上面2:设置stageScaleMode属性为false;
- SRM 451 DIV 1 总结
250p:这次是有史以来做的最快的一次250p...看题花了两分钟,敲代码最多一分钟...太明显了题意~ 500p:这题水了...每次都这样...很显然用DP来做,不过前面状态表示有问题了...搞了好 ...
- discuz问题综合
1.discuz x2搬家问题:搬家后,需要修改数据库的配置文件,包含: 主要的配置文件有三个:config目录下的config_global.php和config_ucenter.php以 ...
- Android中string.xml文件中设置部分字体颜色大小
1.在string.xml文件中: <string name="tips_all"><Data><![CDATA[清理进程:<font colo ...
- Linq 学习
聚合操作符 说 ...
- [Jobdu] 题目1497:面积最大的全1子矩阵
题目描述: 在一个M * N的矩阵中,所有的元素只有0和1,从这个矩阵中找出一个面积最大的全1子矩阵,所谓最大是指元素1的个数最多. 输入: 输入可能包含多个测试样例.对于每个测试案例,输入的第一行是 ...
- 如何用C#语言构造蜘蛛程序
"蜘蛛"(Spider)是Internet上一种很有用的程序,搜索引擎利用蜘蛛程序将Web页面收集到数据库,企业利用蜘蛛程序监视竞争对手的网站并跟踪变动,个人用户用蜘蛛程序下载We ...
- 车牌识别--S5PV210測试
cortex-A8(S5PV210) Linux-3.9.7 arm-linux-gcc 4.5.1(FriendlyARM) 根文件系统:NFS 软浮点执行结果: [liujia@210]#./so ...
- 分布式存储系统sheepdog
Sheepdog,是由NTT的3名日本研究员开发的开源项目,主要用来为虚拟机提供块设备. 其架构例如以下: 以下,我们将从架构.模块等几个方面来介绍下: 一.架构图 如上图: 採用无中心节点的全对称架 ...
- 开机就提示“请安装TCP/IP协议,error=10106”的解决的方法
一.问题描写叙述: 今天开机时提示"请安装TCP/IP协议,error=10106",现象是popo,qq等登录不了,IE浏览器等连不了网,使用ping命令ping其它机器和路由器 ...