CentOS 6.5安装配置LNMP服务器(Nginx+PHP+MySQL)
CentOS 6.5安装配置LNMP服务器(Nginx+PHP+MySQL)
一.准备篇:
/etc/init.d/iptables stop #关闭防火墙
关闭SELINUX
vi /etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
:wq
shutdown -r now #重启系统
二.安装篇
1.安装nginx
yum remove httpd* php* #删除系统自带的软件包
安装步骤:
因为nginx模块需要第三方库的支持,需要安装下列库.
安装gcc编译器及相关工具
#yum -y install gcc gcc-c++ autoconf automake make
安装相关依赖的模块
#yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
创建nginx系统账户:
由于nginx是系统服务,运行此服务需要系统账户。
# groupadd nginx
# useradd -r -g nginx -s /sbin/nologin -M nginx
软件源码包存放位置:/opt/
#cd /opt/
# tar -zxvf nginx-1.2.4.tar
#cd nginx-1.2.4
#./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module //通过编译源码的方式进行安装
#make
#make install
启动Nginx
#启动nginx
#/usr/local/nginx/sbin/nginx -t
显示以下信息为正确的 the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok configuration file /usr/local/nginx/conf/nginx.conf test is successful
#/usr/local/nginx/sbin/nginx
启动成功后,查看nginx进程信息: # ps -ef | grep nginx ,看是否存在nginx的进程来确认是否成功启动。
2.安装MySQL(也可以使用系统自带mysql)
1、安装MySQL
yum install mysql mysql-server #输入Y即可自动安装,直到安装完成
/etc/init.d/mysqld start #启动MySQL chkconfig mysqld on #设为开机启动 cp /usr/share/mysql/my-medium.cnf /etc/my.cnf #拷贝配置文件(注意:如果/etc目录下面默认有一个my.cnf,直接覆盖即可)
为root账户设置密码 mysql_secure_installation #回车,根据提示输入Y,输入2次密码,回车,根据提示一路输入Y,最后出现:Thanks for using MySQL! MySql密码设置完成,重新启动 MySQL: /etc/init.d/mysqld restart #重启 /etc/init.d/mysqld stop #停止 /etc/init.d/mysqld start #启动
3、安装PHP5
1、安装PHP5
yum install php php-fpm #根据提示输入Y直到安装完成 2、安装PHP组件,使 PHP5 支持 MySQL yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt #这里选择以上安装包进行安装,根据提示输入Y回车 chkconfig php-fpm on #设置php-fpm开机启动 /etc/init.d/php-fpm start #启动php-fpm
配置篇
一、配置nginx支持php
cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.confbak #备份原有配置文件
vim /usr/local/nginx/conf/nginx.conf
user www ; #修改nginx运行账号为:www用户
:wq #保存退出
vim /usr/local/nginx/conf/nginx.conf index index.php index.html index.htm; #增加index.php # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} #取消FastCGI server部分location的注释,并要注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径
service nginx restart #重启nginx
二、php配置
vi /etc/php.ini date.timezone = PRC #在946行 把前面的分号去掉,改为date.timezone = PRC disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,ope nlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdns rr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,
posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#在386行列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。
找到:date.timezone =
修改为:date.timezone = PRC #设置时区
找到:expose_php = On
修改为:expose_php = OFF #禁止显示php版本的信息
找到:short_open_tag = Off
修改为:short_open_tag = ON #支持php短标签
:wq! #保存退出
测试篇
cd /usr/local/nginx/html
vim index.php <?php echo phpinfo();
?> :wq! chown www.www /usr/local/nginx/html -R #设置权限
service nginx restart #重启nginx
service php-fpm restart #重启php-fpm
在客户端浏览器输入服务器IP地址,可以看到相关的配置信息!
说明lnmp配置成功!
至此,CnetOS
6.4安装配置LNMP(Nginx+PHP+MySQL)配置完成。
号外:
PHP启动脚本:对照自己的目录,直接放置在/etc/init.d/下给执行权限即可运行.
#! /bin/sh
#
# chkconfig: -
# description: PHP FastCGI Process Manager
# processname: php-fpm
# config: /etc/php-fpm.conf
# config: /etc/sysconfig/php-fpm
# pidfile: /var/run/php-fpm/php-fpm.pid
#
### BEGIN INIT INFO
# Provides: php-fpm
# Required-Start: $local_fs $remote_fs $network $named
# Required-Stop: $local_fs $remote_fs $network
# Short-Description: start and stop PHP FPM
# Description: PHP FastCGI Process Manager
### END INIT INFO # Standard LSB functions
#. /lib/lsb/init-functions # Source function library.
. /etc/init.d/functions # Check that networking is up.
. /etc/sysconfig/network # Additional environment file
if [ -f /etc/sysconfig/php-fpm ]; then
. /etc/sysconfig/php-fpm
fi if [ "$NETWORKING" = "no" ]
then
exit
fi RETVAL=
prog="php-fpm"
pidfile=${PIDFILE-/var/run/php-fpm/php-fpm.pid}
lockfile=${LOCKFILE-/var/lock/subsys/php-fpm} start () {
echo -n $"Starting $prog: "
dir=$(dirname ${pidfile})
[ -d $dir ] || mkdir $dir
daemon --pidfile ${pidfile} /usr/sbin/php-fpm --daemonize
RETVAL=$?
echo
[ $RETVAL -eq ] && touch ${lockfile}
}
stop () {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} php-fpm
RETVAL=$?
echo
if [ $RETVAL -eq ] ; then
rm -f ${lockfile} ${pidfile}
fi
} restart () {
stop
start
} reload () {
echo -n $"Reloading $prog: "
if ! /usr/sbin/php-fpm --test ; then
RETVAL=
echo $"not reloading due to configuration syntax error"
failure $"not reloading $prog due to configuration syntax error"
else
killproc -p ${pidfile} php-fpm -USR2
RETVAL=$?
fi
echo
} # See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} php-fpm
RETVAL=$?
;;
restart)
restart
;;
reload|force-reload)
reload
;;
configtest)
/usr/sbin/php-fpm --test
RETVAL=$?
;;
condrestart|try-restart)
[ -f ${lockfile} ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|try-restart|configtest}"
RETVAL=
;;
esac exit $RETVAL
PHP启动脚本
CentOS 6.5安装配置LNMP服务器(Nginx+PHP+MySQL)的更多相关文章
- CentOS 6.4安装配置LNMP服务器(Nginx+PHP+MySQL)
准备篇 1.配置防火墙,开启80端口.3306端口 vi /etc/sysconfig/iptables-A INPUT -m state --state NEW -m tcp -p tcp --dp ...
- CentOS 6.5 yum安装配置lnmp服务器(Nginx+PHP+MySQL)
以下全部转载于 http://blog.csdn.net/lane_l/article/details/20235909 本人于今晚按照该文章使用centos 6.7 64bit安装成功,做个备份, ...
- CentOS 6.6安装配置LAMP服务器(Apache+PHP5+MySQL)
准备篇: CentOS 6.6系统安装配置图解教程 http://www.osyunwei.com/archives/8398.html 1.配置防火墙,开启80端口.3306端口 vi /etc/s ...
- CentOS 6.4安装配置LAMP服务器(Apache+PHP5+MySQL)
这篇文章主要介绍了CentOS 6.4安装配置LAMP服务器(Apache+PHP5+MySQL)的方法,需要的朋友可以参考下 文章写的不错,很详细:IDO转载自网络: 准备篇: 1.配置防火墙,开启 ...
- CentOS 6.3安装配置LAMP服务器(Apache+PHP5+MySQL)
准备篇: 1.配置防火墙,开启80端口.3306端口 vi /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp -- ...
- CentOS 6.5安装配置LAMP服务器(Apache+PHP5+MySQL)的方法
CentOS 6.5安装配置LAMP服务器(Apache+PHP5+MySQL)的方法 准备篇: 1.配置防火墙,开启80端口.3306端口vi /etc/sysconfig/iptables-A I ...
- CentOS 5.11安装配置LAMP服务器(Apache+PHP5+MySQL)
http://www.osyunwei.com/archives/8880.html 准备篇: CentOS 5.x系统安装配置图解教程 http://www.osyunwei.com/archive ...
- CentOS 6.3安装配置LAMP服务器(Linux+Apache+MySQL+PHP5)
服务器系统环境:CentOS 6.3 客户端系统环境:Windows 7 ultimate(x86)sp1 简体中文旗舰版 ※ 本文档描述了如何在Linux服务器配置Apache.Mysql.PHP ...
- CentOS 6.4安装配置LNMP服务器(Nginx+PHP+MySQL)
一 安装篇 1. 安装nginx yum check-update #更新yum源 yum remove httpd* php* #删除系统自带的软件包 yum install nginx #安装ng ...
随机推荐
- 51nod 1163贪心
用优先队列来贪心,是一个很好地想法.优先队列在很多时候可以维护最值,同时可以考虑到一些其他情况. http://www.51nod.com/onlineJudge/questionCode.html# ...
- C#—类库、委托、is和as运算符、泛型集合
类库 类库(Class Library)是一个综合性的面向对象的可重用类型集合,这些类型包括:接口.抽象类和具体类.类库可以解决一系列常见编程任务(包括诸如字符串管理.数据收集.数据库连接以及文件访问 ...
- C# 不支持关键字: “.;database”。
解决方案分析:这个一定是链接字符串有问题,核对web.config 和程序的字符串是否有误
- ASP.NET MVC html help
public static class HtmlHelper { /// <summary> /// 返回没有边框的只读的TextBox标签 /// </summary> // ...
- 【BZOJ-2055】80人环游世界 上下界费用流 (无源无汇最小费用最大流)
2055: 80人环游世界 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 321 Solved: 201[Submit][Status][Discus ...
- bzoj3295: [Cqoi2011]动态逆序对(cdq分治)
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #i ...
- AutoIt3(AU3)开发的分辨率快速设置工具
项目相关地址 源码:https://github.com/easonjim/Resolution_Settings bug提交:https://github.com/easonjim/Resoluti ...
- ListView的使用-模拟微博随便看看栏目【执行与优化】
今天我们来讲述一下如何使用ListView来模仿微博随便看看栏目(ps:这是老师布置的作业,所以…),在前篇博客中,我们讲述了细解ListView之自定义适配器的使用,所以本篇我们不以特别详细的讲述( ...
- Deformity ASP/ASPX Webshell、Webshell Hidden Learning
catalog . Active Server Page(ASP) . ASP.NET . ASP WEBSHELL变形方式 . ASPX WEBSHELL变形方式 . webshell中常见的编码转 ...
- TrustedInstaller管理权限
TrustedInstaller.exe实际上是“Windows Modules Installer”这个服务的进程,路径位于C:\Windows\servicing\TrustedInstaller ...