源码搭建LNMP环境Word格式.docx
- 文档编号:20897073
- 上传时间:2023-01-26
- 格式:DOCX
- 页数:11
- 大小:18.05KB
源码搭建LNMP环境Word格式.docx
《源码搭建LNMP环境Word格式.docx》由会员分享,可在线阅读,更多相关《源码搭建LNMP环境Word格式.docx(11页珍藏版)》请在冰豆网上搜索。
index.htmlindex.htmindex.php;
}
#fastcgi整合nginx,php
location~\.php${
fastcgi_pass
127.0.0.1:
9000;
fastcgi_index
index.php;
fastcgi_param
SCRIPT_FILENAME
$document_root$fastcgi_script_name;
include
fastcgi_params;
手动编辑nginx开机自启动脚本,将nginx文件放到/etc/init.d/中
vi/etc/init.d/nginx
以下为nginx开机自启动脚本:
#!
/bin/sh
#
nginx
-
this
script
starts
and
stops
the
daemon
chkconfig:
85
15
description:
Nginx
is
an
HTTP(S)
server,
reverse
proxy
IMAP/POP3
server
processname:
2345
90
91
web
server
nginx
config:
/opt/nginx/conf/nginx.conf
pidfile:
/opt/nginx/nginx.pid
Source
function
library.
.
/etc/init.d/functions
networking
configuration.
/etc/sysconfig/network
if
[
-f
/etc/sysconfig/nginx
];
then
/etc/sysconfig/nginx
fi
Check
that
up.
"
$NETWORKING"
=
no"
]
exit
nginx="
/usr/local/nginx/sbin/nginx"
prog=$(basename
$nginx)
NGINX_CONF_FILE="
/usr/local/nginx/conf/nginx.conf"
lockfile=/var/lock/subsys/nginx
start()
{
-x
$nginx
||
5
$NGINX_CONF_FILE
6
echo
-n
$"
Starting
$prog:
#-c
retval=$?
$retval
-eq
0
touch
$lockfile
return
}
stop()
Stopping
killproc
$prog
-QUIT
rm
killall
-9
restart()
configtest
$?
stop
sleep
1
start
reload()
Reloading
-HUP
RETVAL=$?
force_reload()
restart
configtest()
-t
rh_status()
status
rh_status_q()
rh_status
>
/dev/null
2>
case
$1"
in
start)
rh_status_q
$1
;
stop)
restart)
test)
reload)
7
force-reload)
force_reload
status)
condrestart|try-restart)
*)
Usage:
$0
{start|stop|status|restart|condrestart|try-restart|reload|force-reload|test}"
2
esac
chmod+x/etc/init.d/nginx//赋予nginx文件执行权限
chkconfig--addnginx//将nginx加到服务列表中
chkconfignginxon//开机自启动nginx
Mysql安装操作步骤
groupaddmysql
usradd-gmysqlmysql
tar-zxvfmysql-5.1.62.tar.gz
cdmysql-5.1.62
./configure--prefix=/usr/local/mysql\
--sysconfdir=/etc\
--localstatedir=/var/lib/mysql\
--with-tcp-port=3306\
--with-unix-socket-path=/var/lib/mysql/mysqld.socket\
--with-mysqld-user=mysql\
--enable-assembler\
--with-charset=utf8\
--with-extra-charsets=all\
--enable-thread-safe-client\
--with-big-tables\
--with-readline\
--with-ssl\
--with-embedded-server\
--enable-local-infile\
--with-client-ldflags=-all-static\
--with-mysqld-ldflags=-all-static\
--with-debug\
--with-plugins=partition,innobase,myisammrg,myisam
cp/usr/local/mysql/share/mysql/mysql.server/etc/init.d/mysqld//复制自启动脚本
cp/usr/local/mysql/share/mysql/my-f/etc/f//复制配置文件
chmod755/etc/init.d/mysqld//赋予mysqld执行权限
chkconfig--addmysqld
chown-Rmysql/usr/local/mysql//修改文件权限
chgrp-Rmysql/usr/local/mysql//修改文件所属组
/usr/local/mysql/bin/mysql_install_db
--user=mysql//一定要先初始化数据库,否则mysql启动不了。
servicemysqldstart//启动mysql
ln-s/usr/local/mysql/bin/*/bin//创建mysql命令的软连接,可以在任何目录下执行mysql的命令
安装完成时Mysql无密码用户名为root
mysql-uroot//进入mysql数据库
SETPASSWORDFOR'
root'
@'
localhost'
=PASSWORD('
newpass'
);
//设置root用户密码其中newpass即为新设置的密码
grantallprivilegeson*.*to'
%'
identifiedby'
test123'
//设置数据库远程访问权限,允许root用户以任何IP登陆
vi/etc/sysconfig/iptables修改防火墙文件配置
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport3306-jACCEPT//将该代码加入iptables中22端口下面可防止开启防火墙后阻止远程访问
安装PHP步骤
tar–zxvfphp-5.6.9.tar.gz
cdphp-5.6.9
./configure--prefix=/usr/local/php\
--with-config-file-path=/etc\
--with-mysql=/usr/local/mysql\//如果使用的yum安装的mysql时不需要指定路径
--with-mysqli=/usr/local/mysql/bin/mysql_config\//如果使用的yum安装的mysql时不需要指定路径
--enable-sysvsem\
--enable-sysvshm\
--enable-pcntl\
--enable-mbregex\
--enable-zip\
--with-pcre-regex\
--with-libxml-dir\
--with-gd\
--with-jpeg-dir\
--with-png-dir\
--with-freetype-dir\
--with-iconv-dir\
--with-zlib-dir\
--enable-sockets\
--enable-soap\
--enable-gd-native-ttf\
--enable-ftp\
--enable-mbstring\
--enable-exif\
--disable-ipv6\
--disable-debug\
--enable-bcmath\
--with-gettext\
--enable-fpm
cp/usr/local/software/php-5.6.9/php.ini-development/etc/php.ini//将配置文件复制到etc目录
cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
ln-s/usr/local/php/bin/php/usr/bin/
手动编译PHP自启动文件,放入/etc/init.d目录下
vi/etc/init.d/php-fpm
一下为php的自启动脚本:
/bin/bash
php-fpm
startup
for
version:
5.5.0-alpha6
15
very
good
php-fpm
/var/run/php-fpm.pid
/usr/local/php/etc/php-fpm.conf
php_command=/usr/local/php/sbin/php-fom
php_config=/usr/local/php/etc/php-fpm.conf
php_pid=/usr/local/php/var/run/php-fpm.pid
RETVAL=0
prog="
php-fpm"
#start
function
php_fpm_start()
{
/usr/local/php/sbin/php-fpm
start(){
-e
$php_pid
]
already
start..."
1
php_fpm_start
stop(){
parent_pid=`cat
$php_pid`
all_pid=`ps
-ef
|
grep
awk
'
{if('
$parent_pid'
==
$3){print
$2}}'
`
pid
$all_pid
do
kill
$pid
done
$parent_pid
restart(){
stop
start
See
how
we
were
called.
in
start)
stop)
restart)
status)
$prog
*)
{start|stop|restart|status}"
$RETVAL
chmod+x/etc/init.d/php-fpm
chkconfig--addphp-fpm//将php-fpm加到服务列表中
chkconfigphp-fpmon//开机自启动php-fpm
/etc/init.d/php-fpmstart//启动php
/etc/init.d/nginxstart//启动nginx
vi/usr/local/nginx/html/index.php//创建一个php测试文件
<
?
Phpinfo();
vi/etc/php.ini//修改php配置文件中的short_open_tag=Off改成On
在任意路径下使用命令links127.0.0.1/index.php可以看到php的配置信息则环境搭建完成。
至此LNMP环境搭建完成,如果解析php文件提示找不到时请仔细检查nginx部分的nginx.conf文件配置是否配置正确或重启服务再试
本地可以访问,远程不能访问时请关闭防火墙。
serviceiptablesstop
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 源码 搭建 LNMP 环境
![提示](https://static.bdocx.com/images/bang_tan.gif)