yum -y install gcc gcc-c++ autoconf automake make zlib-devel pcre-devel -y
wget http://nginx.org/download/nginx-1.17.0.tar.gz
tar -zxvf nginx-1.17.0.tar.gz
cd nginx-1.17.0
./configure --prefix=/usr/local/nginx
make && make install
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
nginx -h
nginx
# /etc/local/nginx/conf/nginx.conf
server {
listen 80;
server_name localhost;
location / {
root html;
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $DOCUMENT_ROOT$fastcgi_script_name;
include fastcgi_params;
}
...
}
ln -s /usr/local/nginx/html ~
wget https://www.php.net/distributions/php-7.3.4.tar.gz
tar -zxvf php-7.3.4.tar.gz
cd php-7.3.4
yum groupinstall "Development Tools" -y
yum --enablerepo=epel install bzip2-devel curl-devel libjpeg-turbo-devel libpng-devel libicu-devel libmcrypt-devel libxml2-devel freetype-devel -y
yum install libxslt-devel* -y
yum install openssl openssl-devel -y
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/etc/conf.d --enable-bcmath --with-bz2 --with-curl --enable-filter --enable-fpm --with-gd --enable-intl --enable-mbstring --enable-mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --disable-phpdbg --disable-phpdbg-webhelper --enable-opcache --with-openssl --enable-simplexml --enable-xmlreader --enable-xmlwriter --enable-zip --with-zlib --enable-soap --enable-shmop --enable-sockets --enable-sysvmsg --with-openssl-dir=/usr/local/ssl --with-jpeg-dir=/usr/lib64 --with-freetype-dir --with-gettext
或者精简点 (推荐)
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-curl --enable-filter --enable-fpm --with-gd –with-jpeg-dir --enable-intl --enable-mbstring --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --enable-simplexml --with-zlib --enable-sockets --disable-fileinfo
make
make install
cp php.ini-development /usr/local/php/lib/php.ini
cp sapi/fpm/www.conf /usr/local/php/etc/php-fpm.d/www.conf
cp sapi/fpm/php-fpm.conf /usr/local/php/etc/php–fpm.conf
#### 2.6 配置php-fpm服务
1. 修改php-fpm.conf的pid
vim /usr/local/php/etc/php-fpm.conf
取消pid前面的注释
pid = run/php-fpm.pid
2. 复制文件并增加执行权限
cp sapi/fpm/init.d.php-fpm.in /etc/init.d/php-fpm
3. 修改 /etc/init.d/php-fpm
文件
把路径改成绝对路径
php_fpm_BIN=/usr/local/php/sbin/php-fpm
php_fpm_CONF=/usr/local/php/etc/php-fpm.conf
php_fpm_PID=/usr/local/php/var/run/php-fpm.pid
4. 启动
chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
5. 搞定!!
service php-fpm stop |start | restart
yum install libaio-devel ncurses-devel cmake gcc gcc-c++ bison -y
# 下载
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
# 校验校验码
md5sum mysql57-community-release-el7-9.noarch.rpm
# 安装
sudo rpm -ivh mysql57-community-release-el7-9.noarch.rpm
sudo yum install mysql-server
sudo systemctl start mysqld
sudo systemctl status mysqld
Note: MySQL is automatically enabled to start at boot when it is installed. You can change that default behavior with sudo systemctl disable mysqld
sudo grep 'temporary password' /var/log/mysqld.log
# 2018-06-28T07:07:04.914495Z 1 [Note] A temporary password is generated for root@localhost: XTk;w145PkgT
mysql -uroot -p XTk;w145PkgT
show variables like "%password%";
set global validate_password_length=0;
set global validate_password_policy=low;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
exit;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'yangxin'@'%' IDENTIFIED BY 'Yangxin0917!' WITH GRANT OPTION;
修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如下所示:
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
重新启动mysql服务,查看数据库默认编码如下所示:
php文件提示错误,提示信息如下:
nginx: connect() failed (111: Connection refused) while connecting to upstream....
解决办法:
/usr/local/php/etc/php-fpm.d/www.conf
取消以下这行当注释listen.allowed_clients = 127.0.0.1
2. 重启nginx和php-fpm 即可
php编译文件提示错误:configure: error: Please reinstall the libzip distribution
解决办法:
安装 libzip支持即可
wget https://nih.at/libzip/libzip-1.2.0.tar.gz
tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure
make -j4 && make install
php编译文件提示错误:error: Package requirements (sqlite3 > 3.7.4) were not met
解决办法:
yum install libsqlite3x-devel -y
php编译文件提示错误: error: Package requirements (oniguruma) were not met
解决办法:
yum install oniguruma-devel -y
/www/server/php/74/sbin/php-fpm: error while loading shared libraries: libonig.so.2: cannot open shared object file: No such file or directory
解决办法:
ln -s /usr/lib64/libonig.so /usr/lib64/libonig.so.2