CentOS7下的Django2集成部署二:Nginx1.14.2、Mysql5.7和Python3.7的安装
nginx
- 安装依赖
yum install -y gcc pcre-devel zlib zlib-devel
- 默认安装
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install -y nginx - 配置
[root@gz-ct76211 ~]# nginx -v nginx version: nginx/1.14.2 [root@gz-ct76211 ~]# systemctl enable nginx Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service. [root@gz-ct76211 ~]# systemctl start nginx [root@gz-ct76211 ~]# lsof -i :80 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME nginx 11227 root 6u IPv4 34477 0t0 TCP *:http (LISTEN) nginx 11228 nginx 6u IPv4 34477 0t0 TCP *:http (LISTEN)
- 调试
[root@gz-ct76211 ~]# elinks http://localhost --dump Welcome to nginx! If you see this page, the nginx web server is successfully installed and working. Further configuration is required. For online documentation and support please refer to [1]nginx.org. Commercial support is available at [2]nginx.com. Thank you for using nginx. References Visible links 1. http://nginx.org/ 2. http://nginx.com/
此刻nginx基本上就已经可以正常工作了!调试过程中,为了避免干扰,请务必把selinux和防火墙 firewalld或iptables 都关闭了
mysql
- 安装依赖
yum -y install ncurses-devel gcc-* bzip2-*
- 编译安装
- cmake
#获取cmake wget https://github.com/Kitware/CMake/releases/download/v3.13.1/cmake-3.13.1.tar.gz #解压 tar xf cmake-3.13.1.tar.gz #进入程序目录 cd cmake-3.13.1 #编译并安装 ./configuare make make install
- boost
#获取boost1.59 wget https://nchc.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.bz2 #解压 tar xf boost_1_59_0.tar.bz2 #移动目录给mysql编译使用 mv boost_1_59_0 /usr/local/boost
- mysql
#获取mysql wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24.tar.gz
tar xf mysql-5.7.24.tar.gzcd mysql-5.7.24
用cmake编译,耗时有点久编译安装差不多1小时左右
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data/ -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDOWNLOAD_BOOST=0 -DWITH_INNODBBASE_STORAGE_ENGINE=1 -DENABLE_LOCAL_INFILE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_DEBUG=0 -DWITH_EMBEDED_SERVER=0 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost
# -DMYSQL_USER=mysql 稍后新建mysql用户make && make install
- cmake
- 配置
- 添加启动文件
cp support-files/mysql.server /etc/init.d/mysql #授权 chmod 755 /etc/init.d/mysql
- 用户配置
#添加用户 useradd -s /sbin/nologin -r mysql #用户授权 chown mysql.mysql /usr/local/mysql/ -R
- 设置链接文件
ln -sf /usr/local/mysql/bin/* /usr/bin/
ln -sf /usr/local/mysql/lib/* /usr/lib/
ln -sf /usr/local/mysql/libexec/* /usr/local/libexec
ln -sf /usr/local/mysql/share/man/man1/* /usr/share/man/man1
ln -sf /usr/local/mysql/share/man/man8/* /usr/share/man/man8
- 配置文件
#数据目录
[root@home-ct75211 mysql-5.7.24]# mkdir -pv /usr/local/mysql/data
mkdir: created directory ‘/usr/local/mysql/data’配置/etc/my.cnf
1 [mysqld] 2 datadir=/usr/local/mysql/data 3 socket=/usr/local/mysql/mysql.sock 4 # Disabling symbolic-links is recommended to prevent assorted security risks 5 symbolic-links=0 6 # Settings user and group are ignored when systemd is used. 7 # If you need to run mysqld under a different user or group, 8 # customize your systemd unit file for mariadb according to the 9 # instructions in http://fedoraproject.org/wiki/Systemd 10 11 [mysqld_safe] 12 log-error=/var/log/mysql.log 13 pid-file=/var/run/mysql.pid 14 15 # 16 # include all files from the config directory 17 # 18 !includedir /etc/my.cnf.d
- 添加启动文件
#生成默认密码 /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
启动MySQL
/etc/init.d/mysql start
设置root密码
mysql_secure_installation
1 [root@home-ct75211 mysql-5.7.24]# mysql_secure_installation 2 3 Securing the MySQL server deployment. 4 5 Enter password for user root: 6 7 The existing password for the user account root has expired. Please set a new password. 8 9 New password: 10 11 Re-enter new password: 12 13 VALIDATE PASSWORD PLUGIN can be used to test passwords 14 and improve security. It checks the strength of password 15 and allows the users to set only those passwords which are 16 secure enough. Would you like to setup VALIDATE PASSWORD plugin? 17 18 Press y|Y for Yes, any other key for No: n 19 Using existing password for root. 20 Change the password for root ? ((Press y|Y for Yes, any other key for No) : y 21 22 New password: 23 24 Re-enter new password: 25 By default, a MySQL installation has an anonymous user, 26 allowing anyone to log into MySQL without having to have 27 a user account created for them. This is intended only for 28 testing, and to make the installation go a bit smoother. 29 You should remove them before moving into a production 30 environment. 31 32 Remove anonymous users? (Press y|Y for Yes, any other key for No) : y 33 Success. 34 35 36 Normally, root should only be allowed to connect from 37 'localhost'. This ensures that someone cannot guess at 38 the root password from the network. 39 40 Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y 41 Success. 42 43 By default, MySQL comes with a database named 'test' that 44 anyone can access. This is also intended only for testing, 45 and should be removed before moving into a production 46 environment. 47 48 49 Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y 50 - Dropping test database... 51 Success. 52 53 - Removing privileges on test database... 54 Success. 55 56 Reloading the privilege tables will ensure that all changes 57 made so far will take effect immediately. 58 59 Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y 60 Success. 61 62 All done!