编译安装Nginx + PHP + MySQL
2023-06-13 09:14:08 时间
编译安装 Nginx
# 创建用户和组
groupadd nginx
useradd -s /sbin/nologin nginx
# 编译安装
./configure --prefix=/usr/local/nginx --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_mp4_module --with-http_sub_module --with-http_stub_status_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre --with-http_auth_request_module
make && make install
chown -R nginx.nginx /usr/local/nginx/
# 添加启动脚本
vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx - high performance web server
Documentation=https://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
[Install]
WantedBy=multi-user.target
# 启动
systemctl daemon-reload
systemctl start nginx
编译安装 MySQL
# 创建用户和组
groupadd mysql
useradd -r -g mysql mysql
# 创建数据目录并授权
mkdir /data/mysql
chown -R mysql.mysql /data/mysql/
# 编译安装
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
make && make install
# 初始化
cd /usr/local/mysql
scripts/mysql_install_db --user=mysql --defaults-file=/etc/my.cnf --datadir=/data/mysql --basedir=/usr/local/mysql
cp support-files/my-large.conf /etc/my.cnf
mysql_secure_installation
# 添加启动脚本
vim /usr/lib/systemd/system/mysqld.service
[Unit]
Description=MySQL Community Server
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
Alias=mysql.service
[Service]
User=mysql
Group=mysql
PermissionsStartOnly=true
ExecStart=/usr/local/mysql/bin/mysqld
TimeoutSec=600
Restart=always
PrivateTmp=false
# 启动
systemctl daemon-reload
systemctl start mysqld
编译安装 PHP
# 安装依赖
yum install zlib zlib-devel libxml2 libxml2-devel bzip2 bzip2-devel curl curl-devel libjpeg* libpng* freetype freetype-devel libzip libzip-devel libmcrypt libmcrypt-devel mhash mhash-devel
# 编译安装
./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir=/usr --with-gd --enable-sysvshm --with-iconv --with-zlib --with-zlib-dir --enable-xml --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-jpeg-dir --with-png-dir --with-curl --with-jpeg-dir --with-freetype-dir --with-mhash --with-mcrypt --with-bz2 --with-pdo-mysql=/usr/local/mysql/ --enable-fastcgi
make && make install
# 复制配置文件
cp /usr/local/src/php-5.6.31/php.ini-production /etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/src/php-5.6.31/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
chmod +x /etc/init.d/php-fpm
chkconfig php-fpm on
# 设置用户和组
vim /usr/local/php/etc/php-fpm.d/www.conf
user = nginx
group = nginx
vim /usr/local/php/etc/php-fpm.conf
pid = run/php-fpm.pid
# 添加启动脚本
vim /usr/lib/systemd/system/php-fpm.service
[Unit]
Description=The PHP FastCGI Process Manager
After=network.target
[Service]
Type=simple
PIDFile=/usr/local/php/var/run/php-fpm.pid ExecStart=/usr/local/php/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
# 启动
systemctl daemon-reload
systemctl start php-fpm
相关文章
- 【PHP释放MySQL的威力】(php释放mysql)
- 管理MySQL 妙招精打金钱管理(mysql金钱)
- MySQL的分页查询:实现快速分页(mysql的分页语句)
- 从PHP与MySQL结合 创造美好图片(php图片mysql)
- 备份MySQL定时创建表备份的实施与设计(mysql定时创建表)
- 安装MySQL:轻松解决一切(如何下载并安装mysql)
- MySQL连接器安装指南 快速连接数据库(mysql连接器安装)
- MySQL账号密码管理指南(mysql的账号和密码)
- MySQL数据库:免费软件下载体验(mysql数据库软件下载)
- 的安装Mac下MySQL安装指南(mac中mysql)
- MySQL复制出现错误:如何解决(mysql复制错误)
- MySQL中查看用户密码的方法(mysql显示用户密码)
- MySQL配置与安装步骤指南(mysql配置安装)
- MySQL数据库管理: 从入门到精通(mysql数据库如何管理)
- MySQL免安装设置账号密码简易教程(mysql免安装密码)
- 了解MySQL:不同版本的比较(mysql版本介绍)
- 【更改MySQL用户名:一步步教程】(更改mysql用户名)
- 实用指南:MySQL快速安装(mysql的安装方法)
- 使用 cmd 安装 MySQL 数据库(cmd安装mysql)
- Mysql日志的作用及重要性(mysql日志作用)
- 如何安装Hive和MySQL数据库?(hive及mysql安装)
- 使用MySQL自带工具管理数据库(mysql自带工具)
- MySQL联合查询技术:强大而强大(mysql的联合查询)
- MySQL中空值索引优化策略(mysql索引空值)
- Linux中安装PHP的PDO MySQL扩展的详细解决方案
- 深入了解如何在MySQL中进行Was配置(mysql的was配置)
- 更新极速改进:从PHP和MySQL版本更新中获益(php mysql版本)
- MySQL中now函数的使用方法(mysql中now的用法)
- CRT安装MySQL服务一步一步指南(crt安装mysql服务)
- MySQL如何保证严格的语法规范探讨MySQL严格语法的实现方式(mysql严格语法)
- 快速了解如何在ASP环境下安装MySQL(asp 安装mysql)
- 如何避免MySQL安装在C盘上教你轻松搬家到其他磁盘(mysql不下c盘的教程)
- MySQL下载ZIP包,解压安装教程(mysql下载的是zip)
- MySQL分表实现,教你如何优化大数据存储(mysql下如何分表)
- 无法卸载MySQL怎么办解决方案汇总(mysql 不能卸载不了)
- MySQL安装完成后的配置和使用指南(mysql下好后怎么做)