Linux学习笔记十二周一次课(4月23日)
12.1 LNMP架构介绍
12.2 MySQL安装
进入下载目录cd /usr/local/src
查看已下载的文件ls
查看进程是否运行ps aux | grep mysql
删除安装目录rm -rf /usr/local/mysql
删除服务rm -rf /etc/init.d/mysqld
修改配置文件vim /etc/my.cnf //不修改,保留即可;
进入下载目录cd /usr/local/src
wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
tar zxvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/mysql
cd /usr/local/mysql
useradd mysql //添加用户,之前已添加过,可以查看#id mysql,清单掉#rm -rf /data/mysql/*;
mkdir /data/
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
cp support-files/my-default.cnf /etc/my.cnf //或者修改my.cnf文档,(datadir=/data/mysql,socket=/tmp/mysql.sock即可)
cp support-files/mysql.server /etc/init.d/mysqld
vim /etc/init.d/mysqld //定义basedir和datadir,(basedir=/usr/local/mysql,datadir=/data/mysql )
/etc/init.d/mysqld start
ps aux | grep mysql
chkconfig --add mysqld //添加到开机启动项
chkconfig mysqld on
service mysqld stop
service mysqld start
ps aux | grep mysql
12.3/12.4 PHP安装
cd /usr/local/src/
useradd -s /sbin/nologin php-fpm
cd php-5.6.30/
#make clean //之前编译过的文件删掉
./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 //少curl,安装yum install libcurl-devel -y,安装后再配置
make && make install
ls /usr/local/php-fpm/sbin/
/usr/local/php-fpm/sbin/php-fpm -m
/usr/local/php-fpm/sbin/php-fpm -i
/usr/local/php-fpm/sbin/php-fpm -t //测试php文件语法
cp php.ini-production /usr/local/php-fpm/etc/php.ini
vi /usr/local/php/etc/php-fpm.conf //写入如下内容(参考https://coding.net/u/aminglinux/p/aminglinux-book/git/blob/master/D15Z/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
listen.mode = 666
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
写入以上内容;
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm //启动脚本
chmod 755 /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
service php-fpm start
ps aux | grep php-fpm
12.5 Nginx介绍
扩展
Nginx为什么比Apache Httpd高效:原理篇 http://www.toxingwang.com/linux-unix/linux-basic/1712.html
apache和nginx工作原理比较 http://www.server110.com/nginx/201402/6543.html
mod_php 和 mod_fastcgi以及php-fpm的比较 http://dwz.cn/1lwMSd
概念了解:CGI,FastCGI,PHP-CGI与PHP-FPMhttp://www.nowamagic.net/librarys/veda/detail/1319/https://www.awaimai.com/371.html
转载于:https://blog.51cto.com/12059818/2107918