linux--->阿里云centos6.9环境配置安装lnmp
阿里云centos6.9环境配置安装lnmp
mysql安装
本人博客:http://www.cnblogs.com/frankltf/p/8615418.html
PHP安装
1、安装依赖关系
yum install libmcrypt libmcrypt-devel mcrypt mhash
在这个过程中遇到yum安装mcrypt错误:No package php-mcrypt available,解决方法如下:
yum install epel-release //扩展包更新包
yum update //更新yum源
yum install libmcrypt libmcrypt-devel mcrypt mhash2.下载并编译安装php
wget http://cn2.php.net/distributions/php-5.6.32.tar.gz
tar zxvf php-5.6.32.tar.gz
cd php-5.6.32
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts
3.在执行第二步的配置文件设置过程中可能会遇到很多报错,大部分原因是因为缺少相关依赖包造成的,只需要安装相应的依赖包即可继续。
- 比如:configure: error: png.h not found.;configure: error: freetype.h not found.等等
- 参考链接即可解决:https://www.cnblogs.com/sweetXiaoma/p/5855732.html
4.配置
修改fpm配置php-fpm.conf.default文件名称
mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
复制php.ini配置文件
cp php.ini-production /usr/local/php/etc/php.ini
复制php-fpm启动脚本到init.d
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
赋予执行权限
chmod +x /etc/init.d/php-fpm
添加为启动项
chkconfig --add php-fpm
设置开机启动
chkconfig php-fpm on
按照标准,给php-fpm创建一个指定的用户和组
创建群组
groupadd www
创建一个用户,不允许登陆和不创主目录
useradd -s /sbin/nologin -g www -M www
立即启动php-fpm
/etc/init.d/php-fpm start
ln -s /usr/local/php/bin/php /usr/bin/php
PHP安装完毕!
安装Nginx1.8.0
1.准备工作
添加用户与属组:
groupadd -r nginx
useradd -s /sbin/nologin -g nginx -M nginx
创建目录:
mkdir -pv /var/tmp/nginx/client/
下载:
wget http://nginx.org/download/nginx-1.8.0.tar.gz
解压安装包
tar zxvf nginx-1.8.0.tar.gz
cd nginx-1.8.02.编译安装
./configure
--prefix=/usr/local/nginx
--sbin-path=/usr/local/nginx/sbin/nginx
--conf-path=/usr/local/nginx/conf/nginx.conf
--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log
--pid-path=/var/run/nginx.pid
--lock-path=/var/lock/nginx.lock
--user=nginx
--group=nginx
--with-http_ssl_module
--with-http_flv_module
--with-http_stub_status_module
--with-http_gzip_static_module
--http-client-body-temp-path=/var/tmp/nginx/client/
--http-proxy-temp-path=/var/tmp/nginx/proxy/
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi
--http-scgi-temp-path=/var/tmp/nginx/scgi
--with-pcre
注意:若报错./configure: error: the HTTP rewrite module requires the PCRE library,执行:
yum -y install pcre-devel
这里要特别注意sbin、conf、pid、local的path要和后续的控制脚本保持一致!
make && make install3.为Nginx提供SysV init脚本
vim /etc/init.d/nginx
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /var/run/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf "
lockfile="/var/lock/nginx.lock"
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
类似的脚本网上很多,注意config、pid、sbin的路径保持和编译一致即可。
在这一步中遇到一个困扰了很久的错误,pid文件的丢失,尝试了网上很多方法都未解决,最终解决方法:将/etc/init.d/nginx文件中的# pidfile: /var/run/nginx/nginx.pid 改成 # pidfile: /var/run/nginx.pid ,因为每次终止nginx进程都会删除nginx.pid文件及其nginx文件夹,但是在重启时并不会在/var/run/下创建nginx文件夹,于是最简单的解决方案就是重新安装,并将pid路径改为 /var/run/nginx.pid。
- 4.配置
chmod +x /etc/init.d/nginx
chkconfig --add nginx
chkconfig nginx on
然后就可以启动服务了
systemctl restart nginx.service
或
/etc/init.d/nginx start
Nginx安装完毕 ,下面开始整合Nginx与PHP
整合Nginx与PHP
1、编辑Nginx.conf,启用如下选项:
cd /usr/local/nginx/conf/
vim nginx.conf
修改如下:
user nginx nginx;
location / {
root /home/www;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /home/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
重新载入配置
/etc/init.d/nginx reload
或者
service nginx restart
2、在设置的网站root目录下新建index.php测试页面
可通过浏览器 访问此测试页面,可验证nginx连接php配置成功。
注意:若是连接超时可能是防火墙阻隔了80端口,可使用上面mysql开放3306端口的方式开放80端口。
至此,CenOS下LNMP环境搭建完毕!
参考:http://blog.csdn.net/guwuhui123/article/details/69943295
linux--->阿里云centos6.9环境配置安装lnmp的更多相关文章
- 阿里云centos6.5实践编译安装LNMP架构web环境
LNMP 代表的就是:Linux系统下Nginx+MySQL+PHP这种网站服务器架构. 本次测试需求: **实践centos6.5编译安装 LNMP生产环境 架构 web生产环境 使用 ngx_pa ...
- 阿里云服务器Node环境配置
最近,将网站的阿里云服务器迁移到阿里云北京机房,记录下CentOS的迁移过程. 首次登录云服务器,要先进行用户设置. 用户设置 首先用passwd命令修改超级管理员root密码. $ passwd 根 ...
- 在阿里云的CentOS环境中安装django
购买了一台阿里云主机.操作系统为CentOS 6.5.准备在上面跑Django做Web开发.因为CentOS自带的python版本号较低,安装Django先要安装新版本号python.还是费了点周折. ...
- 阿里云三台CentOS7.2配置安装CDH5.12
1 购买3台阿里云服务 2 配置好ssh连接客户端 根据自己情况连接 3 安装好MySQL5.7 跳过,见之前博客 安装在hadoop001上 4 设置好Hosts文件 3台机器同时操作 vim /e ...
- 阿里云服务器centos7环境下安装xampp后,mysql有进程,但是却没有监听3306端口
配置阿里云服务器centos7中xampp环境时出现了一种情况: 在centos中可以使用命令进入mysql 修改后也可以远程用phpmyadmin连接mysql 但是用navicat却无法连接 先修 ...
- 在阿里云的CentOS环境中安装配置MySQL、JDK、Maven
Welcome to Alibaba Cloud Elastic Compute Service ! [root@izbp19stm1x1k2io1e7r3tz ~]# rpm -Uvh http:/ ...
- 阿里云主机Nginx下配置NodeJS、Express和Forever
https://cnodejs.org/topic/5059ce39fd37ea6b2f07e1a3 AngularJS中文社区即运行在阿里云主机上,本站使用Nginx引擎,为了AngularJS,我 ...
- 阿里云ECS服务器环境搭建——ubuntu16.04图形界面的安装
阿里云ECS服务器环境搭建——ubuntu16.04图形界面的安装 最近琢磨着想在服务器上搭建一个hexo博客,于是就在阿里云上买了一个云服务器ECS,远程接入后默认给的是一个命令窗口,没有图形界面, ...
- 阿里云CentOS6上配置iptables
参考:http://blog.abv.cn/?p=50 阿里云CentOS6默认没有启动iptables 1.检查iptables状态 [root@iZ94jj63a3sZ ~]# service i ...
随机推荐
- QP移植
以STM32平台为例,该单片机的ARM Cortex-M系列内核正是被QP长期支持,所以QP在ARM Cortex-M系列内核上已经有长时间的应用验证. 在配套书籍PSICC2中的例程为QP最原始的版 ...
- h5 页面 实现单选题,多选题功能。
效果图: 项目要求: 1:实现单选题和多选题区分 (这个根据后端传来的数据判断 ) 2 单选选中效果 和 多选选中效果(利用input 和label ) 3.答题成功与失败 分单选和多选的情况 ...
- Volatile是用于解决什么问题,谈谈实现原理
一.volatile的作用 通常情况下我们可以通过Synchronized关键字来解决这些个问题,不过如果对Synchronized原理有了解的话,应该知道Synchronized是一个比较重量级的操 ...
- apium环境搭建(mac)
appium 环境搭建 安装homebrew(Mac OSX上的软件包管理工具) $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubuse ...
- DOCKER学习_005:Flannel网络配置
一 简介 Flannel是一种基于overlay网络的跨主机容器网络解决方案,也就是将TCP数据包封装在另一种网络包里面进行路由转发和通信, Flannel是CoreOS开发,专门用于docker多机 ...
- $Poj1723/AcWing123\ Soldiers$ 排序
$Poj$ $AcWing$ $Description$ $Sol$ 分别处理$x$坐标和$y$坐标.$y$坐标显然很好处理,就是排个序然后取中位数就好了.$x$没有$y$那么直接叭.所以我首先写了个 ...
- 多vps管理面板
iis7远程桌面连接工具,又叫做iis7远程桌面管理软件,是一款绿色小巧,功能实用的远程桌面管理工具,其界面简洁,操作便捷,能够同时远程操作多台服务器,并且多台服务器间可以自由切换,适用 ...
- [白话解析] 深入浅出一致性Hash原理
[白话解析] 深入浅出一致性Hash原理 0x00 摘要 一致性哈希算法是分布式系统中常用的算法.但相信很多朋友都是知其然而不知其所以然.本文将尽量使用易懂的方式介绍一致性哈希原理,并且通过具体应用场 ...
- react项目使用antd
在开始实践之前要确保搭建React单页面开发环境,如果还没有搭建好开发环境的朋友请移步到如何搭建React单页面开发环境. 首先在命令行模式下创建一个React项目(项目名使用小写字母命名):(win ...
- 前端Tips#3 - 简写的 border-radius 100% 和 50% 是等效的
本文同步自 JSCON简时空 - 技术博客,点击阅读 视频讲解 视频地址 文字讲解 1.先讲结论 border-radius 这个 css 属性大家应该使用得非常娴熟,现实中用到的场景基本都是四个圆角 ...