Debian11快速安装网站搭建环境,代码如下:
#/bin/bash
apt-get update -y && apt-get upgrade -y
apt-get install nginx mysql-server mysql-client php-fpm php-curl php-zip php-mysql php-mbstring php-xml php-gd -y
sed -i "s/\;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" /etc/php/7.4/fpm/php.ini
sed -i "s/\post_max_size = 8M/post_max_size = 4000M/g" /etc/php/7.4/fpm/php.ini
sed -i "s/\upload_max_filesize = 2M/upload_max_filesize = 4000M/g" /etc/php/7.4/fpm/php.ini
/etc/init.d/php7.4-fpm restart
安装完成后修改/etc/nginx/sites-available/default下location ~ .php$这一段配置关联php,如下:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# With php-cgi (or other tcp sockets):
#fastcgi_pass 127.0.0.1:9000;
}
/etc/init.d/nginx restart 即可。
更新可能会遇到Mariadb没有输入root密码也可以登录,状态如下:
mysql;
select user.plugin from mysql.user;
+-----------------------+
| plugin |
+-----------------------+
| unix_socket |
+-----------------------+
1 row in set (0.00 sec)
运行一下代码增加root密码,以及更新plugin默认值。
UPDATE mysql.user SET authentication_string = PASSWORD('mypassword'), plugin = 'mysql_native_password' WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;
再次查询:
select user.plugin from mysql.user;
+-----------------------+
| plugin |
+-----------------------+
| mysql_native_password |
+-----------------------+
1 row in set (0.00 sec)
最后重启一下mysql服务吧。
/etc/init.d/mysql restart
Debian8 安装lnmp
安装nginx
apt-get install nginx -y
安装php7.0
在/etc/apt/sources.list文件中添加下面两行文字以安装dotdeb.org软件源。
deb http://packages.dotdeb.org jessie all
deb-src http://packages.dotdeb.org jessie all
下载并安装GnuPG key
wget https://www.dotdeb.org/dotdeb.gpg
sudo apt-key add dotdeb.gpg
更新软件库并安装php7.0
apt-get update
apt-get install php7.0-fpm php7.0-mysql php7.0-common php7.0-gd php7.0-json php7.0-cli php7.0-curl
修改php配置:
vim /etc/php/7.0/fpm/php.ini,把;cgi.fix_pathinfo=1修改为cgi.fix_pathinfo=0
重启php服务。
安装mysql:
apt-get install -y mariadb-server mariadb-client
在nginx配置中添加以下代码:
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
phpini中open_basedir =/var/www;改为open_basedir =/var/www:/proc/;
要不然雅黑探针可能无法正常显示服务器信息。
3 条评论
[....] Restarting nginx (via systemctl): nginx.serviceJob for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
failed!
出现了这个错误是否能帮我解决下
Apr 22 15:31:46 instance-1 nginx[12010]: nginx: configuration file /etc/nginx/nginx.conf test failed
应该是nginx配置文件出错了。。你可以运行 nginx -t 看看那个地方写错了
● nginx.service - A high performance web server and a reverse proxy server
Docs: man:nginx(8)Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2018-04-22 15:31:46 UTC; 3s ago
Process: 11840 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exit
ed, status=0/SUCCESS)
Process: 12010 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1
/FAILURE)
Main PID: 21155 (code=exited, status=0/SUCCESS)
Apr 22 15:31:46 instance-1 systemd[1]: Starting A high performance web server and a reverse proxy server...
Apr 22 15:31:46 instance-1 nginx[12010]: nginx: [emerg] "fastcgi_pass" directive is duplicate in /etc/nginx/sites-e
nabled/default:53
Apr 22 15:31:46 instance-1 nginx[12010]: nginx: configuration file /etc/nginx/nginx.conf test failed
Apr 22 15:31:46 instance-1 systemd[1]: nginx.service: Control process exited, code=exited status=1
Apr 22 15:31:46 instance-1 systemd[1]: Failed to start A high performance web server and a reverse proxy se
rver.
Apr 22 15:31:46 instance-1 systemd[1]: nginx.service: Unit entered failed state.
Apr 22 15:31:46 instance-1 systemd[1]: nginx.service: Failed with result 'exit-code'.