为了与Nginx,PHP环境保持一致,此处选择采用源代码编译的方式安装MySQL组件
MySQL 部署的方法
*编译安装MySQL
*优化调整
*初始化数据库
*启动MySQL 服务冰设置root数据库账号的密码
yum -y install \
ncurses \
ncurses-devel \
bison \
cmake
useradd -s /sbin/nologin mysql //创建用户及指定shell环境
###上传mysql-boost-5.7.20.tar.gz到opt目录下###
cd /opt
tar xf 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_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
#####数据库目录进行权限调整###
chown -R mysql:mysql /usr/local/mysql/
#######设置环境变量####
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 status mysqld
netstat -anpt | grep 3306
mysqladmin -u root -p password //刚开始没密码是空的直接回车,然后输入密码abc123,在此确认abc123,这是在root账户下运行的
mysql -u root -p ##这个命令敲下,提示要输入密码,这个就是刚才设置的密码abc123
yum -y install \
libjpeg \
libjpeg-devel \
libpng libpng-devel \
freetype freetype-devel \
libxml2 \
libxml2-devel \
zlib zlib-devel \
curl curl-devel \
openssl openssl-devel
cd /opt
tar xjvf 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
cp php.ini-development /usr/local/php/lib/php.ini
vi /usr/local/php/lib/php.ini ( 在配置文件修改搜索以下俩条进行补全)
mysqli.default_socket = /usr/local/mysql/mysql.sock
date.timezone = Asia/Shanghai
/usr/local/php/bin/php -m //验证安装的模块
[root@localhost php-7.1.10]# cd /opt
[root@localhost php-7.1.10]# cd /usr/local/php/etc/
[root@localhost etc]# ll
total 12
-rw-r–r-- 1 root root 1233 Sep 3 11:51 pear.conf
-rw-r–r-- 1 root root 4463 Sep 3 11:51 php-fpm.conf.default
drwxr-xr-x 2 root root 30 Sep 3 11:51 php-fpm.d
[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf
[root@localhost etc]# cd /usr/local/php//etc/php-fpm.d/
[root@localhost php-fpm.d]# cp www.conf.default www.conf
[root@localhost php-fpm.d]# cd /usr/local/php/etc/
[root@localhost etc]# vi php-fpm.conf
pid = run/php-fpm.pid 这条搜索把前面#号去掉 ,然后在下面添加下面俩条
;user = nginx
;group = nginx
[root@localhost etc]# /usr/local/php/sbin/php-fpm -c /usr/local/php/etc/php.ini
[root@localhost etc]# netstat -anpt |grep 9000
ln -s /usr/local/php/bin/* /usr/local/bin/
[root@localhost etc]# vi /usr/local/nginx/conf/nginx.conf
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;
include fastcgi_params;
}
下面开始做测试页
[root@localhost etc]# vi /usr/local/nginx/html/index.php
();
?>
[root@localhost etc]# systemctl restart nginx
| ####LNMP应用部署####
[部署Discuz!社区论坛Web应用]
########以下安装论坛##########
cd /opt
unzip Discuz X3.4_ SC_ UTF8.zip -d /tmpcd /tmp/dir SC _UTF8/
cp -r upload/ /usr/local/nginx/html/bbs/cd /usr/local/nginx/html/bbs/
chown -R root:nginx ./config/
chown -R root:nginx ./data/
chown -R root:nginx ./uc_ client/
chown -R root:nginx ./uc_ server/
chmod -R 777./config/chmod -R 777 ./data/
chmod -R 777 ./uc client/chmod -R 777 ./uc_ server/
http://lP/bbs/install/index.php
注释:请通过ftp删除install/index.php
cd /usr/local/nginx/html/bbs/
mv install/ install.lock
chmod 600 install.lock/