12.1 Introduction to LNMP Architecture
Unlike LAMP, Nginx provides web services
And php exists as an independent service called php-fpm
Nginx processes static requests directly, and dynamic requests are forwarded to php-fpm
12.2 MYSQL installation
cd /usr/local/src
First delete the mysql directory downloaded before, and the startup script.
Temporarily keep the previously configured /etc/my.cnf
rm -rf /usr/local/mysql
rm -rf /etc/init.d/mysql
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
[root@localhost src]# cd /usr/local/mysql
[root@localhost mysql]# ls
bin COPYING data docs include lib man mysql-test README scripts share sql-bench support-files
[root@localhost mysql]# ls /data/
mariadb mysql wwwroot
[root@localhost mysql]# id mysql
uid=1006(mysql) gid=1009(mysql) 组=1009(mysql)
[root@localhost mysql]# rm -rf /data/mysql/*
useradd mysql
mkdir /data/
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
echo $? 查看一下
cp support-files/my-default.cnf /etc/my.cnf
vi /etc/my.cnf
定义datadir socket
cp support-files/mysql.server /etc/init.d/mysql
vi /etc/init.d/mysqld
定义basedir和datadir
basedir=/usr/local/mysql
datadir=/data/mysql
mv /etc/init.d/mysql /etc/init.d/mysqld //改名,mysqld 常用一点
/etc/init.d/mysqld start
ps aux |grep mysql
chkconfig --add mysqld //加入到服务列表
chkconfig mysqld on //开机启动 (此时就可以用service mysqld stop start)
12.3/12.4 PHP Installation
Using apxs in LAMP - APache eXtenSion tool
apxs is a tool for compiling and installing extension modules for the Apache HTTP server. It is used to compile one or more source or object code files into dynamic shared objects so that they can be loaded into the Apache server at runtime using the LoadModule directive provided by mod_so middle.
It is different from the LAMP installation method of PHP, you need to open the php-fpm service
cd /usr/local/src/
wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
tar zxf php-5.6.30.tar.gz
(Downloaded before, do not need to download and decompress for the time being)
cd php-5.6.30
make clean //Delete the previously compiled files (equivalent to the state just decompressed)
useradd -s /sbin/nologin php-fpm //Create an account to run the php-fpm service
./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
yum install -y libcurl-devel
make && make install
vim Makefile
make clean && make
make install
echo $? //Verify
/usr/local/php-fpm/sbin/php-fpm -m -i -t can be used
/usr/local/php-fpm/bin/php You can also check that the usage of the two is basically the same
(php.ini is the php configuration file
php-fpm.conf is the configuration file of the php-fpm service)
cp php.ini-production /usr/local/php-fpm/etc/php.ini
(production online, development production environment)
(cd /usr/local/php-fpm/etc/
vim php-fpm.conf)
vim /usr/local/php-fpm/etc/php-fpm.conf //Write the following
(Refer to https://coding.net/u/aminglinux/p/aminglinux-book/git/blob/master/D15Z/php-fpm.conf )
When listening is enabled, listen.mode = 666 will take effect, which is used to define sock file permissions
[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 php-fpm on
[root@localhost php-5.6.30]# service php-fpm start
Starting php-fpm done
ps aux |grep php-fpm
Introduction to Nginx
Nginx official website nginx.org , the latest version 1.13, the latest stable version 1.12
Nginx application scenarios: web services, reverse proxy, load balancing
The famous branch of Nginx, Tengine developed by Taobao based on Nginx, is consistent with Nginx in use, the service name and configuration file name are the same, the biggest difference from Nginx is that Tenging has added some customized modules, which are outstanding in terms of safe speed limit. Support for js, css merging
Nginx core + lua-related components and modules form a high-performance web container openresty that supports lua, refer to http://jinnianshilongnian.iteye.com/blog/2280928
expand
Why is Nginx more efficient than Apache Httpd: Principles http://www.toxingwang.com/linux-unix/linux-basic/1712.html
Comparison of working principles of apache and nginxhttp : //www.server110.com/nginx/201402/6543.html
Comparison of mod_php and mod_fastcgi and php-fpm http://dwz.cn/1lwMSd
Conceptual understanding: CGI, FastCGI, PHP-CGI and PHP-FPM http://www.nowamagic.net/librarys/veda/detail/1319/ https://www.awaimai.com/371.html