lnmp 安装


安装lnmp

MySQL安装
yum install make cmake bison-devel ncurses-devel git libaio library glibc zlib-devel pcre pcre-devel -y
1 libmcrypt-devel epel-release
2 yum install -y libmcrypt-devel epel-release zlib-devel pcre pcre-devel apr apr-devel libxml2-devel openssl openssl-devel bzip2 bzip2-devel libpng libpng-devel freetype freetype-devel  libcurl-devel  libjpeg-devel libtool-ltdl-devel
安装依赖包
解压
tar zxvf mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz
创建mysql用户
useradd -s /sbin/nologin mysql

进去mysql里面
cd /usr/local/mysql

创建目录和修改权限
mkdir -p /data/mysql ; chown -R mysql:mysql /data/mysql

免编译
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
或者
重要一步
./bin/mysqld --initialize --user=mysql --datadir=/data/mysql/

./bin/mysql_ssl_rsa_setup --datadir=/data/mysql
设置密码
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');
set password = password( yourpasswd );

复制配置文件
cp support-files/my-large.cnf /etc/my.cnf

复制启动文件
cp support-files/mysql.server /etc/init.d/mysqld

修改启动文件权限
chmod 755 /etc/init.d/mysqld

然后修改启动脚本的参数
vim /etc/init.d/mysqld “datadir=/data/mysql”

加载系统服务里面去
chkconfig --add mysqld

设置开机启动
chkconfig mysqld on

启动mysql
service mysqld start
配置文件里有log-bin=mysql-bin 这是mysql里面二进制的bin-log
如果打开的话他会在你更新数据查询数据读取数据的时候会记录相应的日志




cd /usr/local/src
tar zxvf php-5.3.27.tar.gz cd php-5.3.27
useradd -s /sbin/nologin php-fpm
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-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 --enable-zend-multibyte --disable-ipv6 --with-pear --with-curl --with-openssl

 


make && make install

--enable-fpm 用的工具就是它

cp php.ini-production /usr/local/php/etc/php.ini
vim /usr/local/php/etc/php-fpm.conf
 1 [global]
 2 pid = /usr/local/php/var/run/php-fpm.pid
 3 error_log = /usr/local/php/var/log/php-fpm.log
 4 [www]
 5 listen = 127.0.0.1:9000
 6 user = php-fpm
 7 group = php-fpm
 8 pm = dynamic
 9 pm.max_children = 50
10 pm.start_servers = 20
11 pm.min_spare_servers = 5
12 pm.max_spare_servers = 35
13 pm.max_requests = 500
14 rlimit_files = 1024
php-fpm.conf

/usr/local/php/sbin/php-fpm -t

cp /usr/local/src/php-5.3.27/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

chmod 755 /etc/init.d/php-fpm
service php-fpm start
chkconfig php-fpm on

nginx
cd /usr/local/src/
tar zxvf nginx-1.4.4.tar.gz
./configure \
--prefix=/usr/local/nginx \
--with-http_realip_module \
--with-http_sub_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-pcre 支持正则的
make && make install
vim /etc/init.d/nginx
 1 #!/bin/bash
 2 # chkconfig: - 30 21
 3 # description: http service.
 4 # Source Function Library
 5 . /etc/init.d/functions
 6 # Nginx Settings
 7 
 8 NGINX_SBIN="/usr/local/nginx/sbin/nginx"
 9 NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
10 NGINX_PID="/usr/local/nginx/logs/nginx.pid"
11 RETVAL=0
12 prog="Nginx"
13 
14 start() {
15         echo -n $"Starting $prog: "
16         mkdir -p /dev/shm/nginx_temp
17         daemon $NGINX_SBIN -c $NGINX_CONF
18         RETVAL=$?
19         echo
20         return $RETVAL
21 }
22 
23 stop() {
24         echo -n $"Stopping $prog: "
25         killproc -p $NGINX_PID $NGINX_SBIN -TERM
26         rm -rf /dev/shm/nginx_temp
27         RETVAL=$?
28         echo
29         return $RETVAL
30 }
31 
32 reload(){
33         echo -n $"Reloading $prog: "
34         killproc -p $NGINX_PID $NGINX_SBIN -HUP
35         RETVAL=$?
36         echo
37         return $RETVAL
38 }
39 
40 restart(){
41         stop
42         start
43 }
44 
45 configtest(){
46     $NGINX_SBIN -c $NGINX_CONF -t
47     return 0
48 }
49 
50 case "$1" in
51   start)
52         start
53         ;;
54   stop)
55         stop
56         ;;
57   reload)
58         reload
59         ;;
60   restart)
61         restart
62         ;;
63   configtest)
64         configtest
65         ;;
66   *)
67         echo $"Usage: $0 {start|stop|reload|restart|configtest}"
68         RETVAL=1
69 esac
70 
71 exit $RETVAL
启动脚本

 



