目录
一、安装Nginx
1.关闭防火墙和安全机制
2.安装依赖包
3.创建运行用户
4.编译安装并安装
5.优化路径
6. 添加 Nginx 系统服务
7.赋权并重启服务
二、安装Mysql数据库
1、安装Mysql环境依赖包
2.创建运行用户
3.编译安装
4.修改mysql 配置文件
5.更改mysql安装目录和配置文件的属主属组
6.设置路径环境变量
7.初始化数据库
8.添加mysqld系统服务
9.修改mysql 的登录密码
10.授权远程登录
三、安装PHP
1、安装环境依赖包
编辑2、编译安装
3.路径优化
4.调整PHP配置文件
5.启动php-fpm
编辑6、配置 Nginx 支持 PHP 解析
7.验证PHP 测试页
yum -y install pcre-devel zlib-devel gcc gcc-c++ make
useradd -M -s /sbin/nologin nginx
cd /opt
tar zxvf nginx-1.12.0.tar.gz -C /opt/
cd nginx-1.12.0/
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module
make && make install
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
vim /lib/systemd/system/nginx.service
chmod 754 /lib/systemd/system/nginx.service
yum -y install \
ncurses \
ncurses-devel \
bison \
cmake
useradd -M -s /sbin/nologin mysql
cd /opt
tar zxvf mysql-boost-5.7.20.tar.gz
cd /opt/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_EXTRA_CHARSETS=all \
-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 -j 4 && make install
vim /etc/my.cnf
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
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/
systemctl daemon-reload
systemctl start mysqld.service
systemctl enable mysqld
mysqladmin -u root -p password "123456"
mysql -u root -p
yum -y install gd \
libjpeg libjpeg-devel \
libpng libpng-devel \
freetype freetype-devel \
libxml2 libxml2-devel \
zlib zlib-devel \
curl curl-devel \
openssl openssl-devel
cd /opt
tar jxvf php-7.1.10.tar.bz2
cd 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 && make install
ln -s /usr/local/php/bin/* /usr/local/bin/
ln -s /usr/local/php/sbin/* /usr/local/sbin/
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
cd /opt/php-7.1.10/sapi/fpm
重启服务
systemctl restart nginx.service
vim /usr/local/nginx/html/index.php
phpinfo();
?>
浏览器访问http://192.168.146.110/index.php