1、 操作系统
CentOS release 6.5(final)
2、 安装mysql
# yum install mysql-server
#vi /etc/my.cnf +default-character-set=utf8
#chkconfig --add mysqld chkconfig --level 35 mysqld on//开机启动 查看#chkconfig --list | grep mysql*
#service mysqld stop //停止restart//重启 start//启动
#mysqladmin -u root password 123456 //设置管理员密码
#UPDATE user SET `Host` = '%' WHERE `User` = 'root' LIMIT 1;FLUSH PRIVILEGES;//所有主机root连接
#vi /etc/sysconfig/iptables
增加:-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
#service iptables restart
3、 安装nginx
先安装nginx的yum源
http://nginx.org/en/linux_packages.html#stable 找到链接,安装:
#rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
查看:
#yum info nginx
安装:
#yum install nginx
#service nginx start
默认配置:/etc/nginx/conf.d/
4、 安装php
#wget http://cn2.php.net/get/php-5.6.23.tar.gz/from/this/mirror
#tar –zxvf php-5.6.23.tar.gz
#yum install epel-release
或者
#rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
#yum install gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel sqlite-devel libpng-devel
#cd php-5.6.23
#./configure \
--prefix=/usr/local/php56 \
--with-config-file-path=/usr/local/php56/etc \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-opcache \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-gettext \
--enable-mbstring \
--with-iconv \
--with-mcrypt \
--with-mhash \
--with-openssl \
--enable-bcmath \
--enable-soap \
--with-libxml-dir \
--enable-pcntl \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-sockets \
--with-curl \
--with-zlib \
--enable-zip \
--with-bz2 \
--with-gd \
--with-freetype \
--with-readline
#make -j8
#make install
配置 PHP
配置文件:
# cp php.ini-development /usr/local/php56/etc/php.ini
php-fpm 服务
# cp /usr/local/php56/etc/php-fpm.conf.default /usr/local/php56/etc/php-fpm.conf
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm56
# chmod +x /etc/init.d/php-fpm56
启动 php-fpm
# service php-fpm56 start
Starting php-fpm done
php-fpm 可用参数 start|stop|force-quit|restart|reload|status
添加 PHP 命令到环境变量
编辑 ~/.bash_profile,将:
PATH=$PATH:$HOME/bin
改为:
PATH=$PATH:$HOME/bin:/usr/local/php56/bin
使 PHP 环境变量生效:
# . ~/.bash_profile
查看看 PHP 版本
# php -v