chmod 755 /etc/init.d/nginx

chkconfig --add nginx
chkconfig nginx on
> /usr/local/nginx/conf/nginx.conf
vim /usr/local/nginx/conf/nginx.conf

 1 user nobody nobody;
 2 worker_processes 2;
 3 error_log /usr/local/nginx/logs/nginx_error.log crit;
 4 pid /usr/local/nginx/logs/nginx.pid;
 5 worker_rlimit_nofile 51200;
 6 
 7 events
 8 {
 9     use epoll;
10     worker_connections 6000;
11 }
12 
13 http
14 {
15     include mime.types;
16     default_type application/octet-stream;
17     server_names_hash_bucket_size 3526;
18     server_names_hash_max_size 4096;
19     log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'
20     '$host "$request_uri" $status'
21     '"$http_referer" "$http_user_agent"';
22     sendfile on;
23     tcp_nopush on;
24     keepalive_timeout 30;
25     client_header_timeout 3m;
26     client_body_timeout 3m;
27     send_timeout 3m;
28     connection_pool_size 256;
29     client_header_buffer_size 1k;
30     large_client_header_buffers 8 4k;
31     request_pool_size 4k;
32     output_buffers 4 32k;
33     postpone_output 1460;
34     client_max_body_size 10m;
35     client_body_buffer_size 256k;
36     client_body_temp_path /usr/local/nginx/client_body_temp;
37     proxy_temp_path /usr/local/nginx/proxy_temp;
38     fastcgi_temp_path /usr/local/nginx/fastcgi_temp;
39     fastcgi_intercept_errors on;
40     tcp_nodelay on;
41     gzip on;
42     gzip_min_length 1k;
43     gzip_buffers 4 8k;
44     gzip_comp_level 5;
45     gzip_http_version 1.1;
46     gzip_types text/plain application/x-javascript text/css text/htm application/xml;
47    include vhosts/*.conf;
48 
49 
50 }
配置文件

 


/usr/local/nginx/sbin/nginx -t
service nginx start

cd /usr/local/nginx/conf
mkdir vhosts

配置虚拟主机
vim default.conf
server
{
listen 80 default_server;
server_name localhost;
index index.html index.htm index.php;
root /tmp/123;
deny all
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/tmp/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
}

}


(标准配置
server
{
listen 80;
server_name 111.com;
index index.html index.htm index.php;
root /data/www;

location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/tmp/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
}

}
mkdir /tmp/123
/etc/init.d/nginx reload 重新加载配置文件


php-fpm 配置
vim /usr/local/php/etc/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] pool一个名字
listen = /tmp/php-fcgi.sock; 注意 用什么样的方式监听 tcp/ip
user = php-fpm
group = php-fpm
listen.mode = 0666
pm = dynamic 动态管理下面的东西
pm.max_children = 50 子进程最大有五十个
pm.start_servers = 20 一开始启动20个
pm.min_spare_servers = 5 当它空闲的时候最小是五个
pm.max_spare_servers = 35 最多不能多余35个
pm.max_requests = 500 一个子进程在他的生命周期内一共去处理多少个请求自动销毁
rlimit_files = 1024 每一个进程它所使用的文件描述符的一个限制可以调大点
slowlog = /tmp/www_slow.log 如果网站访问非常慢可以加上这条命令
request_slowlog_timeout = 1 这要这个脚本执行时间超过1秒就去记录slowlog
php_admin_value[open_basedir]=/data/www/:/tmp 针对不同的域名 针对不同的限制


[www1]
listen = /tmp/www1.sock 注意
user = php-fpm
group = php-fpm
listen.owner = nobody
listen.group = nobody
listen.mode = 0666
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
slowlog = /tmp/www1_slow.log
request_slowlog_timeout = 1
php_admin_value[open_basedir]=/data/www/:/tmp

vim /usr/local/nginx/conf/vhosts/111.conf
[www]
listen = /tmp/www.sock 注意
user = php-fpm
group = php-fpm
listen.mode = 0666
pm = dynamic


posted @ 2016-12-16 16:25  onlylc  阅读(89)  评论(0)    收藏  举报