php7.1 + nginx1.14+mysql5.5 + CentOS6.8 lnmp自定义搭建

php7.1 + nginx1.14+mysql5.5 + CentOS6.8自定义搭建

Yum更新:

	一、配置CentOS 第三方yum源(CentOS默认的标准源里没有nginx软件包)
		#安装下载工具wget
		yum install wget 
		#下载atomic yum源
		wget http://www.atomicorp.com/installers/atomic  
		#安装
		sh ./atomic  
		#更新yum软件包
		yum check-update

nginx安装

yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel
安装nginx
yum install nginx -y
开启
service nginx start
#设置 开机启动
chkconfig --levels 235 nginx on  

mysql安装

1.新开的云服务器,需要检测系统是否自带安装mysql

# yum list installed | grep mysql
2.如果发现有系统自带mysql,果断这么干

# yum -y remove mysql-libs.x86_64
3.随便在你存放文件的目录下执行,这里解释一下,由于这个mysql的yum源服务器在国外,所以下载速度会比较慢,还好mysql5.6只有79M大,而mysql5.7就有182M了,所以这是我不想安装mysql5.7的原因

# wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
4.接着执行这句,解释一下,这个rpm还不是mysql的安装文件,只是两个yum源文件,执行后,在/etc/yum.repos.d/ 这个目录下多出mysql-community-source.repo和mysql-community.repo

# rpm -ivh mysql-community-release-el6-5.noarch.rpm
5.这个时候,可以用yum repolist mysql这个命令查看一下是否已经有mysql可安装文件

#yum repolist all | grep mysql
6.安装mysql 服务器命令(一路yes):

# yum install mysql-community-server
7.安装成功后

# service mysqld start
8.由于mysql刚刚安装完的时候,mysql的root用户的密码默认是空的,所以我们需要及时用mysql的root用户登录(第一次回车键,不用输入密码),并修改密码

# mysql -u root
# use mysql;
# update user set password=PASSWORD("这里输入root用户密码") where User='root';
# flush privileges; 
9.查看mysql是否自启动,并且设置开启自启动命令

 
# chkconfig --list | grep mysqld
# chkconfig mysqld on

10.mysql安全设置(系统会一路问你几个问题,看不懂复制之后翻译,基本上一路yes):
# mysql_secure_installation

php安装

下载源码包  (容易下载失败,如果失败  直接把**下下**方的链接 复制到浏览器端下载,手动ftp上传到服务器端/usr/local/src)
	wget -c http://cn2.php.net/distributions/php-7.1.3.tar.gz
下载失败 或者是解压报错 直接把**下**方的链接 复制到浏览器端下载,手动ftp上传到服务器端/usr/local/src
手动下载 ftp上传
	http://cn2.php.net/distributions/php-7.1.3.tar.gz
	tar -xzvf php-7.1.3.tar.gz
	cd php-7.1.3
安装php7需要的一些依赖库包 libxml2和一些其他依赖的扩展库
	yum -y install libxml2 
	yum -y install libxml2-devel 
	yum -y install openssl 
	yum -y install openssl-devel 
	yum -y install curl-devel 
	yum -y install libjpeg-devel 
	yum -y install libpng-devel 
	yum -y install freetype-devel
	yum -y install bzip2-devel
	yum -y install libmcrypt libmcrypt-devel
	yum -y install postgresql-devel
	yum -y install aspell-devel
	yum -y install readline-devel
	yum -y install libxslt-devel
	yum -y install net-snmp-devel
	yum -y install unixODBC-devel
	yum -y install libicu-devel
	yum -y install libc-client-devel
	yum -y install libXpm-devel
	yum -y install libvpx-devel
	yum -y install enchant-devel
	yum -y install openldap
	yum -y install openldap-devel
	yum -y install db4-devel
	yum -y install gmp-devel
	yum -y install sqlite-devel
	yum -y install mysql-devel
先创建运行php的用户以及组
	groupadd -r www && useradd -r -g www -s /sbin/nologin
config配置安装
./configure      --prefix=/usr/local/php    --with-config-file-path=/usr/local/php/etc    --enable-fpm    --with-fpm-user=www    --with-fpm-group=www    --enable-inline-optimization    --disable-debug    --disable-rpath    --enable-shared    --enable-soap    --with-xmlrpc    --with-openssl    --with-mcrypt    --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-freetype-dir    --enable-gd-native-ttf    --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
编译
	make && make install
查看php版本
	/usr/local/php/bin/php -v
运行php-fpm
	/usr/local/php/sbin/php-fpm
运行php-fpm 报错
	 ERROR: failed to open configuration file '/usr/local/php/etc/php-fpm.conf': No such file or directory (2)
	[13-May-2019 12:50:05] ERROR: failed to load configuration file '/usr/local/php/etc/php-fpm.conf'
	[13-May-2019 12:50:05] ERROR: FPM initialization failed
解决方法
	WARNING: Nothing  matches the include pattern /usr/local/php/etc/php-fpm.d/*.conf),需要把/usr/local/php/etc/php-fpm.d/*.conf目录中的www.conf.default重名名为www.conf。
	缺少php-fpm.conf配置文件 需要在/usr/local/php/etc/php-fpm.conf 把默认的配置文件php-fpm.conf.default改成php-fpm.conf
	安装php和所需组件使PHP支持MySQL、FastCGI模式
安装
	yum install  php-tidy php-common php-devel php-fpm php-mysql -y
	php从新加载
	service php-fpm restart
	开机启动
	chkconfig --levels 235 php-fpm on
配置nginx支持php
	cp /etc/nginx/nginx.conf{,.bak}  #

增加这一段代码
	location ~ \.php$ {
        root           /usr/share/nginx/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name;
        include        fastcgi_params;
    }
重启nginx  重启php
这里就结束了 但是还要测试一下  nginx是否支持了php
和php是否能链接上mysql,这些都是要进行测试。祝大家硬起来

你可能感兴趣的:(lnmp环境搭建)