一.关闭防火墙和SElinuxphp
systemctl stop firewalld.service setenforce 0
二.建立/data/server用于存放解析后的文件:html
mkdir /data/server
三.源码安装nginx
下载NGINX并解压:mysql
wget http://nginx.org/download/nginx-1.16.0.tar.gz
下载依赖包:linux
yum install openssl openssl-devel zlib zlib-devel pcre pcre-devel gcc gcc-c++ -y
进到目录下:nginx
cd /usr/local/src/nginx-1.16.0
编译安装:c++
./configure --prefix=/data/server/nginx #(编译安装的路径,将服务都放在/data/server下) make && nake install
进到编译好的NGINX下,启动NGINXgit
cd /data/server/nginx/sbin ./nginx
查看本身IPsql
ifconfig
在浏览器中输入查到的IP
NGINX编译完成数据库
四.源码安装mysql
下载源码包
解压vim
unzip AliSQL-AliSQL-5.6.32-9.zip
下载依赖环境包:
yum -y install cmake bison git ncurses-devel gcc gcc-c++
添加用户:
groupadd mysql
useradd -g mysql mysql
安装perl而后解压:
wget http://repo.openfusion.net/centos7-x86_64//perl-Data-Dumper-2.154-1.of.el7.x86_64.rpm rpm -ivh http://repo.openfusion.net/centos7-x86_64//perl-Data-Dumper-2.154-1.of.el7.x86_64.rpm
进到解压好的目录中
cd AliSQL-AliSQL-5.6.32-9/
而后进行编译安装:
cmake -DCMAKE_INSTALL_PREFIX=/data/server/mysql -DMYSQL_UNIX_ADDR=/data/server/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/data/server/mysql/data -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DENABLE_DOWNLOADS=1 make && make install
修改目录主权限:
chown -R mysql:mysql /data/server/mysql
复制文件给权限:
cd /data/server/mysql cp support-files/my-default.cnf ./my.cnf chown -R mysql:mysql my.cnf
配置文件
vim my.cnf
basedir = /data/server/mysql datadir = /data/server/mysql/data socket = /data/server/mysql/mysql.sock log-error= /data/server/mysql/data/error.log pid-file = /data/server/mysql/data/mysql.pid user = mysql tmpdir = /tmp
数据库初始化
scripts/mysql_install_db --defaults-file=./my.cnf --user=mysql
启动数据库
support-files/mysql.server start
启动数据库报错PID解决办法:
rm -rf /etc/my.cnf rm -rf my.conf cd data rm -rf * cd .. scripts/mysql_install_db --defaults-file=./my.cnf --user=mysql cd support-files/ ./mysql.server start cd .. cd bin
从新启动数据库:
./mysql -uroot -p
建立数据库:
>create database wordpress; >grant all on wordpress.* to wordpress@'localhost' identified by'123456'; >flush privileges; >exit
mysql安装完毕。
五.源码安装PHP:
添加用户:
groupadd www useradd -g www -s /sbin/nologin -M www
安装依赖的程序包:
yum install zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel openssl openssl-devel libxslt-devel -y
安装 libiconv,解压:
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz tar zxf libiconv-1.15.tar.gz
进入到libiconf文件下
cd libiconv-1.15
编译libiconv
./configure --prefix=/data/server/libiconv make && make install
下载并解压PHP:
tar -zxvf php-5.6.32.tar.gz
进到php-5.6.30文件下
cd /data/server/php-5.6.30
编译
./configure \ --prefix=/data/server/php \ --enable-fpm \ --with-mysql=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-mysqli=mysqlnd \ --with-openssl \ --with-zlib \ --with-gd \ --with-jpeg-dir \ --with-png-dir \ --with-iconv=/data/server/libiconv \ --enable-short-tags \ --enable-sockets \ --enable-zend-multibyte \ --enable-soap \ --enable-mbstring \ --enable-static \ --with-curl \ --enable-ftp \ --with-libxml-dir
make && make install
php.ini配置
cp php.ini-development /data/server/php/lib/php.ini
php-fpm配置:
cp -R ./sapi/fpm/php-fpm.conf /data/server/php/etc/php-fpm.conf
将php给咱们准备好的init.d.php-fpm备份
cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
将php-fpm服务添加到chkconfig列表
chkconfig --add php-fpm
设置开机自启动
chkconfig php-fpm on
启动服务
service php-fpm start
在这里会报错:Permission Denied
vim /etc/profile #(在末尾加) PATH=$PATH:$HOME/bin:/data/server/php56/bin
source /etc/profile #(使环境生效)
设置开机自启动
chkconfig --add php-fpm
加权限
chkconfig php-fpm on
启动php-fpm
service php-fpm start
更改配置文件:
vim /data/server/nginx/conf/nginx.conf
将user 前面注释去掉 并将nobady改为www www
在server/location模块下的index栏下 加一个 index.php
 将location ~ \.php$ 模块注释去掉 并/scripts改为$document_root
去到html目录下
cd /data/server/nginx/html
添加test.php文件
vim test.php
<?php phpinfo() ; ?
进到nginx运行目录
cd /data/server/nginx/sbin
重读nginx
./nginx -s reload
在浏览器里输入 ip/test.php
PHP搭建完毕
六.搭建 wordpress
下载wordpress并解压
wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz
tar -zxvf wordpress-4.9.4-zh_CN.tar.gz
将wordpress文件复制到网页目录下
cp -r wordpress /data/server/nginx/html
修改Wordpress配置文件
cd /data/server/nginx/html/wordpress
拷贝配置文件
cp -r wp-config-sample.php wp-config.php
修改wp-config.php
vim wp-config.php
在其中修改
数据库名字、帐号、密码(这里修改的是mysql中建立的数据库名字、用户、密码)
再将主机改为127.0.0.1(设置本身能够访问)