赞
踩
本文介绍的安装各软件版本如下:
| 软件 | 版本 | 下载地址 |
|---|---|---|
| Nginx | 1.14.0 | http://nginx.org/download/nginx-1.14.0.tar.gz |
| PHP | 7.2.5 | http://cn2.php.net/downloads.php/php-7.2.5.tar.gz |
| MySQL | 8.0.17 | https://dev.mysql.com/downloads/repo/yum/ |
| Redis |
安装之前,需要准备编译环境和nginx依赖。
yum -y install gcc automake autoconf libtool make
yum install gcc gcc-c++
cd /usr/local/src
wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
tar -zxvf pcre-8.43.tar.gz
cd pcre-8.43/
./configure
make && make install
cd /usr/local/src
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11/
./configure
make && make install
cd /usr/local/src
wget http://www.openssl.org/source/openssl-1.1.1c.tar.gz
tar -zxvf openssl-1.1.1c.tar.gz
cd openssl-1.1.1c/
./config
make && make install
一般为了服务器安全,会指定一个普通用户权限的账号做为Nginx的运行角色,这里使用www用户做为Nginx工作进程的用户。后续安装的PHP也以www用户作为工作进程用户。
groupadd -r www
useradd -r -g www www
cd /usr/local/src
wget http://nginx.org/download/nginx-1.14.0.tar.gz
tar -zxvf nginx-1.14.0.tar.gz
cd nginx-1.14.0
./configure \ --prefix=/usr/local/nginx \ --sbin-path=/usr/local/nginx/sbin/nginx \ --conf-path=/usr/local/nginx/nginx.conf \ --pid-path=/usr/local/nginx/nginx.pid \ --user=www \ --group=www \ --with-http_ssl_module \ --with-http_flv_module \ --with-http_mp4_module \ --with-http_stub_status_module \ --with-http_gzip_static_module \ --http-client-body-temp-path=/var/tmp/nginx/client/ \ --http-proxy-temp-path=/var/tmp/nginx/proxy/ \ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \ --http-scgi-temp-path=/var/tmp/nginx/scgi \ --with-pcre=/usr/local/src/pcre-8.43 \ --with-zlib=/usr/local/src/zlib-1.2.11 \ --with-openssl=/usr/local/src/openssl-1.1.1c make && make install
nginx编译选项说明:
–prefix表示nginx要安装到哪个路径下,这里指定刚才新建好的/alidata/server目录下的nginx-1.12.2;
–sbin-path表示nginx的可执行文件存放路径
–conf-path表示nginx的主配置文件存放路径,nginx允许使用不同的配置文件启动,通过命令行中的-c选项
–pid-path表示nginx.pid文件的存放路径,将存储的主进程的进程号。安装完成后,可以随时改变的文件名 , 在nginx.conf配置文件中使用 PID指令。默认情况下,文件名 为prefix/logs/nginx.pid
–error-log-path表示nginx的主错误、警告、和诊断文件存放路径
–http-log-path表示nginx的主请求的HTTP服务器的日志文件的存放路径
–user表示nginx工作进程的用户
–group表示nginx工作进程的用户组
–with-select_module或–without-select_module表示启用或禁用构建一个模块来允许服务器使用select()方法
–with-poll_module或–without-poll_module表示启用或禁用构建一个模块来允许服务器使用poll()方法
–with-http_ssl_module表示使用https协议模块。默认情况下,该模块没有被构建。建立并运行此模块的OpenSSL库是必需的
–with-pcre表示pcre的源码路径,因为解压后的pcre是放在root目录下的,所以是/root/pcre-8.41;
–with-zlib表示zlib的源码路径,这里因为解压后的zlib是放在root目录下的,所以是/root/zlib-1.2.11
–with-openssl表示openssl库的源码路径
mkdir -p /var/tmp/nginx/client
/usr/local/nginx/sbin/nginx
ln -sf /usr/local/nginx/sbin/nginx /usr/sbin
nginx -t
结果:
nginx: the configuration file /usr/local/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/nginx.conf test is successful
centos7的防火墙firewall默认关闭http请求及80端口,因此需先打开防火墙
firewall-cmd --add-service=http --permanent
firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-all
使用另外一台机器访问该服务器,就会出现“Welcome to nginx!”。
| 参数 | 路径 |
|---|---|
| config-file-path | /usr/local/php/etc |
| config-file-scan-dir | /usr/local/php/etc/conf.d |
| php.ini | /usr/local/php/etc/php.ini |
yum -y install libmcrypt-devel mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel
cd /usr/local/src
wget https://www.php.net/distributions/php-7.3.8.tar.gz
tar -zxvf php-7.3.8.tar.gz
cd php-7.3.8
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --with-mcrypt --with-libmbfl --enable-ftp --with-gd --enable-gd-jis-conv --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-pear --enable-maintainer-zts --with-ldap=shared --without-gdbm
make && make install
vim /etc/profile 在末尾加入 export PHP_HOME=/usr/local/php export PATH=PATH:PHP_HOME/bin:$PHP_HOME/sbin 保存修改后,使用source命令重新加载配置文件: source /etc/profile 配置php-fpm cd /usr/local/php/etc cp php-fpm.conf.default php-fpm.conf cd php-fpm.d/ cp www.conf.default www.conf cp /usr/local/src/php-7.3.8/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm cp /usr/local/src/php-7.3.8/php.ini-production /usr/local/php/etc/php.ini chmod +x /etc/init.d/php-fpm 修改/usr/local/nginx/nginx.conf: 添加红色文字内容 location / { root html; # 添加index.php index index.php index.html index.htm; } 去掉注释、修改inclue location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; #include fastcgi_params; # 添加include include fastcgi.conf } 重新载入nginx的配置文件 nginx -s reload 在/usr/local/nginx/html下创建index.php文件,输入如下内容: <?php phpinfo(); 浏览器访问该地址:{IP}/index.php
cd /usr/local/src
wget wget http://pecl.php.net/get/redis-4.2.0.tgz
tar -zxvf redis-4.2.0.tgz
cd redis-4.2.0
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
添加拓展
vi /usr/local/php/etc/php.ini
extension=redis.so
service php-fpm restart
cd /usr/local/src
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
yum -y install mysql80-community-release-el7-1.noarch.rpm
yum -y install mysql-community-server
groupadd mysql
useradd -r -g www mysql
systemctl start mysqld.service
查看默认密码
grep "password" /var/log/mysqld.log
登录
mysql -uroot -p
设置强密码,包含:大写+小写+数字+符号
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new STRONG password’;
CREATE USER `dba`@`192.168.%` IDENTIFIED BY 'passowrd';
GRANT ALL ON *.* TO `wangwei`@`127.0.0.1` WITH GRANT OPTION;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。