环境准备:先安装准备环境
yum install gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel
nginx
1. 下载 wget http://nginx.org/download/nginx-1.16.0.tar.gz (版本可自行选择)
2. 解压 tar xvf nginx-1.16.0.tar.gz
3. 进入 cd nginx-1.16.0
4. ./configure --prefix=/lnmp/nginx --with-http_ssl_module
5. make
6.
make install
configure参数说明
–prefix=path nginx安装路径
–sbin-path=path 启动程序路径
–pid-path=path pid路径
–error-log-path=path
–http-log-path=path acess.log
–user=name 用户
–group=name 用户组
–without-http_rewrite_module
–without-http_proxy_module
–without-http_gzip_module
–with-http_ssl_module
php
1. wget https://www.php.net/distributions/php-7.3.5.tar.gz (版本可自行选择)
2. tar xvf php-7.3.5.tar.gz
3. ce php-7.35.tar.gz
4. ./configure --prefix=/lnmp/php7 --enable-fpm --with-mysqli --with-curl --with-pdo_mysql --with-pdo_sqlite --enable-mysqlnd --enable-mbstring --with-gd
如提示某些安装某些依赖 (安装好提示的未安装依赖后,再从新走四步)
如libxml2 用 命令 yum install libxml2-devel
yum install libpng-devel
yum install curl-devel
5. make && make install
6. cp php.ini-development /lnmp/php7/lib/php.ini
7. 重命名php-fpm.conf.default 为 php-fpm.conf
www.conf.default 为 www.conf
8. 复制php-fpm到/usr/local/bin/ (这样全局可用php-fpm开启php,关闭命令为killall php-fpm, 否则使用 /lnmp/php7/sbin/php-fpm开启php )
mysql
1. https://dev.mysql.com/downloads/mysql/ (自行选择)
2. tar zxvf mysql-8.0.11-linux-glibc2.12-i686.tar.gz
3. mv /root/mysql-8.0.11-linux-glibc2.12-i686 /lnmp/mysql (移动压缩包到usr/local目录下,并重命名文件)
4. mkdir data (在MySQL根目录下新建一个文件夹data,用于存放数据)
5. groupadd mysql (创建 mysql 用户组和 mysql 用户)
useradd -g mysql mysql
6. chown -R mysql.mysql /lnmp/mysql/ (改变 mysql 目录权限)
7. mkdir mysql_install_db (创建mysql_install_db安装文件)
chmod 777 ./mysql_install_db
bin/mysqld --initialize --user=mysql --basedir=/lnmp/mysql --datadir=/lnmp/mysql/data (初始化)
8. vim /etc/my.cnf (修改my.cnf文件 把下方内容粘贴进去 如果安装路径不同填写自己的路径)
[mysqld]
basedir = /lnmp/mysql
datadir = /lnmp/mysql/data
socket = /tmp/mysql.sock
character-set-server=utf8
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
socket = /lnmp/mysql.sock
default-character-set=utf8
9. cp -a ./support-files/mysql.server /etc/init.d/mysqld (配置mysqld服务)
chmod +x /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
10. vi /etc/profile (配置全局环境变量)
在 profile 文件底部添加如下两行配置,保存后退出
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
export PATH
设置环境变量立即生效
source /etc/profile
(不慎忘记mysql密码可用此方法找回 http://www.cnblogs.com/wuotto/p/9682400.html)
主要参考自 https://me.csdn.net/qq_19826793
原文:https://www.cnblogs.com/phpshangxiaobai/p/10864525.html