目录
1、安装Nginx
2、安装Mysql
3、编译安装php7.2
4、配置nginx
1.1安装nginx源
yum localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
1.2安装nginx
yum install nginx
1.3启动nginx
service nginx start
1.4 访问http://你的ip/
遇到了访问被拒绝,因为端口没有开放,开启端口号重新访问成功
firewall-cmd --zone=public --add-port=80/tcp --permanent
开启之后重启下防火墙:firewall-cmd --reload
2.1安装mysql源
yum localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
2.2安装mysql
yum install mysql-community-server
安装下mysqk开发包:
yum install mysql-community-devel
2.3启动mysql
service mysqld start
2.4查看mysql启动状态
service mysqld status
2.5修改默认密码
1、首先获取默认密码:
grep 'temporary password' /var/log/mysqld.log
用默认密码登陆mysql,然后修改密码 注意:密码一定要包含字母、数字、符号
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Hzswh557@'; FLUSH PRIVILEGES; #刷新数据库 mysql可以被所有客户端访问设置方法: 1、use mysql 2、 update user set host = '%' where user = 'root'; 4、flush privileges;
3.1:下载php包
在官网下载7.2的压缩包,然后上传到服务器,
http://am1.php.net/distributions/php-7.2.13.tar.gz
3.2解压源码包
tar -xvf php-7.2.13.tar.gz
cd ./php-7.2.13
3.3 安装php依赖包 AND 编译
1、
#Yum 安装依赖包
yum -y install wget vim pcre pcre-devel openssl openssl-devel libicu-devel gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses ncurses-devel curl curl-devel krb5-devel libidn libidn-devel openldap openldap-devel nss_ldap jemalloc-devel cmake boost-devel bison automake libevent libevent-devel gd gd-devel libtool* libmcrypt libmcrypt-devel mcrypt mhash libxslt libxslt-devel readline readline-devel gmp gmp-devel libcurl libcurl-devel openjpeg-devel bzip2 bzip2-devel
2、编译
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/etc \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-soap \
--with-libxml-dir \
--with-xmlrpc \
--with-openssl \
--with-mhash \
--with-pcre-regex \
--with-sqlite3 \
--with-zlib \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--with-cdb \
--enable-dom \
--enable-exif \
--enable-fileinfo \
--enable-filter \
--with-pcre-dir \
--enable-ftp \
--with-gd \
--with-openssl-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-freetype-dir \
--enable-gd-jis-conv \
--with-gettext \
--with-gmp \
--with-mhash \
--enable-json \
--enable-mbstring \
--enable-mbregex \
--enable-mbregex-backtrack \
--with-libmbfl \
--with-onig \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-zlib-dir \
--with-pdo-sqlite \
--with-readline \
--enable-session \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-libxml-dir \
--with-xsl \
--enable-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-opcache \
--disable-fileinfo
make && make install
3.4 配置环境变量:
上一步等待完成之后配置环境变量
vim /etc/profile
在末尾加入
PATH=$PATH:/usr/local/php/bin
export PATH
要使改动立即生效执行
# source /etc/profile
查看环境变量
# echo $PATH
查看php版本
# php -v
3.5配置php-fpm
# cp php.ini-production /etc/php.ini
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# chmod +x /etc/init.d/php-fpm启动php-fpm: /etc/init.d/php-fpm start
4.1、配置nginx
修改 /etc/nginx/conf.d/default.conf
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
5.1 常用命令
nginx 重启 :service nginx reload
启动php-fpm:/etc/init.d/php-fpm start
重启php-fpm: /etc/init.d/php-fpm restart
启动mysql:service mysqld start