MySQL
安装
MySQL
mysql-boots-5.7.11.tar.gz
tar zxf mysql-boots-5.7.11.tar.gzcmake
get cmake-2.8.12.2-4.el6.x86_64.rpm
yum install cmake-2.8.12.2-4.el6.x86_64.rpm -y
- MySQL安装时所需依赖性
yum install gcc gcc-c++ ncurses-devel
- 编译
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BOOST=boost/boost_1_59_0/
安装时如若出错,查看给出error信息,检,纠错后删除掉CMakeCache.txt再次编译,若编译成功后即可安装:
make && make install
配置MySQL
groupadd -g 27 mysql
useradd -u 27 -g 27 -s /sbin/nologin -M -d /usr/local/lnmp/mysql mysql ##建立mysql用户
vim /etc/passwd
mysql:x:27:27::/usr/local/lnmp/mysql/data:/sbin/nologin
cd /usr/local/lnmp/mysql
chown mysql.mysql . -R ##修改此文件里所有文件包括子文件的用户与用户组
vim ~/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin
source ~/.bash_profile ##使环境变量生效
mysqld --initialize --user=mysql ##会生成临时密码(第一次进MySQL所需)
测试:
mysql -p
ERROR:Can't connect to local MySQL server through socket...
cd /usr/local/lnmp/mysql/support-files/
cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql ##这里的datadir是不正确的,需要改变datadir重新初始化
cd /etc/
cp my.cnf my.cnf.bak ##备份
cd /usr/local/lnmp/mysql/support-files/
cp my-default.cnf /etc/my.cnf
cp mysql.server /etc/init.d/mysqld
cd /usr/local/lnmp/mysql/
chown root.root . -R
cd /var/lib/
rm -fr mysql/
cd /usr/local/lnmp/mysql/
chown root.root . -R
chown mysql.mysql . -R
mysqld --initialize --user=mysql ##mysql初始化
ll /usr/local/lnmp/mysql/
drwxr-xr-x 2 root root 4096 Jul 21 10:49 bin
-rw-r--r-- 1 root root 17987 Nov 28 2016 COPYING
drwxr-x--- 5 root root 4096 Jul 21 11:22 data
drwxr-xr-x 2 root root 4096 Jul 21 10:47 docs
drwxr-xr-x 3 root root 4096 Jul 21 10:47 include
drwxr-xr-x 4 root root 4096 Jul 21 10:49 lib
drwxr-xr-x 4 root root 4096 Jul 21 10:48 man
drwxr-xr-x 10 root root 4096 Jul 21 10:49 mysql-test
-rw-r--r-- 1 root root 2478 Nov 28 2016 README
drwxr-xr-x 28 root root 4096 Jul 21 10:49 share
drwxr-xr-x 2 root root 4096 Jul 21 11:14 support-files
chown mysql.data -R ##修改data文件的用户为mysql,使得datadir为正确的路径
ll /usr/local/lnmp/mysql/
drwxr-xr-x 2 root root 4096 Jul 21 10:49 bin
-rw-r--r-- 1 root root 17987 Nov 28 2016 COPYING
drwxr-x--- 5 mysql root 4096 Jul 21 11:22 data
drwxr-xr-x 2 root root 4096 Jul 21 10:47 docs
drwxr-xr-x 3 root root 4096 Jul 21 10:47 include
drwxr-xr-x 4 root root 4096 Jul 21 10:49 lib
drwxr-xr-x 4 root root 4096 Jul 21 10:48 man
drwxr-xr-x 10 root root 4096 Jul 21 10:49 mysql-test
-rw-r--r-- 1 root root 2478 Nov 28 2016 README
drwxr-xr-x 28 root root 4096 Jul 21 10:49 share
drwxr-xr-x 2 root root 4096 Jul 21 11:14 support-files
/etc/init.d/mysqld start
mysql -p
使用临时密码登入后执行命令后:
ERROR:You must reset your password using ALTER USER statement before executing this statement.
重置密码
mysql_secure_installation
测试:
mysql -p ##使用重置密码登录
PHP
安装包
php-5.6.20.tar.bz2
tar jxf php-5.6.20.tar.bz2
编译
./configure --prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-gmp --with-gettext --enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash
- 安装过程中会有提醒error需要解决安装各功能模块所需的开发模块,通过yum install一一解决
- 依赖性解决
yum install libxml2-devel curl-devel libjpeg-devel freetype-devel gmp-devel net-snmp-devel bison -y
rpm -ivh libmcrypt-devel-2.5.8-9.el6.x86_64.rpm libcrypt-2.5.8-9.el6.x86_64.rpm re2c-0.13.5-1.el6.x86_64.rpm
安装
- 解决了PHP软件包的依赖性后即可安装
make && make install
配置php
cd ~/php-5.6.20
cp php.int-production /usr/local/lnmp/php/etc/php.ini ##复制配置文件
cd sapi/fpm/
cp init.d.php-fpm /etc/init.d/php-fpm ##添加php-fpm命令
chmod +x /etc/init.d/php-fpm ##给予php-fpm可执行权限
cd /usr/local/lnmp/php/etc/
vim php.ini
date.timezone = Asia/Shanghai ##修改时区
cd /usr/local/lnmp/php/etc
cp php-fpm.conf.default php-fpm.conf
vim php-fpm.conf
pid = run/php-fpm.pid
/etc/init.d/php-fpm start ##运行php fast cgi
vim ~/.bash_profile ##修改环境变量
PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin:/usr/local/lnmp/php/bin
source ~/.bash_profile
PHP+Nginx
vim /usr/local/lnmp/nginx/conf/nginx.conf
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000; ##fastcgi:本机的9000端口
fastcgi_index index.php; ##fastcgi访问页面
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi.conf;
}
51 location / {
52 root html;
53 index index.php index.html index.htm; ##加入index.php
54 }
cd /usr/local/lnmp/nginx/html/
vim index.php
<?
phpinfo()
?>
测试:
web:172.25.36.1
通过论坛Discuz,整合MySQL+PHP
安装包
Discuz_X3.2_SC_UTF8.zip安装
unzip Discuz_X3.2_SC_UTF8.zip
- 配置
mv upload/ /usr/local/lnmp/nignx/html/bbs
测试:
172.25.36.1/bbs ##设置论坛界面
当进入论坛界面无法加载mysql文件:
cd /usr/local/lnmp/nginx/html/bbs
chmod 777 config/ data/ uc_client/ uc_server/ -R ##递归
当论坛数据无法连接数据库:
vim /etc/local/lnmp/php/etc/php.ini
1000 pdo_mysql.default_socket= /usr/local/lnmp/mysql/data/mysql.sock