nginx+php7+mysql+wordpress搭建自己的博客网站
安装php7
这是通过源码安装的,也可以通过apt-get install php7来安装
1. tar zxvf php-7.1.13.tar.gz
2. cd php-7.1.13/
3. sudo mkdir /usr/local/php7
4. 进行配置,进入目录,输入
./configure --prefix=/usr/local/php7 \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--with-mysqli \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-gd-native-ttf \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip
- 安装依赖
sudo apt-get install libxslt1-dev
sudo apt-get install libxslt1.1
sudo apt-get install libfreetype6-dev
sudo apt-get install freetype2-demos
sudo apt-get install libpng*
sudo apt-get install openssl
sudo apt-get install libssl-dev
sudo apt-get install libxml2-dev
sudo apt-get install libxml2
- 编译
make - 安装
make install - 启动php服务
启动程序目录为
/usr/local/php7/sbin
配置文件目录为
/usr/local/php7/etc/
默认为配置文件为php.fpm.conf
需要拷贝两份default文件,进行重命名
sudo cp php-fpm.conf.default php-fpm.conf
sudo cp etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf
然后修改其中的user和group
sudo vi etc/php-fpm.d/www.conf
然后启动服务
sudo ./sbin/php-fpm
安装nginx
没有采用编译源码的方式,直接apt-get
1. sudo apt-get install nginx
2. 采用apt自动安装时,相关路径说明
/usr/sbin/nginx:主程序
/etc/nginx:存放配置文件
主配置文件为nginx.conf, 通过vi可以看到它include了conf.d文件夹和sites-enabled文件夹
/usr/share/nginx:存放静态文件
/var/log/nginx:存放日志
- 修改配置文件
sudo vi /etc/nginx/sites-enabled/default 应该为
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
- 修改文件权限的
sudo chmod 777 /usr/share/nginx/html/ - 重载配置文件
sudo nginx -c /etc/nginx/nginx.conf
nginx -s reload - 相关命令说明
重新启动
service nginx restart
显示端口占用
netstat -tln|grep 9000
显示进程
ps -aux|grep php-fpm
ps -ef
杀死进程
sudo kill *
安装mysql
也是两种方式,一种通过源码安装,一种通过apt-get进行整合
进入mysql数据库,创建wordpress数据库
mysql -uroot -p root
create database wordpress;mysql易错及参考
安装完mysql 之后,登陆以后,不管运行任何命令,总是提示这个
step 1: SET PASSWORD = PASSWORD(‘your new password’);
step 2: ALTER USER ‘root’@’localhost’ PASSWORD EXPIRE NEVER;
step 3: flush privileges;
安装WordPress
- 直接把WordPress的解压包放在/usr/share/nginx/html/下
- 打开浏览器,访问localhost,就能看到WordPress的安装程序
- 中途还需要sudo vi wp-config.php来写入一些东西,页面会提示