目录
1.编译安装Nginx
1.1 关闭防火墙
1.2 安装依赖包
1.3 创建运行用户
1.4 编译安装Nginx
1.5 路径优化
1.6 添加Nginx系统服务
2.编译安装mysql5.7
2.1 安装Mysql环境依赖包
2.2 创建运行用户
2.3 编译安装
2.4 数据库目录进行权限调整
2.5 调整配置文件
2.6 设置环境变量
2.7 初始化数据库
2.8 数据库开启自启、 关闭、状态
2.9 设置Mysql密码
2.10 登录数据库
3.安装配置php文件
3.1 安装环境依赖包
3.2 编译安装
3.3 修改php配置文件
3.4 验证php测试页
4.安装论坛
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
yum -y install pcre-devel zlib-devel gcc gcc-c++ make
新建用户 组便于管理(nginx 服务程序默认 以 nobody 身份运行,建议为其创建专门的用户账户,以便更准确的控制访问权限)
useradd -M -s /sbin/nologin nginx
#切换至/opt
cd /opt
#解压nginx文件
tar zxvf nginx-1.12.0.tar.gz
#切换目录
cd nginx-1.12.0/
#编译
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module
#安装
make && make install -j4
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
方法一:
vim /etc/init
#!/bin/bash
#chkconfig: - 99 20
#description:Nginx Service Control Script
PROG="/usr/local/nginx/sbin/nginx"
PIDF="/usr/local/nginx/logs/nginx.pid"
case "$1" in
start) $PROG
;;
stop)
kill -s QUIT $(cat $PIDF)
;;
restart)
$0 stop $0 start
;;
reload)
kill -s HUP $(cat $PIDF)
;;
*) echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
exit 0
#!/bin/bash
#chkconfig: 35 99 20
#description:Nginx Service Control Script
cmd="/usr/local/nginx/sbin/nginx"
pid="/usr/local/nginx/logs/nginx.pid"
case $1 in
start)
$cmd
;;
stop)
kill -3 `cat $pid`
;;
reload)
kill -1 `cat $pid`
;;
restart)
$0 stop
$0 start
;;
*)
echo "plaese input start,stop,reload,restart"
exit 1
esac
exit 0
方法二:
vim /lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/bin/kill -s HUP $MAINPID
ExecStop=/usr/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
##配置参数解释##
[Unit]
Description=nginx ####描述
After=network.target ####描述服务类别
[Service]
Type=forking ###后台运行形式
PIDFile=/usr/local/nginx/logs/nginx.pid ###PID文件位置
ExecStart=/usr/local/nginx/sbin/nginx ###启动服务
ExecReload=/usr/bin/kill -s HUP $MAINPID ###根据PID重载配置
ExecStop=/usr/bin/kill -s QUIT $MAINPID ###根据PID终止进程
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[root@localhost system]#systemctl daemon-reloadsystemctl daemon-reload
#重载服务
[root@localhost system]#systemctl start nginx.service
测试
[root@localhost ~]# yum -y install \
ncurses \
ncurses-devel \
bison \
cmake
[root@localhost ~] useradd -s /sbin/nologin mysql
[root@localhost opt]#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 && make install -j4
[root@localhost mysql-5.7.20]#chown -R mysql:mysql /usr/local/mysql/
[root@localhost mysql-5.7.20]#vi /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
NO_ENGINE_SUBSTITUTION
如果需要的存储引擎被禁用或未编译,那么抛出错误。不设置此值时,用默认的存储引擎替代,并抛出一个异常
STRICT_TRANS_TABLES
在该模式下,如果一个值不能插入到一个事务表中,则中断当前的操作,对非事务表不做限制
NO_AUTO_CREATE_USER
禁止:GRANT创建密码为空的用户
NO_AUTO_VALUE_ON_ZERO
mysql中的自增长列可以从o开始。默认情况下自增长列是从1开始的,如果你插入值为0的数据会报错
NO_ZERO_IN_DATE
mysql数据库不允许插入零日期,插入零日期会抛出错误而不是警告
ERROR_FOR_DIVISION_BY_ZERO
在INSERT或UPDATE过程中,如果数据被零除,则产生错误而非警告。默认情况下数据被零除时MysQL返回NULL
IPES_AS_CONCAT
将"||"视为字符串的连接操作符而非或运算符,这和oracle数据库是一样的,
ANSI QUOTES
启用ANSI QUOTES后,不能用双引号来引用字符串,因为它被解释为识别符
[root@localhost mysql-5.7.20]#chown mysql:mysql /etc/my.cnf
#改变属主 属组
echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile
echo 'export 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/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
systemctl enable mysqld
systemctl start mysqld
systemctl stop mysqld
systemctl status mysqld
netstat -anpt | grep 3306
mysqladmin -u root -p password
mysql -u root -p
yum -y install \
libjpeg \
libjpeg-devel \
libpng libpng-devel \
freetype freetype-devel \
libxml2 \
libxml2-devel \
zlib zlib-devel \
curl curl-devel \
openssl openssl-devel
#切换至/opt目录
cd /opt/
#解压文件
tar -jxf 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 -j4
#修改php.ini 核心配置文件
#拷贝
cp php.ini-development /usr/local/php/lib/php.ini
#进入核心配置文件
vim /usr/local/php/lib/php.ini
#修改第1170行和939行
1170 mysqli.default_socket = /usr/local/mysql/mysql.sock
939 date.timezone = Asia/Shanghai
#验证安装的模块
/usr/local/php/bin/php -m
#配置及优化FPM模块
cd /usr/local/php/etc/
cp php-fpm.conf.default php-fpm.conf
cd /usr/local/php/etc/php-fpm.d/
cp www.conf.default www.conf
#进入目录
cd /usr/local/php/etc/
#进入进程服务配置文件
vi php-fpm.conf
pid = run/php-fpm.pid #将这一行注释去掉
#创建
/usr/local/php/sbin/php-fpm -c /usr/local/php/lib/php.ini
#查看结果
ps aux | grep -c "php-fpm"
#让nginx支持PHP功能
#进入nginx主配置文件
vi /usr/local/nginx/conf/nginx.conf
--65行--取消注释,修改
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name; #将/scripts修改为nginx的工作目录
include fastcgi_params;
}
#创建网页文件
vi /usr/local/nginx/html/index.php
#创建网页文件
vi /usr/local/nginx/html/index.php
#重启nginx服务
systemctl restart nginx
#在网页测试
“http://192.168.52.120/index.php”
mysql> CREATE DATABASE bbs; //创建一个数据库//
mysql> GRANT all ON bbs.* TO 'bbsuser'@'%' IDENTIFIED BY 'admin123'; //把bbs数据库里面所有表的权限授予给bbsuser,并设置密码// 所有访问来源/渠道
mysql> GRANT all ON bbs.* TO 'bbsuser'@'localhost' IDENTIFIED BY 'admin123';
mysql>flush privileges; //刷新数据库//
unzip /opt/lamp/Discuz_X2.5_SC_UTF8.zip -d /opt/dis
cd /opt/dis
cp -r upload/ /usr/local/httpd/htdocs/bbs
cd /usr/local/httpd/htdocs/bbs
chown -R daemon ./config
chown -R daemon ./data
chown -R daemon ./uc_client
chown -R daemon ./uc_server/data
http://192.168.52.120/bbs