[root@server1 bin]# cd /usr/local/lnmp/mysql/
[root@server1 ~]# chown root . -R #改回权限
[root@server1 mysql]# chown mysql data/ -R
[root@server1 ~]# /etc/init.d/mysqld start #启动mysql
Starting MySQL. SUCCESS!
[root@server1 ~]# mysql-p #登陆mysql
Enter password: #密码是上一个截图里最后的QV>6!r4LCyjw
3. php的源码安装及配置
1.安装
[root@server1 mnt# tar jxf php-5.6.20.tar.bz2 #解压
[root@server1 php-5.6.20]# rpm -vih libmcrypt-* #安装libmcrypt库
[root@server1 php-5.6.20]# yum installre2c-0.13.5-1.el6.x86_64.rpm –y #安装re2c
[root@server1 php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash
如果出现如下错误
[root@server1 php-5.6.20]# yum install libxml2-devel -y
[root@server1 php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash
#####注意:php在加载配置过程中,如上面会报很多错误。有经验的可以根据报错自己去装所需要的包;新手可以参考前几篇博文,安装所需要的包
[root@server1 php-5.6.20]# make #编译
[root@server1 php-5.6.20]# make install #安装
2.php的配置
[root@server1 php-5.6.20]# cd /usr/local/lnmp/php/etc/
[root@server1 etc]# ls
php-fpm.conf.default
[root@server1 etc]# cp php-fpm.conf.default php-fpm.conf #备份php的文件
[root@server1 etc]# ls
php-fpm.conf php-fpm.conf.default
[root@server1 etc]# cp /mnt/php-5.6.20/php.ini-productionphp.ini #php的配置文件
[root@server1 etc]# ls
php-fpm.conf php-fpm.conf.default php.ini
[root@server1 etc]# vim php.ini
925 date.timezone = Asia/Shanghai #修改时区
1001 pdo_mysql.default_socket=/usr/local/lnmp/mysql/data/mysql.sock #指定连接数据库的sock文件的路径
1150 mysql.default_socket =/usr/local/lnmp/mysql/data/mysql.sock #同上
1209 mysqli.default_socket =/usr/local/lnmp/mysql/data/mysql.sock #同上
[root@server1 etc]# vim php-fpm.conf
25 pid = run/php-fpm.pid #将pid的标记去掉
[root@server1 etc]# cd /mnt/php-5.6.20/sapi/fpm/
[root@server1 fpm]# cp init.d.php-fpm /etc/init.d/php-fpm #添加启动命令
[root@server1 fpm]# chmod +x /etc/init.d/php-fpm #添加可执行权限
[root@server1 fpm]# ll /etc/init.d/php-fpm
-rwxr-xr-x 1 root root 2359 Sep 18 00:18 /etc/init.d/php-fpm
[root@server1 fpm]# /etc/init.d/php-fpm start #开启php服务
Starting php-fpm done
[root@server1 fpm]# cd /usr/local/lnmp/nginx/conf/
[root@server1 conf]# vim nginx.conf
51 root html;
52 index index.php index.html index.htm; #在nginx里添加默认访问目录为php优先
50 location / {
53 }
75 location ~ \.php$ {
76 root html;
77 fastcgi_pass 127.0.0.1:9000;
78 fastcgi_index index.php;
79 fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
80 include fastcgi.conf; #设置成已存在的文件
81 }
[root@server1 conf]# nginx –t #检测
[root@server1 conf]# nginx #开启
4.搭建bbs论坛
[root@server1 html]# unzip /mnt/Discuz_X3.2_SC_UTF8.zip -d/usr/local/lnmp/nginx/html/ #解压Discuz包
[root@server1 html]# ls
50x.html index.html index.php readme upload utility
[root@server1 html]# mv upload/ bbs/ #给upload文件重命名
[root@server1 html]# ls
50x.html bbs index.html index.php readme utility
[root@server1 html]# chmod 777 -R bbs/ #修改权限
[root@server1 html]# mysql –p
Enter password:
mysql> grant all on discuz.* to Discuz@localhost identifiedby 'Red+hat888'; #创建能从论坛操作数据库的数据库用户
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> exit
Bye
[root@server1 html]# cd /usr/local/lnmp/mysql/
[root@server1 mysql]# chmod 755 data/
LNMP安装参考如下文章
Ubuntu 14.04 搭建 LNMP
Ubuntu 14.04 LTS 安装 LNMP Nginx\PHP5 (PHP-FPM)\MySQL