Nginx专题:LNMP之WordPress部署

创建MySQL用户及授权:

[root@lnmp tools]# cd /app/

[root@lnmp app]# ln -s mysql-5.6.47-linux-glibc2.12-x86_64/ /app/mysql

[root@lnmp tools]# useradd mysql -s /sbin/nologin -M

[root@lnmp mysql]# chown mysql.mysql /app/mysql/data/

初始化MySQL:

第一遍初始化报错,然后我把data目录下东西干掉后就好了。什么原理?

[root@lnmp mysql]# bin/mysqld --user=mysql --datadir=/app/mysql/data --basedir=/app/mysql

制作MySQL启动脚本:

[root@lnmp data]# cp /app/mysql/support-files/mysql.server /etc/init.d/mysqld

cp:是否覆盖"/etc/init.d/mysqld"? y

[root@lnmp mysql]# sed -ri ‘s#/usr/local#/app#g’ /etc/init.d/mysqld /app/mysql/bin/mysqld_safe

创建配置文件:

[root@lnmp mysql]# cp /app/mysql/support-files/my-default.cnf /etc/my.cnf

cp:是否覆盖"/etc/my.cnf"? y

启动MySQL:

[root@lnmp mysql]# /etc/init.d/mysqld restart

Shutting down MySQL… SUCCESS!

Starting MySQL. SUCCESS!

[root@lnmp mysql]# netstat -utpln | grep mysqld

tcp 0 0 :::3306 ::😗 LISTEN 17796/mysqld

设置环境变量:

[root@lnmp mysql]# echo ‘export PATH=/app/mysql/bin:$PATH’ >>/etc/profile

[root@lnmp mysql]# source /etc/profile

登录数据库:

因为初始密码为空,所以登录后要修改密码

[root@lnmp mysql]# mysql

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.6.47 MySQL Community Server (GPL)

Copyright © 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql>

[root@lnmp mysql]# mysqladmin -u root password ‘123123’

Warning: Using a password on the command line interface can be insecure.

[root@lnmp mysql]# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.6.47 MySQL Community Server (GPL)

Copyright © 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql>

安装PHP

==============================================================

下载PHP包及liblconv包:

[root@lnmp ~]# cd /server/tools/

[root@lnmp tools]# wget https://museum.php.net/php5/php-5.5.3.tar.gz

[root@lnmp tools]# wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz

安装依赖包:

[root@lnmp tools]# yum -y install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel

[root@lnmp tools]# yum -y install libiconv-devel freetype-devel libpng-devel gd-devel

[root@lnmp tools]# yum -y install libcurl-devel libxslt-devel

[root@lnmp tools]# yum -y install libmcrypt-devel mhash mcrypt

编译安装语言转换工具:

[root@lnmp tools]# tar xf libiconv-1.16.tar.gz

[root@lnmp tools]# cd libiconv-1.16

[root@lnmp libiconv-1.16]# ./configure --prefix=/usr/local/libiconv

[root@lnmp libiconv-1.16]# make && make install

解压PHP包进行预编译:

[root@lnmp libiconv-1.16]# cd /server/tools/

[root@lnmp tools]# tar xf php-5.5.3.tar.gz

[root@lnmp tools]# cd php-5.5.3

[root@lnmp php-5.5.3]# mkdir -p /app/php-5.5.3

[root@lnmp php-5.5.3]# ./configure --prefix=/app/php-5.5.3 --with-mysql --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --enable-short-tags --enable-static --with-xsl --with-fpm-user=www --with-fpm-group=www --enable-ftp --enable-opcache=no

[root@lnmp php-5.5.3]# echo $?

0

防报错处理:

[root@lnmp php-5.5.3]# ln -s /app/mysql/lib/libmysqlclient.so.18 /usr/lib64/

[root@lnmp php-5.5.3]# touch ext/phar/phar.phar

编译安装PHP:

[root@lnmp php-5.5.3]# make && make install

[root@lnmp php-5.5.3]# echo $?

0

[root@lnmp php-5.5.3]# cp php.ini-production /app/php-5.5.3/lib/

[root@lnmp php-5.5.3]# ln -s /app/php-5.5.3/ /app/php

[root@lnmp php-5.5.3]# cd /app/php/etc/

[root@lnmp etc]# ll

总用量 28

-rw-r–r-- 1 root root 1152 8月 25 06:39 pear.conf

-rw-r–r-- 1 root root 21846 8月 25 06:39 php-fpm.conf.default

[root@lnmp etc]# cp php-fpm.conf.default php-fpm.conf

[root@lnmp etc]# vim php-fpm.conf

listen = 172.16.1.30:9000

启动PHP:

[root@lnmp etc]# useradd -s /sbin/nologin -M www

[root@lnmp etc]# /app/php/sbin/php-fpm

[root@lnmp etc]# netstat -utpln | grep php

tcp 0 0 172.16.1.30:9000 0.0.0.0:* LISTEN 39741/php-fpm

修改Nginx配置文件

====================================================================

[root@lnmp etc]# cd /app/nginx/conf/

[root@lnmp conf]# cp nginx.conf nginx.conf.bak

[root@lnmp conf]# grep -Ev “#|^$” nginx.conf.default >nginx.conf

[root@lnmp conf]# vim nginx.conf

[root@lnmp conf]# cat nginx.conf

worker_processes 1;

events {

worker_connections 1024;

}

http {

include mime.types;

default_type application/octet-stream;

sendfile on;

keepalive_timeout 65;

server {

listen 80;

server_name 192.168.1.30;

location / {

root html/www;

index index.html index.htm index.php;

location ~* .*.(php|php5)?$ {

fastcgi_pass 172.16.1.30:9000;

fastcgi_index index.php;

include fastcgi.conf;

}

}

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

}

}

[root@lnmp conf]# /app/nginx/sbin/nginx -t

nginx: the configuration file /app/nginx-1.12.2//conf/nginx.conf syntax is ok

nginx: configuration file /app/nginx-1.12.2//conf/nginx.conf test is successful

重新启动Nginx服务:

[root@lnmp etc]# /app/nginx/sbin/nginx -s reload

测试:

[root@lnmp etc]# cd /app/nginx/html/

[root@lnmp html]# ls

50x.html index.html

[root@lnmp html]# vim test_php.php

[root@lnmp html]# cat test_php.php

<?php phpinfo(); ?>

独家面经总结,超级精彩

本人面试腾讯,阿里,百度等企业总结下来的面试经历,都是真实的,分享给大家!

image

image

image

image

Java面试准备

准确的说这里又分为两部分:

  1. Java刷题
  2. 算法刷题

Java刷题:此份文档详细记录了千道面试题与详解;

image

image

]# vim test_php.php

[root@lnmp html]# cat test_php.php

<?php phpinfo(); ?>

独家面经总结,超级精彩

本人面试腾讯,阿里,百度等企业总结下来的面试经历,都是真实的,分享给大家!

[外链图片转存中…(img-pARZ2fAy-1721150471221)]

[外链图片转存中…(img-YBzpN1P2-1721150471222)]

[外链图片转存中…(img-d23GR3ML-1721150471223)]

[外链图片转存中…(img-TiuCPusv-1721150471223)]

Java面试准备

准确的说这里又分为两部分:

  1. Java刷题
  2. 算法刷题

Java刷题:此份文档详细记录了千道面试题与详解;

[外链图片转存中…(img-bWmEkwEM-1721150471224)]

[外链图片转存中…(img-ofCrY5lO-1721150471224)]

  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值