标签:DBName make 开机 image cti pcr ash dha user
在单台主机上配置LNMP1.登录官网获取下载链接直接wget
[root@localhost ~]# wget http://nginx.org/download/nginx-1.17.0.tar.gz
2.解压文件
[root@localhost ~]# tar xf nginx-1.17.0.tar.gz
3.检查当前环境是否符合编译要求,并生成makefile文件
[root@localhost ~]# cd nginx-1.17.0
[root@localhost nginx-1.17.0]# ./configure --prefix=/apps/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module
4.根据makefile文件内容生成指定的模块
[root@localhost nginx-1.14.2]# make
5.将生成的模块复制到相应的目录,如果目录不存在会创建目录
[root@localhost nginx-1.14.2]# make install
6.将执行文件关联到sbin下
[root@localhost nginx-1.17.0]# ln -s /apps/nginx/sbin/nginx /sbin/nginx
7.配置服务脚本
使用yum安装的服务脚本进行修改
[root@localhost ~]# vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/apps/nginx/logs/nginx.pid #修改为nginx编译安装的目录
# Nginx will fail to start if /run/nginx.pid already exists but has the wrong
# SELinux context. This might happen when running `nginx -t` from the cmdline.
# https://bugzilla.redhat.com/show_bug.cgi?id=1268621
ExecStartPre=/usr/bin/rm -f /run/nginx.pid
ExecStartPre=/apps/nginx/sbin/nginx -t #修改nginx的路径
ExecStart=/apps/nginx/sbin/nginx -c /apps/nginx/conf/nginx.conf #修改nginx路径,并添加配置文件
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
[Install]
WantedBy=multi-user.target
8.创建nginx用户
[root@localhost ~]# useradd -u 2000 nginx
9.修改配置文件
[root@localhost ~]# vim /apps/nginx/conf/nginx.conf
user nginx; #修改用户为nginx
pid /apps/nginx/logs/nginx.pid; #修改pid文件存放路径与服务脚本内路径相同
10.启动服务
[root@localhost ~]# systemctl start nginx
[root@localhost ~]# ss -tnl | grep 80
LISTEN 0 128 *:80 *:*
1.解压文件
[root@localhost ~]# tar xf php-7.3.5.tar.bz2
2.检查当前环境是否符合编译要求,并生成makefile文件
[root@localhost ~]# cd php-7.3.5
[root@localhost php-7.3.5]# ./configure --prefix=/app/php --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-mbstring --enable-xml --enable-sockets --enable-fpm --enable-maintainer-zts --disable-fileinfo
3.生成模块并将模块复制到指定位置
[root@localhost ~]# make && make install
4.复制启动配置文件并修改
[root@localhost php-7.3.5]# cp php.ini-production /etc/php.ini
[root@localhost php-7.3.5]# sed -i ‘/;date.tim/s@.*@data.timezone = "Asia/Shanghai"@‘ /etc/php.ini
5.复制服务器脚本,并配置为开机启动
[root@localhost php-7.3.5]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@localhost php-7.3.5]# chmod +x /etc/init.d/php-fpm
[root@localhost php-7.3.5]# chkconfig --add /etc/init.d/php-fpm
6.复制php配置文件
[root@localhost php-7.3.5]# cp /app/php/etc/php-fpm.conf.default /app/php/etc/php-fpm.conf
[root@localhost php-7.3.5]# cp /app/php/etc/php-fpm.d/www.conf.default /app/php/etc/php-fpm.d/www.conf
1.修改php配置文件
[root@localhost ~]# vim /app/php/etc/php-fpm.d/www.conf
user = ngnix
group = nginx
listen.allowed_clients = 127.0.0.1
2.修改nginx配置文件
[root@localhost ~]# mkdir /apps/nginx/conf/server
[root@localhost ~]# vim /apps/nginx/conf/server/mylinuxops.conf
[root@localhost ~]# vim /apps/nginx/conf/server/mylinuxops.conf
server {
server_name www.mylinuxops.com;
listen 80;
location / {
root /data/www;
index index.html;
}
location ~ \.php$ {
root /data/www/php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
3.在nginx主配置文件中将server的配置导入
[root@localhost ~]# vim /apps/nginx/conf/nginx.conf
http {
......
include /apps/nginx/conf/server/*.conf;
}
4.启动nginx和php-fpm
[root@localhost ~]# service php-fpm start
[root@localhost ~]# systemctl start nginx
5.测试
创建测试页面
[root@localhost ~]# echo www.mylinuxops.com > /data/www/index.html
[root@localhost ~]# vim /data/www/php/index.php
<?php
phpinfo();
?>
6.访问测试页面
1.创建MySQL用户和组
[root@localhost ~]# groupadd -r mysql
[root@localhost ~]# useradd -g mysql -r -s /sbin/nologin mysql
2.解压文件到/usr/local目录下
[root@localhost ~]# tar xf mariadb-10.2.23-linux-x86_64.tar.gz -C /usr/local/
3.对目录创建软连接并修改属主属组
[root@localhost ~]# cd /usr/local/
[root@localhost local]# ln -s mariadb-10.2.23-linux-x86_64 mysql
[root@localhost local]# chown -R root.root mysql
4.复制配置文件模板,并修改
[root@localhost local]# mkdir /etc/mysql
[root@localhost local]# cp mysql/support-files/my-huge.cnf /etc/mysql/my.cnf
[root@localhost mysql]# vim /etc/mysql/my.cnf
datadir=/data/mysql #指定数据库目录
5.复制服务启动脚本,并配置为开机自动启动
[root@localhost local]# cp mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhost local]# chkconfig --add mysqld
6.创建数据库目录并配置为安全权限
[root@localhost local]# mkdir /data/mysql
[root@localhost local]# chown -R mysql.mysql /data/mysql
[root@localhost local]# chmod 700 /data/mysql
7.初始化数据库
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
8.启动数据库服务
[root@localhost mysql]# service mysqld start
Starting mysqld (via systemctl): [ OK ]
1.创建测试页面
[root@localhost mysql]# vim /data/www/php/index.php
<?php
$dsn=‘mysql:host=127.0.0.1;dbname=test‘;
$username=‘mysql‘; $passwd=‘‘;
$dbh=new PDO($dsn,$username,$passwd);
var_dump($dbh);
phpinfo();
?>
2.使用浏览器访问
标签:DBName make 开机 image cti pcr ash dha user
原文地址:https://blog.51cto.com/11886307/2403953