#关闭防火墙和selinux
systemctl stop firewalld
setenforce 0
#安装依赖
yum -y install pcre-devel zlib-devel gcc gcc-c++ make
#创建用户
useradd -M -s /sbin/nologin nginx
#获取源码包
wget https://nginx.org/download/nginx-1.24.0.tar.gz
cd /opt
tar xf nginx-1.24.0.tar.gz#解压
cd nginx-1.24.0/
#编译
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module
cd nginx-1.24.0/
#编译
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module
#安装
make -j2 && make install
#让系统识别nginx操作命令,可以补全
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
#依赖环境
yum -y install \
ncurses \
ncurses-devel \
bison \
cmake
#添加用户
useradd -s /sbin/nologin mysql
将MySQL源代码包放在 /opt目录下
tar xf mysql-boost-5.7.20.tar.gz #解压
cd mysql-5.7.20
#编译
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DSYSCONFDIR=/etc \
-DSYSTEMD_PID_DIR=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_BOOST=boost \
-DWITH_SYSTEMD=1
#安装
make -j2 && make install
#进入配置文件,把内容全删掉,然后加入以下内容
vim /etc/my.cnf
[client]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock
[mysql]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock
[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
character_set_server=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket = /usr/local/mysql/mysql.sock
server-id = 1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES
chown -R mysql:mysql /usr/local/mysql/
chown mysql:mysql /etc/my.cnf
echo 'export PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile
source /etc/profile
cd /usr/local/mysql/bin/
./mysqld \
--initialize-insecure \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data
cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
#能用systemd启动
systemctl daemon-reload 刷新识别
systemctl start mysqld.service 开启服务
systemctl enable mysqld 开机自启动
ss -natp | grep 3306 查看端口
mysqladmin -u root -p password "123abc"
mysql -u root -p #授权远程登录
#安装依赖环境
#安装GD库和GD库关联程序,用来处理和生成图片
yum -y install \
libjpeg \
libjpeg-devel \
libpng libpng-devel \
freetype freetype-devel \
libxml2 \
libxml2-devel \
zlib zlib-devel \
curl curl-devel \
openssl openssl-devel
将PHP源代码包放在 /opt目录下
tar -jxvf php-7.1.10.tar.bz2 #解压
cd /opt/php-7.1.10/
#编译环境检测 功能模块添加
./configure \
--prefix=/usr/local/php \
--with-mysql-sock=/usr/local/mysql/mysql.sock \
--with-mysqli \
--with-zlib \
--with-curl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-openssl \
--enable-fpm \
--enable-mbstring \
--enable-xml \
--enable-session \
--enable-ftp \
--enable-pdo \
--enable-tokenizer \
--enable-zip
#安装
make -j2 && make install
ln -s /usr/local/php/bin/* /usr/local/bin/
ln -s /usr/local/php/sbin/* /usr/local/sbin/
php有三个配置文件
php.ini 主配置文件
php-fpm.conf 进程服务配置文件
www.conf 扩展配置文件
调整主配置文件
cp /opt/php-7.1.10/php.ini-development /usr/local/php/lib/php.ini #模板
vim /usr/local/php/lib/php.ini #修改主配置文件
cd /usr/local/php/etc/
cp php-fpm.conf.default php-fpm.conf
vim php-fpm.conf
cd /usr/local/php/etc/php-fpm.d/
cp www.conf.default www.conf
/usr/local/php/sbin/php-fpm -c /usr/local/php/lib/php.ini
ss -napt | grep 9000
cd /opt/php-7.1.10/sapi/fpm
cp php-fpm.service /usr/lib/systemd/system/php-fpm.service
systemctl restart php-fpm.service
vim /usr/local/nginx/conf/nginx.conf
#创建网页文件
vi /usr/local/nginx/html/index.php
<?php
phpinfo();
?>
#重启nginx服务
systemctl restart nginx
#在网页测试
http://192.168.2.102/index.php