Linux
虚拟机
VMware:安装centos7_鲍海超-GNUBHCkalitarro的博客-CSDN博客
物理机
linux:真机安装centos linux(突发事件:解决卡在安装界面){寻找镜像--u启制作--引导u盘--解决卡在安装界面--安装配置}_安装centos7卡在安装界面_鲍海超-GNUBHCkalitarro的博客-CSDN博客
Nginx
Linux:nginx基础搭建(源码包)_鲍海超-GNUBHCkalitarro的博客-CSDN博客
mysql
首先安装环境 安装cmake
准备 cmake源码包 , mysql源码包、
yum -y install ncurses-devel perl* gcc-c++
tar zxvf /root/cmake-2.8.6.tar.gz -C /usr/src/
cd /usr/src/cmake-2.8.6
./configure &&gmake &&gmake install
安装mysql源码包
tar zxvf mysql-5.6.36.tar.gz -C /usr/src/
cd /usr/src/mysql-5.6.36/
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc
make &&make install
# 过程很慢
编译完后别退出目录
cp -f support-files/my-default.cnf /etc/my.cnf
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
echo "PATH=$PATH:/usr/local/mysql/bin" >>/etc/profile
source /etc/profile
groupadd mysql
useradd -M -s /sbin/nologin mysql -g mysql
chown -R mysql:mysql /usr/local/mysql
cd /usr/local/mysql/scripts/
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
/etc/rc.d/init.d/mysqld start
mysqladmin -u root password 123
PHP
yum -y install libxmlyum -y install libxml2-devel gd zlib-devel libjpeg-devel libpng-devel2-devel gd zlib-devel libjpeg-devel libpng-devel
tar xf php-5.5.38.tar.gz -C /usr/src
cd /usr/src/php-5.5.38/
./configure --prefix=/usr/local/php5 --with-gd --with-zlib --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-file-path=/usr/local/php5 --enable-mbstring --enable-fpm --with-jpeg-dir=/usr/lib
make && make install
编译安装完先别切换目录
cp php.ini-development /usr/local/php5/php.ini
ln -s /usr/local/php5/bin/* /usr/local/bin/
ln -s /usr/local/php5/sbin/* /usr/local/sbin/
安装ZendGuardLoader:
php加速加载模块,不需要可以跳过
tar xf zend-loader-php5.5-linux-x86_64_update1.tar.gz
cd zend-loader-php5.5-linux-x86_64
cp ZendGuardLoader.so /usr/local/php5/lib/php/
vim /usr/local/php5/php.ini
在最下面添加
zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so
zend_loader.enable=1
配置nginx支持php
cd /usr/local/php5/etc/
useradd -M -s /sbin/nologin php
vim php-fpm.conf
里面写入
[global]
pid = run/php-fpm.pid
[www]
listen = 127.0.0.1:9000
user = php
group = php
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
/usr/local/php5/sbin/php-fpm
#测试可以启动php-fpm
killall -9 php-fpm
# 关闭php-fpm
编写启动LNMP脚本
vi /etc/init.d/lnmp
写入
#!/bin/bash
# chkconfig: 35 95 30
# description: This script is for LNMP Management!
NGF=/usr/local/nginx/sbin/nginx
NGP=/usr/local/nginx/logs/nginx.pid
FPMF=/usr/local/php5/sbin/php-fpm
FPMP=/usr/local/php5/var/run/php-fpm.pid
case $1 in
start)
$NGF &&echo "nginx is starting! "
$FPMF && echo "php-fpm is starting! "
;;
stop)
kill -QUIT $(cat $NGP) &&echo "nginx is stoped! "
kill -QUIT $(cat $FPMP) &&echo "php-fpm is stoped! "
;;
restart)
$0 stop
$0 start
;;
reload)
kill -HUP $(cat $NGP)
kill -HUP $(cat $FPMP)
;;
status)
netstat -utpln |grep nginx &>/dev/null
if [ $? -eq 0 ]
then
echo "nginx is running! "
else
echo "nginx is not running! "
fi
netstat -upltn |grep php-fpm &>/dev/null
if [ $? -eq 0 ]
then
echo "php-fpm is runing! "
else
echo "php-fpm is not running! "
fi
;;
*)
echo "Usage $0 {start|stop|status|restart}"
exit 1
;;
esac
exit 0
chmod +x /etc/init.d/lnmp
chkconfig --add lnmp
systemctl start lnmp
# start | stop | restart
创建测试php网页
vim /usr/local/nginx/conf/nginx.conf
找到server模块在模块内写入
location ~ \.php$ {
root /usr/local/nginx/html/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
mkdir /usr/local/nginx/html/www
vim /usr/local/nginx/html/www/aaa.php
写入
<?php
$link=mysqli_connect('localhost','root','123');
if($link) echo "<h1>mysql connected success ! its ok !!</h1>";
mysqli_close($link);
?>
/etc/init.d/lnmp restart
重启成功
在Linux通过Nginx的服务连接到Mysql数据库使用的PHP访问成功