how to setup standard Web server with nginx on centos 7 easily
1. updlate and install packet to suport instalation
yum updateyum install nano -yyum install epel-release –y
2. install nginx
yum install nginx -y
systemctl start nginx
systemctl enable nginx
3. allow http and https
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
4. install mariadb
yum install mariadb-server mariadb –y
systemctl start mariadb
systemctl enable mariadb
mysql_secure_installation
5. install php
add repo php to centos
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpmset php repo
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum install yum-utils
yum-config-manager --enable remi-php56 [Install PHP 5.6]yum-config-manager --enable remi-php72 [Install PHP 7.2]yum-config-manager --enable remi-php74 [Install PHP 7.4]
install php
yum install php php-fpm php-cli php-common php-curl php-dev php-gd php-imap php-intl php-json php-mbstring php-mcrypt php-mysql php-pgsql php-phpdbg php-sqlite3 php-sybase php-xml php-xmlrpc php-xsl php-zip libapache2-mod-php
6. setup php fpm if you need
nano /etc/php-fpm.d/www.conf
then set user for nginx with remove ';' an change user and group on this line
listen.owner = nginx
listen.group = nginx
user = nginx
group = nginx
confim and restart php fpm
systemctl start php-fpm
systemctl enable php-fpm
7. add vhost to nginx
nano /etc/nginx/conf.d/domain-or-ip.conf
then add vhost
server {
listen 80;
server_name 192.168.8.42;
root /var/www/html;
index index.php index.html index.htm;
autoindex on;
location / {
try_files $uri $uri/ /index.php$query_string;
}
#remove # on spesific aplication root
#location /application/ {
# try_files $uri $uri/ /aplication/index.php$args;
#}
error_page 404 /usr/share/nginx/html/404.html;
error_page 500 502 503 504 /usr/share/nginx/html/50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
now restart nginx to applay
systemctl reload nginx
good look!
Iklan ada di sini
Komentar