環(huán)境包括:nginx php mysql
yum源更新:yum -y update
yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel gcc gcc++ autoconf
icu libicu libicu-devel openldap openldap-develgcc-c++
nginx安裝流程
下載安裝包:wget https://nginx.org/download/nginx-1.16.0.tar.gz
解壓:tar zxvf nginx-1.16.0.tar.gz
添加nginx組诺苹,用戶:
[root@n1 nginx-1.14.2]# groupadd nginx
[root@n1 nginx-1.14.2]# useradd nginx -g nginx -s /sbin/nologin -M
對(duì)nginx進(jìn)行配置: ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/config/nginx.conf --error-log-path=/usr/local/nginx/logs/error.log --pid-path=/usr/local/nginx/logs/nginx.pid --http-log-path=/usr/local/nginx/logs/access.log --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module 【https://www.cnblogs.com/flashfish/p/11025961.html(有關(guān)編譯的說明)】
原文鏈接:https://blog.csdn.net/weixin_41114593/article/details/82285604
編譯安裝:make && make install
其他用法:
1.nginx -t 【檢查配置文件語法是否正確】
2.nginx -v【查看nginx版本號(hào)】
安裝后配置
$ vim /etc/profile.d/nginx.sh
export PATH=/usr/local/nginx/sbin:$PATH
$ source /etc/profile.d/nginx.sh
啟動(dòng)/停止/重載/
啟動(dòng):nginx
停止:nginx -s stop
重載:nginx -s reload
php7安裝流程
下載安裝包:wget https://www.php.net/distributions/php-7.3.10.tar.gz
解壓:tar zxvf php-7.3.10.tar.gz
創(chuàng)建用戶和組
1.[root@cloudhost ~]# groupadd www-data
2.[root@cloudhost ~]# useradd -g www-data www-data
對(duì)php進(jìn)行配置:./configure --prefix=/export/lnmp/php7 \
--with-config-file-path=/export/lnmp/php7/etc \
--with-fpm-user=www-data \
--with-fpm-group=www-data \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-sqlite3 \
--with-libxml-dir \
--with-ldap=shared \
--with-gdbm \
--with-pear \
--with-gettext \
--with-curl \
--with-xmlrpc \
--with-openssl \
--with-mhash \
--with-gd \
--with-pcre-regex \
--enable-fpm \
--enable-mysqlnd \
--enable-mysqlnd-compression-support \
--enable-xml \
--enable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--disable-debug \
--enable-mbregex \
--enable-mbstring \
--enable-intl \
--enable-ftp \
--enable-gd-jis-conv \
--enable-pcntl \
--enable-sockets \
--enable-zip \
--enable-soap \
--with-bz2 \
--enable-fileinfo \
--enable-opcache \
--with-iconv \
--with-cdb \
--enable-calendar \
--enable-maintainer-zts \
--enable-dom \
--enable-exif \
--enable-filter \
--with-gmp \
--enable-json \
--enable-mbregex-backtrack \
--with-onig \
--with-readline \
--enable-session \
--enable-simplexml \
--enable-sysvmsg \
--enable-sysvshm \
--enable-wddx \
--with-xsl \
--with-pear
【https://blog.csdn.net/ZHANG_TIMI/article/details/99410608】
編譯安裝:make && make install
配置php.ini文件
具體的路徑裆操,大家可自行修改炉媒。cd
1.cp php.ini-development /data/nmp/php/etc/php.ini
2.cp /data/nmp/php/etc/php-fpm.conf.default /data/nmp/php/etc/php-fpm.conf
3.cp /data/nmp/php/etc/php-fpm.d/www.conf.default /data/nmp/php/etc/php-fpm.d/www.conf
4.cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
配置php.ini文件
max_execution_time = 120
max_input_time = 120
memory_limit = 1024M
post_max_size = 128M
date.timezone = PRC
extension_dir = "/data/nmp/php/lib/php/extensions/no-debug-zts-20180731"
問題1:configure: error: DBA: Could not find necessary header file(s).
解決辦法:yum install gdbm-devel
問題2:configure: error: Cannot find ldap libraries in /usr/lib
解決辦法:cp -frp /usr/lib64/libldap* /usr/lib/
問題2:configure: error: Cannot find ldap libraries in /usr/lib
解決辦法:
1.wget https://libzip.org/download/libzip-1.5.2.tar.gz【https://libzip.org/download/ 下載源碼】
2.tar zxvf libzip-1.5.2.tar.gz
3.cd libzip-1.5.2
4.mkdir build && cd build && cmake .. && make && make install
問題3:CMake 3.0.2 or higher is required. You are running version 2.8.12.2
解決辦法:
1.先刪除原有cmake? yum remove cmake 【yum install gcc-c++】
2.wget https://github.com/Kitware/CMake/releases/download/v3.16.0-rc2/cmake-3.16.0-rc2.tar.gz【https://cmake.org/download/ 下載源碼】
3.tar zxvf cmake-3.16.0-rc2.tar.gz
4.cd cmake-3.16.0-rc2
5../bootstrap && make && make install
6.ln -s /usr/local/bin/cmake /usr/bin/cmake{具體看是不是這個(gè)目錄}執(zhí)行目錄【/usr/local/bin】
問題4:error: off_t undefined; check your library configuration
解決辦法:
# 添加搜索路徑到配置文件
echo '/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64'>>/etc/ld.so.conf
# 更新配置
ldconfig -v
一些常見的php問題解決方法 -? 包含上面的問題【https://www.cnblogs.com/jkko123/p/10790427.html】
mysql8安裝流程
下載安裝包:wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-boost-8.0.16.tar.gz
解壓:tar zxvf php-7.3.10.tar.gz
【升級(jí)Gcc-(https://www.cnblogs.com/NanZhiHan/p/11010130.html)】
1吊骤、下載源碼包
wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-9.2.0/gcc-9.2.0.tar.gz
wget http://mirrors.nju.edu.cn/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.gz
ftp://gcc.gnu.org/pub/gcc/infrastructure/
2、進(jìn)入gcc目錄白粉,安裝gcc依賴庫
cd gcc
./contrib/download_prerequisites
執(zhí)行命令后它會(huì)自動(dòng)下載mpfr传泊、gmp、mpc isl這4個(gè)庫
問題1:如果執(zhí)行報(bào)錯(cuò):tar (child): lbzip2: no exec: no file or directory
解決方法:安裝解壓軟件即可
yum -y install bzip2
3蜗元、在新目錄中配置或渤、編譯、安裝
mkdir build
cd build
../configure --prefix=/usr/local/gcc --enable-languages=c,c++ --disable-multilib
make
make install
mv /usr/bin/gcc /usr/bin/gcc_old
ln -s /usr/local/gcc/bin/gcc /usr/bin/gcc
mv /usr/bin/g++ /usr/bin/g++_old
ln -s /usr/local/gcc/bin/g++ /usr/bin/g++
gcc --verson
g++ --version
http://www.reibang.com/p/df8e82ade760--version `CXXABI_1.3.9' not found
編譯程序
mkdir bld
cd bld
cmake ../ -DCMAKE_INSTALL_PREFIX=/export/lnmp/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DSYSCONFDIR=/etc \
-DWITH_EXTRA_CHARSETS=all \
-DMYSQL_DATADIR=/export/lnmp/mysql/data \
-DWITH_BOOST=/export/installp/mysql-8.0.16/boost \
-DFORCE_INSOURCE_BUILD=1 \
-DCMAKE_CXX_COMPILER=/usr/local/gcc/bin/g++ \
-DDEFAULT_CHARSET=utf8
make
make install
創(chuàng)建數(shù)據(jù)庫用戶
useradd -s /sbin/nologin mysql
創(chuàng)建數(shù)據(jù)存放目錄并修改權(quán)限
mkdir /usr/local/mysql/data
chown -R mysql:mysql /usr/local/mysql
修改配置文件(根據(jù)自己的情況來配置)
[mysqld]
port=3306
server-id=1
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
[client]
socket=/usr/local/mysql/mysql.sock
初始化數(shù)據(jù)庫并安裝ssl
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/database/? --log-error=/usr/local/mysql/log/mysqld.log
# /usr/local/mysql/bin/mysql_install_db? ? //安裝命令
--initialize? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //生成默認(rèn)密碼?
--user=mysql? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //指定mysql用戶
--basedir=/usr/local/mysql/? ? ? ? ? ? ? ? ? ? ? //安裝目錄
--datadir=/usr/local/mysql/database/? ? ? ? ? ? ? ? // 數(shù)據(jù)庫目錄
--log-error=/usr/local/mysql/log/mysqld.log? ? // 指定日志文件奕扣,安裝過程中數(shù)據(jù)庫生成的初
/usr/local/mysql/bin/mysql_ssl_rsa_setup
復(fù)制啟動(dòng)腳本、啟動(dòng)
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
/etc/init.d/mysqld? start
修改mysql密碼(忘記密碼)
9.1在配置文件中的[mysqld]下加入skip-grant-tables
vim /etc/my.cnf
? ? ? [mysqld]
? ? ? skip-grant-tables
9.2重啟mysql
/etc/init.d/mysqld restart
9.3登錄數(shù)據(jù)庫后掌敬,修改密碼為空惯豆。
mysql
? ? mysql >use mysql;
? ? mysql >update user set authentication_string="" where user='root';
? ? mysql >flush privileges;
? ? mysql > exit;
9.4在配置文件中刪除skip-grant-tables并重啟mysql
/etc/init.d/mysqld restart
9.5登錄mysql,修改密碼
mysql -uroot -p
? ? mysql>ALTER user 'root'@'localhost' IDENTIFIED BY 'tengxun@123';密碼要復(fù)雜點(diǎn)}
? ? mysql>flush provoleges;
? ? mysql>exit;
更改加密方式和更新用戶密碼
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; #修改加密規(guī)則
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';? #更新一下用戶的密碼