tar zxf mysql-boost-5.7.28.tar.gz
useradd -s /sbin/nologin -M mysql
yum install -y cmake ##编译mysql需要用的包
cd mysql-5.7.28 ##进入mysql解压后的目录
##编译:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql \ ##安装位置
> -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock \ ##指定套接字文件位置
> -DEXTRA_CHARSETS=all \ ##扩展字符集
> -DDEFAULT_CHARSET=utf8 \ ##默认字符集
> -DDEFAULT_COLLATION=utf8_general_ci \ ##默认字符校对
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \ ##安装myisam 存储引擎
> -DWITH_MYISAM_STORAGE_ENGINE=1 \ ##安装innodb存储引擎
> -DWITH_MEMORY_STORAGE_ENGINE=1 \ ##安装memory存储引擎
> -DWITH_READLINE=1 \ ##支持readline库
> -DENABLED_LOCAL_INFILE=1 \ ##启用加载本地数据
> -DMYSQL_USER=mysql \ ##指定mysql运行用户
> -DMYSQL_TCP_PORT=3306 ##指定mysql端口
yum install -y gcc gcc-c++ ncurses-devel openssl-devel -y
make && make install
cd /usr/local/lnmp/mysql
mkdir data
chown -R root .
chown -R mysql data
ln -s /usr/local/lnmp/mysql/bin/* /usr/local/bin/
cd /usr/local/lnmp/mysql/mysql-test/include
cp default_my.cnf /etc/my.cnf
cd /usr/local/lnmp/mysql/support-files
cp -a mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig mysqld on
systemctl status mysqld
mysqld --user=mysql --initialize ##以mysql 用户身份初始化
注意:
初始化会生成一个临时密码,用于登录 mysql(要记住此密码)
比如:
2019-01-03T09:06:09.448851Z 1 [Note] A temporary password is generated
for root@localhost: r##9VqAoA/au
r##9VqAoA/au
就是临时密码
systemctl start mysqld
mysql -uroot -pr##9VqAoA/au: ##使用刚才的临时密码(会有报错,所以需要安全初始化)
mysql_secure_installation ##然后会提示是否启用密码检测插件,直接回车不启用,否则会要求密码有大小写和特殊字符等要求。剩余全部选 y
tar zxf php-7.4.1.tar.gz
yum -y install bzip2
./configure --prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc \
--with-mysqli=/usr/local/lnmp/mysql/bin/mysql_config \
--enable-soap \
--enable-mbstring=all \
--enable-sockets \
--with-pdo-mysql=/usr/local/lnmp/mysql \
--enable-gd \
--without-pear \
--enable-fpm
yum install -y libxml2-devel
yum install -y libpng-devel
yum install -y oniguruma-*
make && make install
cd /usr/local/lnmp/php/etc
cp php-fpm.conf.default php-fpm.conf
vim php-fpm.conf
##修改
pid = run/php-fpm.pid
cd /usr/local/lnmp/php/etc/php-fpm.d
cp www.conf.default www.conf
vim www.conf
##修改
user = nginx
group = nginx
cd php-7.4.1
cp php.ini-production /usr/local/lnmp/php/etc/php.ini
vim /usr/local/lnmp/php/etc/php.ini
##修改时区
date.timezone = Asia/Shanghai
/etc/init.d/
:cd /root/lnmp/php-7.4.1/sapi/fpm
cp init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm ##添加执行权限
/etc/init.d/php-fpm start
注意:
启动报错可能因为没有 nginx 用户,需要手动创建
useradd -u 900 nginx
tar zxf nginx-1.16.0.tar.gz
cd /root/lnmp/nginx-1.16.0
vim src/core/nginx.h
##修改:
#define NGINX_VER "nginx/"(将此行末尾显示 nginx 版本号的配置删除)
vim auto/cc/gcc
##修改:
# debug
#CFLAGS="$CFLAGS -g" (将这2行注释调,关闭debug)
./configure --prefix=/usr/local/lnmp/nginx --with-http_ssl_module --with-http_stub_status_module --user=nginx --group=nginx
pcre-devel
:yum install pcre-devel -y
make && make install
cd /usr/local/lnmp/nginx/conf
vim nginx.conf
##修改
user nginx nginx;
location / {
root html;
index index.php index.html index.htm; ##(添加 php 页面)
}
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.conf;
}
/usr/local/sbin/
:ln -s /usr/local/lnmp/nginx/sbin/nginx /usr/local/sbin/
nginx -t ##检测语法
nginx
http://172.25.254.51
可以访问到Nginx默认页面。index.php
:vim /usr/local/lnmp/nginx/html/index.php
##写入:
()
?>
刷新http://172.25.254.51
可以看到php的默认页面。