源码安装LNMP环境
新装CentOS 6.7,安装默认服务版本basic server
安装顺序linux(忽略...)--> Nginx--> Mariadb--> PHP
为了不影响测试效果,首先关闭selinux及iptables。校对系统时间。
iptables -F
chkconfig iptables off
vi /etc/selinux/config
将
SELINUX=enforcing
更改为
SELINUX=disabled
修改时区
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
安装rz上传组件:
yum install lrzsz -y
1、安装Nginx:
安装依赖,新建文件夹,rz上传nginx安装包。
mkdir packet
cd packet/
groupadd -r nginx
useradd -r -g nginx nginx
tar xf nginx-1.11.5.tar.gz
cd nginx-1.11.5
./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/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
make && make install
nginx="/usr/local/nginx/sbin/nginx" (configure参数中--sbin-path参数)
NGINX_CONF_FILE="/etc/nginx/nginx.conf"(nginx配置文件,configure参数中 --conf-path参数)
vi /etc/rc.d/init.d/nginx
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# 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="/etc/nginx/nginx.conf" [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx lockfile=/var/lock/subsys/nginx make_dirs() {
# make required directories
user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
options=`$nginx -V 2>&1 | grep 'configure arguments:'`
for opt in $options; do
if [ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d "=" -f 2`
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
} start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs
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
sleep 1
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
chmod +x /etc/rc.d/init.d/nginx
chkconfig --add nginx
chkconfig nginx on
service nginx start
mkdir -p /mydata/data
fdisk /dev/sdb
mkfs.ext4 /dev/sdb1
vi /etc/fstab
/dev/sdb1 /mydata/data ext4 defaults 0 0 挂载
mount -a
groupadd -r mysql
useradd -g mysql -r -s /sbin/nologin -M -d /mydata/data mysql
tar xf mariadb-10.1.18-linux-x86_64.tar.gz
ln -sv /root/packet/mariadb-10.1.18-linux-x86_64 /usr/local/mysql
cd /usr/local/mysql
chown -R mysql:mysql .
scripts/mysql_install_db --user=mysql --datadir=/mydata/data
chown -R root .
cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf
vi /etc/my.cnf
# Try number of CPU's*2 for thread_concurrency (CPU数量*2)
thread_concurrency = 2
datadir = /mydata/data
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
vi /etc/man.config
新增行
MANPATH /usr/local/mysql/man
mysql的头文件输出至系统的头文件
ln -sv /usr/local/mysql/include /usr/include/mysql
echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
ldconfig
vi /etc/profile
末尾新增行
PATH=/usr/local/mysql/bin:$PATH
export PATH
source /etc/profile
service mysqld start
yum -y groupinstall "X Software Development"
yum -y install libxml2 libxml2-devel bzip2-devel curl-devel libjpeg-devel libpng-devel freetype-devel
rz上传php,解压并编译安装
tar xf php-5.6.27.tar.bz2
cd php-5.6.27
./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath
make && make test && make install
cp packet/php-5.6.27/php.ini-production /etc/php.ini
cp packet/php-5.6.27/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
chmod +x /etc/rc.d/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
vi /usr/local/php/etc/php-fpm.conf
pm.max_children = 150
pm.start_servers = 8
pm.min_spare_servers = 5
pm.max_spare_servers = 10
pid = /usr/local/php/var/run/php-fpm.pid
service php-fpm start
vi /etc/nginx/nginx.conf
添加index.php
location / {
root html;
index index.html index.htm index.php;
} 启用php
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
vi /etc/nginx/fastcgi_params
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
service nginx reload
cd /usr/local/nginx/ html/
vi index.php
<?php
phpinfo();
?>
[root@localhost ~]# netstat -antp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 2201/php-fpm
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2715/nginx
tcp 0 0 127.0.0.1:34197 0.0.0.0:* LISTEN 2903/sshd
tcp 0 0 127.0.0.1:34198 0.0.0.0:* LISTEN 2903/sshd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2225/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 2020/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2585/master
tcp 0 0 172.28.1.8:10051 172.28.1.5:51231 TIME_WAIT -
tcp 0 52 172.28.1.8:22 172.28.1.5:51242 ESTABLISHED 2903/sshd
tcp 0 0 :::3306 :::* LISTEN 2444/mysqld
tcp 0 0 ::1:34197 :::* LISTEN 2903/sshd
tcp 0 0 ::1:34198 :::* LISTEN 2903/sshd
tcp 0 0 :::22 :::* LISTEN 2225/sshd
tcp 0 0 ::1:631 :::* LISTEN 2020/cupsd
tcp 0 0 ::1:25 :::* LISTEN 2585/master
[root@localhost ~]#


源码安装LNMP环境的更多相关文章
- ubuntu 源码安装 lnmp 环境
准备篇 下载软件包 1.下载nginx http://nginx.org/download/nginx-1.2.0.tar.gz 2.下载pcre (支持nginx伪静态) ftp://ftp.cs ...
- linux 手动源码安装lnmp(亲测)
linux 手动源码安装lnmp笔记(亲测)<pre>先安装这2个yum install gccyum install g++</pre><pre>先在linux ...
- CENTOS6.5源码安装LNMP
CENTOS6.5源码安装LNMP 一.安装前准备 ########################################################################## ...
- 在CENTOS上源码搭建LNMP环境
前言 1.操作前提: CentOS Linux release 7.5.1804: sudo用户(需要root权限): 2.需要安装的组件: nginx稳定版:nginx-1.14.0: MariaD ...
- 终于完成了 源码 编译lnmp环境
经过了大概一个星期的努力,终于按照海生的编译流程将lnmp环境源码安装出来了 nginx 和php 主要参考 http://hessian.cn/p/1273.html mysql 主要参考 http ...
- 源码安装LNMP与搭建Zabbix
系统环境:CentOS release 6.5 (Final) 搭建Zabbix 3.0对PHP环境要求>= 5.4 一.下载NMP的软件包: N:wget http://nginx.org/d ...
- 用源码搭建LNMP环境+部署WordPress
首先要做的是就是关闭Centos7.4的防火墙及selinux #systemctl stop firewalld #systemctl disable firewalld #sed -ri 's/^ ...
- CentOS 7 源码搭建LNMP环境
搭建 LNMP 环境 源码包版本 : CentOS Linux 7 nginx-1.15.1.tar.gz mysql-boost-5.7.21.tar.gz php-7.2.7.tar.gz ...
- CentOS 下源码安装LAMP环境
一.简介 什么是LAMP LAMP是一种Web网络应用和开发环境,是Linux, Apache, MySQL, Php/Perl的缩写,每一个字母代表了一个组件,每个组件就其本身而言都是在它所代 ...
随机推荐
- Python库的安装方法
Python库的安装方法 Python的解释器CPython是开源的,我们可以下载查看其源代码,同时,Python语言的各种库也都是开源的.利用Python语言编程,可用的库有很多,在Python官方 ...
- 一句话告诉你JQuery $(this)到底指的是什么,怎么用
看了网上好多关于jquery $(this)的解释,感觉都说的很模糊. 下面说出我自己的理解. this表示的是当前对象,下面以例子来说明 <!DOCTYPE html> <html ...
- Spring Boot 学习笔记
参考资料 http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/ Spring Boot简介 Spring Boot使 ...
- 如何在Linux实现自动运行程序
1.开机启动时 Linux加载后, 它将初始化硬件和设备驱动, 然后运行第一个进程init. init根据配置文件继续引导过程,启动其它进程.通常情况下,修改放置在 /etc/rc或 /etc/rc. ...
- Docker - 生成镜像
利用docker commit命令生成镜像 Docker镜像是多层存储,每一层是在前一层的基础上进行的修改.而容器是镜像为基础层的多层存储. 如果不使用数据卷,运行一个容器的时候,对任何文件的修改都会 ...
- 浏览器存储(cookie、localStorage、sessionStorage)
互联网早期浏览器是没有状态维护,这个就导致一个问题就是服务器不知道浏览器的状态,无法判断是否是同一个浏览器.这样用户登录.购物车功能都无法实现,Lou Montulli在1994年引入到web中最终纳 ...
- php学习之目录
一. 关于php中dirname(_file_)的使用 php中定义了一个很有用的常数,即 __file__ 这个内定常数是当前php程序的就是完整路径(路径+文件名). 即使这个文件被其他文件引用( ...
- POJ3252-Round Numbers 数学
题目链接:http://poj.org/problem?id=3252 题目大意: 输入两个十进制正整数a和b,求闭区间 [a ,b] 内有多少个Round number 所谓的Round Numbe ...
- ConcurrentHashMap实现原理及源码分析
ConcurrentHashMap实现原理 ConcurrentHashMap源码分析 总结 ConcurrentHashMap是Java并发包中提供的一个线程安全且高效的HashMap实现(若对Ha ...
- Maven学习-项目对象模型
POM包含了四类描述和配置: 项目总体信息:它包含了一个项目的名称,项目的URL,发起组织,以及项目的开发者贡献者列表和许可证. 构建设置:在这一部分,我们自定义Maven构建的默认行为.我们可以更改 ...