环境:
CentOS Linux release 7.9.2009 (Core)
mysql-5.7.44
nginx-1.18
php-7.2.29
WordPress-4.7.4
DiscuzX-3.4
安装mysql57
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| rm -rf /usr/local/mysql* useradd mysql -M -s /sbin/nologin wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz tar -xf mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz mv mysql-5.7.44-linux-glibc2.12-x86_64 /usr/local/mysql mkdir /usr/local/mysql/data -p mkdir /usr/local/mysql/logs -p chown -R mysql:mysql /usr/local/mysql chown mysql:mysql /etc/my.cnf \cp -f /usr/local/mysql/bin/* /bin/
cat > /etc/my.cnf << EOF [mysql] default-character-set=utf8mb4 socket=/usr/local/mysql/logs/mysql.sock [mysqld] port=3306 basedir=/usr/local/mysql datadir=/usr/local/mysql/data log-error=/usr/local/mysql/logs/mysqld.log socket=/usr/local/mysql/logs/mysql.sock character-set-server=utf8mb4 default-storage-engine=INNODB log-output=FILE default-authentication-plugin=mysql_native_password EOF
mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ \ --datadir=/usr/local/mysql/data/
cat > /usr/lib/systemd/system/mysqld.service << EOF [Unit] Description=MySQL Server Documentation=man:mysqld(8) After=network.target After=syslog.target [Install] WantedBy=multi-user.target [Service] User=mysql Group=mysql ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf LimitNOFILE=65536 LimitNPROC=65536 EOF systemctl daemon-reload systemctl restart mysqld.service systemctl is-active mysqld.service active
mysql -uroot -p$(cat /usr/local/mysql/logs/mysqld.log | grep root | grep generated | awk '{print $11}') set password="root"; create database web; create user 'php'@'localhost' identified by 'php123'; grant select on web.* to 'php'@'localhost'; flush privileges;
use web; create table web01(id int auto_increment primary key, name varchar(15)); insert into web01 value (1,'wangsheng'); commit;
|
编译安装nginx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| rm -rf /usr/local/nginx* useradd www -M -s /sbin/nologin wget https://nginx.org/download/nginx-1.18.0.tar.gz tar -xf nginx-1.18.0.tar.gz cd ~/nginx-1.18.0/
./configure \ --user=www \ --group=www \ --prefix=/usr/local/nginx \ --sbin-path=/usr/local/nginx/sbin/nginx \ --conf-path=/usr/local/nginx/conf/nginx.conf \ --error-log-path=/usr/local/nginx/logs/error.log \ --http-log-path=/usr/local/nginx/logs/access.log \ --pid-path=/var/run/nginx.pid \ --lock-path=/var/lock/subsys/nginx \ --with-http_stub_status_module \ --with-http_ssl_module \ --with-http_gzip_static_module \ --with-pcre make && make install
chown -R www:www /usr/local/nginx/ cat > /usr/local/nginx/conf/nginx.conf <<'EOF' worker_processes 4; events { worker_connections 1024; } http { include /usr/local/nginx/conf/vhost/*.conf; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; } EOF
mkdir /usr/local/nginx/conf/vhost -p mkdir /usr/local/nginx/html/wangsheng -p echo "welcome to www.wangsheng.com" > /usr/local/nginx/html/wangsheng/index.html
cat > /usr/local/nginx/conf/vhost/wangsheng.conf << 'EOF' server { listen 80; server_name www.wangsheng.com; location / { root /usr/local/nginx/html/wangsheng; index index.html index.php; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/wangsheng$fastcgi_script_name; include fastcgi_params; } } EOF nginx -t nginx -s reload curl www.wangsheng.com welcome to www.wangsheng.com
|
编译安装php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel yum install -y libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel yum install -y glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel yum install -y e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers yum install sqlite-devel yum install oniguruma-devel
wget https://www.php.net/distributions/php-7.2.29.tar.gz tar -xf php-7.2.29.tar.gz cd php-7.2.29/ ./configure --prefix=/usr/local/php --exec-prefix=/usr/local/php \ --with-mysqli --with-pdo-mysql --bindir=/usr/local/php/bin --with-gd \ --sbindir=/usr/local/php/sbin --includedir=/usr/local/php/include \ --libdir=/usr/local/php/lib/php --mandir=/usr/local/php/php/man \ --with-config-file-path=/usr/local/php/etc --with-openssl \ --enable-mbstring --enable-fpm make && make install
cd ~/php-7.2.29/ \cp php.ini-production /usr/local/php/etc/php-ini \cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod +x /etc/init.d/php-fpm \cp /usr/local/php/etc/php-fpm.d/www.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 ln -s /usr/local/php/bin/php /usr/local/bin/ /etc/init.d/php-fpm start
netstat -tunlp | grep 9000
|
nginx连接php测试
1 2 3 4 5 6
| cat > /usr/local/nginx/html/wangsheng/index.php << EOF <?php phpinfo(); ?> EOF nginx -s reload
|

php连接mysql测试
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| cat > /usr/local/nginx/html/wangsheng/mysql_test.php << 'EOF' <?php $servername = "127.0.0.1"; $username = "php"; $password = "php123"; $conn = mysqli_connect($servername, $username, $password); if ($conn) { echo "mysql successful login !\n"; } else { die("Connection failed: " . mysqli_connect_error()); } ?> EOF curl www.wangsheng.com/mysql_test.php
|
发布discuz
版本3.4
1 2 3 4 5 6 7 8 9 10
| cp Discuz_X3.4.zip /usr/local/nginx/html/wangsheng/ cd /usr/local/nginx/html/wangsheng/ unzip Discuz_X3.4.zip chown -R www:www . nginx -s reload 浏览器安装 输入mysql ip为127.0.0.1或其他 输入mysql用户名和密码 安装完成并进入浏览
|

发布WordPress
版本4.7.4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| yum -y install php-zlib pkill php-fpm /etc/init.d/php-fpm start nginx -s reload
cat > /usr/local/nginx/conf/vhost/wordpress.conf << 'EOF' server { listen 80; server_name www.it.com; location / { root /usr/local/nginx/html/wp; index index.html index.php; } location ~ \.php* { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/wp$fastcgi_script_name; include fastcgi_params; } error_log /usr/local/nginx/logs/wp.error.log; } EOF mkdir -p /usr/local/nginx/html/wp cp ~/wordpress-4.7.4-zh_CN.tar.gz /usr/local/nginx/html/wp/ cd /usr/local/nginx/html/wp/ tar -xf wordpress-4.7.4-zh_CN.tar.gz mv wordpress/* . rm -rf wordpress* chown -R www.www . nginx -t && nginx -s reload
mysql -uroot -proot create database wordpress; exit;
修改host 192.168.10.113 www.s.wangsheng.com www.wangsheng.com www.it.com 浏览器访问www.it.com 开始安装
|
