1、安装 nginx: 先安装 nginx 的依赖: yum -y install gcc gcc-c++ openssl openssl-devel cyrus-sasl-md5 接着安装 nginx,我把下载下来的软件包都放在 /usr/local/src 目录下,可自主选择。 为了避免上传文件到服务器的过程,所以直接使用 wget 进行下载,方便。 先下载 pcre 和 zlib: wget https://downloads.sourceforge.net/project/pcre/pcre/8.42/pcre-8.42.tar.gz wget http://www.zlib.net/fossils/zlib-1.2.11.tar.gz 再到 nginx 官网下载 nginx 包: wget http://nginx.org/download/nginx-1.14.2.tar.gz 下载完成后进行解压: tar -zxvf nginx-1.14.2.tar.gz tar -zxvf pcre-8.42.tar.gz tar -zxvf zlib-1.2.11.tar.gz 之后进入解压目录进行编译(解压后当前目录下会有 configure 文件,--prefix 配置安装的路径(位置),--with-pcre和--with-zlib分别是上面下载解压的 pcre 和 zlib 包的路径): cd nginx-1.14.2 ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-pcre=../pcre-8.42 --with-zlib=../zlib-1.2.11 编译完成就进行构建和安装: make make install 或者 make && make install 安装完毕后得使用绝对路径启动 nginx 服务: /usr/local/nginx/sbin/nginx #查看服务状态 ps -ef | grep nginx 成功开启 nginx 服务的效果图类似下面: root 24418 1 0 May29 ? 00:00:00 nginx: master process /usr/sbin/nginx nginx 30413 24418 0 10:31 ? 00:00:00 nginx: worker process root 30484 9008 0 10:32 pts/0 00:00:00 grep --color=auto nginx 直接在浏览器地址栏输入服务器 ip 或 域名即可访问,得到如下图的结果即正常: 现在启动 nginx 需要使用绝对路径,比较麻烦,所以将 nginx 的启动命令(路径)配置到系统全局变量文件(/etc/profile)内即可。在文件底部添加:(使用分号":"分割之前的系统变量) export PATH="$PATH:/usr/local/nginx/sbin" 保存退出后执行以下语句是配置生效: source /etc/profile 现在就可以直接使用 nginx 命令启动 nginx 服务了。 nginx -s reload #重启nginx服务 nginx -t #测试nginx配置文件是否正常 将 nginx 服务添加到开机自启动: 系统启动脚本 /etc/rc.local ,这个文件是系统启动后会自动执行的。进入此文件添加如下语句》 #启动命令和 -c 配置文件的路径 /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf & 重启服务器再使用如下命令查看 nginx 服务是否启动: ps -ef | grep nginx #如若未正常启动,则可能是该文件执行权限问题,可以给文件添加其他人执行的权限: chmod o+x /etc/rc.local,之后重启服务器试试。 正常效果图如下: 当使用 nginx -s reopen 会报如下错误的时候可以如下图解决: nginx.conf 配置文件去掉下图 pid 前的注释符号"#",保存退出 :wq。 再执行 nginx -s reopen 未出现上述错误即可。 2、rpm 安装mysql8.0 https://dev.mysql.com/downloads/file/?id=484922 wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm rpm -Uvih mysql80-community-release-el7-3.noarch.rpm yum repolist yum --enablerepo=mysql-connectors-community search mysql yum --enablerepo=mysql-connectors-community install mysql-community-client.x86_64 mysql-community-server.x86_64 //重启 systemctl restart mysqld //查看启动状态 systemctl status mysqld //查看默认密码 [root@sfo1-7 ~]# cat /var/log/mysqld.log | grep 'A temporary password' 2017-07-09T01:44:24.043881Z 1 [Note] A temporary password is generated for root@localhost: r-kY0uaY>M>g --设置复杂程度 set global validate_password.policy=0; --设置密码长度 set global validate_password.length=6; //修改密码 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '1qa2ws3ED'; 3、安装php yum -y install gcc gcc-c++ libxml2 libxml2-devel autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel 执行后如果出现错误类似(https://blog.csdn.net/zhuxiang203/article/details/38779779),意思是存在多个库版本,我这边是 glib2 多了个 32 位的版本,而系统是 64 位的,因此需要将其删除。大家根据具体提示进行删除。 Error: Multilib version problems found. This often means that the root cause is something else and multilib version checking is just pointing out that there is a problem. Eg.: 1. You have an upgrade for openssl which is missing some dependency that another package requires. Yum is trying to solve this by installing an older version of openssl of the different architecture. If you exclude the bad architecture yum will tell you what the root cause is (which package requires what). You can try redoing the upgrade with --exclude openssl.otherarch ... this should give you an error message showing the root cause of the problem. 2. You have multiple architectures of openssl installed, but yum can only see an upgrade for one of those arcitectures. If you don't want/need both architectures anymore then you can remove the one with the missing update and everything will work. 3. You have duplicate versions of openssl installed already. You can use "yum check" to get yum show these errors. ...you can also use --setopt=protected_multilib=false to remove this checking, however this is almost never the correct thing to do as something else is very likely to go wrong (often causing much more problems). Protected multilib versions: openssl-1.0.1e-16.el6_5.7.x86_64 != openssl-1.0.0-27.el6_4.2.i686 You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofiles --nodigest #使用此命令查看发现 glib2 确实存在多个版本 rpm -qa|grep glib2 #删除上面命令执行结果中不需要的版本 rpm --erase --nodeps glib2-2.46.2-4.el7.i686 完成上一步操作之后先下载 php 包: #下载 wget http://am1.php.net/distributions/php-7.3.0.tar.gz #解压 tar -zxvf php-7.3.0.tar.gz 进入解压目录 cd php-7.3.0 进行编译: --with-config-file-path=php.ini_path #此配置项指定 php.ini 存放路径 #编译命令配置如下: ./configure \ --prefix=/usr/local/php \ --with-config-file-path=/etc \ --enable-fpm \ --with-fpm-user=nginx \ --with-fpm-group=nginx \ --enable-inline-optimization \ --disable-debug \ --disable-rpath \ --enable-shared \ --enable-soap \ --with-libxml-dir \ --with-xmlrpc \ --with-openssl \ --with-mcrypt \ --with-mhash \ --with-pcre-regex \ --with-sqlite3 \ --with-zlib \ --enable-bcmath \ --with-iconv \ --with-bz2 \ --enable-calendar \ --with-curl \ --with-cdb \ --enable-dom \ --enable-exif \ --enable-fileinfo \ --enable-filter \ --with-pcre-dir \ --enable-ftp \ --with-gd \ --with-openssl-dir \ --with-jpeg-dir \ --with-png-dir \ --with-zlib-dir \ --with-freetype-dir \ --enable-gd-native-ttf \ --enable-gd-jis-conv \ --with-gettext \ --with-gmp \ --with-mhash \ --enable-json \ --enable-mbstring \ --enable-mbregex \ --enable-mbregex-backtrack \ --with-libmbfl \ --with-onig \ --enable-pdo \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-zlib-dir \ --with-pdo-sqlite \ --with-readline \ --enable-session \ --enable-shmop \ --enable-simplexml \ --enable-sockets \ --enable-sysvmsg \ --enable-sysvsem \ --enable-sysvshm \ --enable-wddx \ --with-libxml-dir \ --with-xsl \ --enable-zip \ --enable-mysqlnd-compression-support \ --with-pear \ --enable-opcache \ --disable-fileinfo make && make install //添加环境变量 vi /etc/profile PATH=$PATH:/usr/local/php/bin export PATH source /etc/profile cp ~/php-7.1.11/php.ini-production /etc/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf //配置php-fpm vim /etc/init.d/php-fpm #! /bin/sh ### BEGIN INIT INFO # chkconfig: - 95 15 # description: php-fpm # Provides: php-fpm # Required-Start: $remote_fs $network # Required-Stop: $remote_fs $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts php-fpm # Description: starts the PHP FastCGI Process Manager daemon ### END INIT INFO prefix=/usr/local/php exec_prefix=${prefix} php_fpm_BIN=${exec_prefix}/sbin/php-fpm php_fpm_CONF=${prefix}/etc/php-fpm.conf php_fpm_PID=${prefix}/var/run/php-fpm.pid php_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID" wait_for_pid () { try=0 while test $try -lt 35 ; do case "$1" in 'created') if [ -f "$2" ] ; then try='' break fi ;; 'removed') if [ ! -f "$2" ] ; then try='' break fi ;; esac echo -n . try=`expr $try + 1` sleep 1 done } case "$1" in start) echo -n "Starting php-fpm " $php_fpm_BIN --daemonize $php_opts if [ "$?" != 0 ] ; then echo " failed" exit 1 fi wait_for_pid created $php_fpm_PID if [ -n "$try" ] ; then echo " failed" exit 1 else echo " done" fi ;; stop) echo -n "Gracefully shutting down php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -QUIT `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then echo " failed. Use force-quit" exit 1 else echo " done" fi ;; status) if [ ! -r $php_fpm_PID ] ; then echo "php-fpm is stopped" exit 0 fi PID=`cat $php_fpm_PID` if ps -p $PID | grep -q $PID; then echo "php-fpm (pid $PID) is running..." else echo "php-fpm dead but pid file exists" fi ;; force-quit) echo -n "Terminating php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -TERM `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then echo " failed" exit 1 else echo " done" fi ;; restart) $0 stop $0 start ;; reload) echo -n "Reload service php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -USR2 `cat $php_fpm_PID` echo " done" ;; *) echo "Usage: $0 {start|stop|force-quit|restart|reload|status}" exit 1 ;; esac # 设置权限 chmod 755 /etc/init.d/php-fpm # php-fpm加入服务 chkconfig --add php-fpm # php-fpm 2345 级别下设置为启动 chkconfig php-fpm on # 查看php-fpm服务当前配置 chkconfig --list php-fpm php-fpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off # 启动 service php-fpm start # 关闭 service php-fpm stop # 重启 service php-fpm restart # 平滑重启 service php-fpm reload # 检查配置文件 service php-fpm configtest # 执行结果 Usage: /etc/init.d/php-fpm {start|stop|force-quit|restart|reload|status}