L===Linux
N====Nginx
M====MysSQL
P====php
安装包
mysql-boost | https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.27.tar.gz |
---|---|
php7.2 | https://www.php.net/distributions/php-7.2.21.tar.bz2 |
nginx1.16 | http://nginx.org/download/nginx-1.16.0.tar.gz |
解压文件
[root@server ~]# tar -jxf php-7.2.21.tar.bz2 -C /usr/local/src/
[root@server ~]# tar -zxf mysql-boost-5.7.27.tar.gz -C /usr/local/src/
[root@server ~]# tar -zxf nginx-1.16.0.tar.gz -C /usr/local/src/
[root@server ~]# ll /usr/local/src/
总用量 8
drwxr-xr-x 35 7161 31415 4096 6月 10 22:51 mysql-5.7.27
drwxr-xr-x 8 1001 2.sh 147 4月 23 21:13 nginx-1.16.0
drwxrwxr-x 14 root root 4096 7月 30 17:21 php-7.2.21
源码编译安装配置nginx
[root@server ~]# cd /usr/local/src/nginx-1.16.0/
[root@server nginx-1.16.0]# ls
auto CHANGES.ru configure html man src
CHANGES conf contrib LICENSE README
[root@server nginx-1.16.0]# useradd -s /sbin/nologin nginx
[root@server nginx-1.16.0]# mkdir /server
[root@server nginx-1.16.0]# ./configure --prefix=/server/nginx-1.16 \
> --with-http_dav_module \
> --with-http_stub_status_module \
> --with-http_addition_module \
> --with-http_sub_module \
> --with-http_flv_module \
> --with-http_mp4_module \
> --user=nginx \
> --group=nginx
[root@server nginx-1.16.0]# echo $?
0
[root@server nginx-1.16.0]# make && make install
[root@server nginx-1.16.0]# cd /server/nginx-1.16/conf/
[root@server conf]# ls
fastcgi.conf koi-win scgi_params
fastcgi.conf.default mime.types scgi_params.default
fastcgi_params mime.types.default uwsgi_params
fastcgi_params.default nginx.conf uwsgi_params.default
koi-utf nginx.conf.default win-utf
配置用户,默认nobody
[root@server conf]# vim nginx.conf
#user nobody;
user nginx nginx;
#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;
#}
/scripts 改为nginx html根目录
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /server/nginx-1.16/html$fastcgi_script_name;
include fastcgi_params;
}
#测试语法
[root@server conf]# ../sbin/nginx -t
nginx: the configuration file /server/nginx-1.16/conf/nginx.conf syntax is ok
nginx: configuration file /server/nginx-1.16/conf/nginx.conf test is successful
[root@server conf]# ../sbin/nginx
[root@server conf]# ../sbin/nginx -s reload #重载配置文件
[root@server conf]# ps aux | grep nginx
root 28446 0.0 0.0 20608 660 ? Ss 19:04 0:00 nginx: master process ../sbin/nginx
nginx 28447 0.0 0.0 20984 1376 ? S 19:04 0:00 nginx: worker process
root 28485 0.0 0.0 112728 980 pts/2 R+ 19:05 0:00 grep --color=auto nginx
curl IP 进行测试
[root@server conf]# curl 192.168.220.138
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
每次启动都会加载rc.local的内容,可以通过这种方式设置开机自启
[root@server conf]# echo '/server/nginx-1.16/sbin/nginx &' >> /etc/rc.local
源码编译安装配置mysql
[root@server ~]# cd /usr/local/src/mysql-5.7.27/
[root@server mysql-5.7.27]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
> -DMYSQL_DATADIR=/usr/local/mysql/data \
> -DDOWNLOAD_BOOST=1 \
> -DWITH_BOOST=/usr/local/src/mysql-5.7.27/boost/boost_1_59_0 \
> -DWITH_MYISAM_STORAGE_ENGINE=1 \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_MEMORY_STORAGE_ENGINE=1 \
> -DWITH_READLINE=1 \
> -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
> -DMYSQL_TCP_PORT=3306 \
> -DENABLED_LOCAL_INFILE=1 \
> -DENABLE_DTRACE=0 \
> -DEXTRA_CHARSETS=all \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci \
> -DMYSQL_USER=mysql
## 若中间编译失败,需先删除CMakeCache.txt再重新编译
[root@server mysql-5.7.27]# make && make install
[root@server mysql-5.7.27]# useradd -s /sbin/nologin mysql
[root@server mysql-5.7.27]# chown -R mysql:mysql /usr/local/mysql/
修改基本配置
[mysqld]
2 basedir=/usr/local/mysql
3 datadir=/usr/local/mysql/data
4 port=3306
5 socket=/usr/local/mysql/mysql.sock
6 character-set-server=utf8
7 pid-file=/usr/local/mysql/mysqld.pid
8 log-error=/var/log/mysqld.log
[root@server mysql-5.7.27]# mkdir /usr/local/mysql/data
[root@server mysql-5.7.27]# vim /etc/init.d/mysqld
46 basedir=/usr/local/mysql/
47 datadir=/usr/local/mysql/data/
[root@server mysql-5.7.27]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
#初始化数据库
[root@server mysql-5.7.27]# /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/dat
[root@server mysql-5.7.27]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!
[root@server bin]# echo 'PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile
[root@server bin]# source /etc/profile
[root@server bin]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.27 Source distribution
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
源码编译安装配置php
[root@server bin]# cd /usr/local/src/php-7.2.21/
可以查看参数说明
[root@server php-7.2.21]# ./configure --help
root@server php-7.2.21]# ./configure --prefix=/usr/local/php \
> -with-config-file-path=/usr/local/php/etc \
> --with-mysqli \
> --with-pdo-mysql \
> --with-mysql-sock=/usr/local/mysql/mysql.sock \
> --with-iconv-dir \
> --with-freetype-dir \
> --with-jpeg-dir \
> --with-png-dir \
> --with-curl \
> --with-gd \
> --with-gmp \
> --with-zlib \
> --with-xmlrpc \
> --with-openssl \
> --without-pear \
> --with-snmp \
> --with-gettext \
> --with-mhash \
> --with-libxml-dir=/usr \
> --with-fpm-user=nginx \
> --with-fpm-group=nginx \
> --enable-xml \
> --enable-fpm \
> --enable-ftp \
> --enable-bcmath \
> --enable-soap \
> --enable-shmop \
> --enable-sysvsem \
> --enable-sockets \
> --enable-inline-optimization \
> --enable-maintainer-zts \
> --enable-mbregex \
> --enable-mbstring \
> --enable-pcntl \
> --enable-zip \
> --disable-fileinfo \
> --disable-rpath \
> --enable-libxml \
> --enable-opcache
Generating files
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+
Thank you for using PHP.
[root@server php-7.2.21]# make && make install
[root@server php-7.2.21]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.conf
[root@server php-7.2.21]# cp /usr/local/src/php-7.2.21/php.ini-production /usr/local/php/etc/php.ini
[root@server php-7.2.21]# cp /usr/local/src/php-7.2.21/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@server php-7.2.21]# chmod +x /etc/init.d/php-fpm
[root@server php-7.2.21]# /etc/init.d/php-fpm start
Starting php-fpm done
[root@server php-7.2.21]# netstat -autnp | grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 129852/php-fpm: mas