标签:pictures 压缩包 报错 starting dynamic gcc pdo library file
LNMP架构介绍LNMP = Linux + Ningx + Mysql + PHP
由Nginx取代apache,提供web服务;
PHP作为一个独立服务存在而非apache的一个模块,这个服务为php-fpm;
Nginx直接处理静态请求,动态请求会转发给php-fpm。
Nginx在处理静态文件的速率较Apache要快的多,这时两者的底层设计所决定的。同时Nginx可以处理的并发访问量也较Apache要大的多,毕竟Apache创建之初并没有考虑到当今的高并发访问量的规模会如此之大。Apache采用的是多进程的方式,对内存的要求会较高,而且有限制;Nginx采用多线程的方式,在内存消耗方面要比Apache好的多。
由于mysql的二进制源码包的安装较复杂,这里使用的是预编译版本的
[root@localhost src]# tar zxf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
[root@localhost src]# mv mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/mysql
2 创建用户及数据目录
[root@localhost src]# cd /usr/local/mysql/
[root@localhost mysql]# useradd -M -s /sbin/nologin mysql
[root@localhost mysql]# mkdir /data
3.安装依赖包
[root@localhost mysql]# yum install -y perl-Data-Dumper libaio-devel
4.初始化数据库
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
[root@localhost mysql]# cp support-files/my-default.cnf /etc/my.cnf
[root@localhost mysql]# vi /etc/my.cnf
"修改[mysqld]内的2行即可
basedir = /usr/local/mysql
datadir = /data/mysql
保存退出"
5.修改启动脚本
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# vi /etc/init.d/mysqld
"同样要修改一下参数
basedir=/usr/local/mysql
datadir=/data/mysql"
6.设置开机启动
[root@localhost mysql]# chmod 755 /etc/init.d/mysqld
[root@localhost mysql]# chkconfig --add mysqld
7.启动mysql,验证是否安装成功
[root@localhost mysql]# /etc/init.d/mysqld start
[root@localhost mysql]# ps aux | grep mysqld
[root@localhost src]# tar zxvf php-5.6.30.tar.gz
[root@localhost src]# cd php-5.6.30
[root@localhost src]# useradd -M -s /sbin/nologin php-fpm
[root@localhost php-5.6.30]# yum install -y epel-release
[root@localhost php-5.6.30]# yum install -y gcc gcc-c++ libxml2-devel openssl-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel
[root@localhost php-5.6.30]# ./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-openssl
[root@localhost php-5.6.30]# make && make install
php7版本已经取消--with-mysql参数,编译安装时该参数不写,写了会报错,但不影响安装
5.修改配置文件
[root@localhost php-5.6.30]# cp php.ini-production /usr/local/php-fpm/etc/php.ini
[root@localhost php-5.6.30]# cd /usr/local/php-fpm/etc
[root@localhost etc]# vi php-fpm.conf
[root@localhost etc]# cat php-fpm.conf
[global] # 定义全局参数
pid = /usr/local/php-fpm/var/run/php-fpm.pid
error_log = /usr/local/php-fpm/var/log/php-fpm.log
[www] # 模块名
listen = /tmp/php-fcgi.sock # 监听socket
#listen = 127.0.0.1:9000
listen.mode = 666 # 监听是socket才会生效
user = php-fpm # 定义用户
group = php-fpm # 定义组
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
6.设置启动脚本,并设置开机启动
启动脚本模板文件在/usr/local/src/php-5.6.30/sapi/fpm/init.d.php-fpm
[root@localhost etc]# cd /usr/local/src/php-5.6.30
[root@localhost php-5.6.30]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@localhost php-5.6.30]# chmod 755 /etc/init.d/php-fpm
[root@localhost php-5.6.30]# chkconfig --add php-fpm
[root@localhost php-5.6.30]# chkconfig --level 345 php-fpm on
7.启动php-fpm服务
[root@localhost php-5.6.30]# service php-fpm start
Starting php-fpm done
这里只写出了最基础的nginx源码安装方式,我们可以根据需要在后期加上需要的参数再次编译(例如支持HTTPS的http_ssl_module模块,再次编译时加上--with-http_ssl_module参数),需要注意的是再次安装时用户自定义的虚拟主机配置文件可能丢失,最好进行备份。
1.下载并解压
[root@localhost ~]# cd /usr/local/src
[root@localhost src]# wget http://nginx.org/download/nginx-1.12.2.tar.gz
[root@localhost src]# tar zxf nginx-1.12.2.tar.gz
2.编译、安装
[root@localhost src]# cd nginx-1.12.2
[root@localhost nginx-1.12.2]# ./configure --prefix=/usr/local/nginx
[root@localhost src]# make && make install
[root@localhost nginx-1.12.2]# vim /etc/init.d/nginx
#!/bin/bash
# chkconfig: - 30 21
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings
NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/logs/nginx.pid"
RETVAL=0
prog="Nginx"
start()
{
echo -n $"Starting $prog: "
mkdir -p /dev/shm/nginx_temp
daemon $NGINX_SBIN -c $NGINX_CONF
RETVAL=$?
echo
return $RETVAL
}
stop()
{
echo -n $"Stopping $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -TERM
rm -rf /dev/shm/nginx_temp
RETVAL=$?
echo
return $RETVAL
}
reload()
{
echo -n $"Reloading $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -HUP
RETVAL=$?
echo
return $RETVAL
}
restart()
{
stop
start
}
configtest()
{
$NGINX_SBIN -c $NGINX_CONF -t
return 0
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
configtest)
configtest
;;
*)
echo $"Usage: $0 {start|stop|reload|restart|configtest}"
RETVAL=1
esac
exit $RETVAL
4.更改配置文件权限并开机启动
[root@localhost nginx-1.12.2]# chmod 755 /etc/init.d/nginx
[root@localhost nginx-1.12.2]# chkconfig --add nginx
[root@localhost nginx-1.12.2]# chkconfig nginx on
如果无法直接使用nginx命令,则表示/etc/init.d不在PATH变量内,可以通过修改/etc/profile来添加;
标签:pictures 压缩包 报错 starting dynamic gcc pdo library file
原文地址:http://blog.51cto.com/castiel/2058829