fix: database,nginx,php fixes

This commit is contained in:
Aliberk Sandıkçı 2023-12-21 03:39:59 +03:00
parent 4c4d0d9c87
commit 72105618d3
Signed by: asandikci
GPG key ID: 25C67A03B5666BC1

View file

@ -35,7 +35,7 @@ class Config {
const BASE_URL = 'http://localhost:8000';
const LANGUAGE = 'turkish';
const DEBUG_MODE = TRUE;
const DEBUG_MODE = FALSE;
// ------------------------------------------------------------------------
// DATABASE SETTINGS
@ -61,31 +61,52 @@ class Config {
/* Location: ./config.php */
"""
NGINX_CONFIG_FILE="""
OLD_CONFIG="""
server {
listen 80;
server_name localhost;
listen 80;
server_name localhost:8000;
root /usr/share/nginx/html;
access_log /var/log/nginx/example.journaldev.com-access.log;
error_log /var/log/nginx/example.journaldev.com-error.log error;
index index.php;
location / {
# alias /usr/share/nginx/html/;
root /usr/share/nginx/html/;
try_files \$uri \$uri/ /index.php\$is_args\$args;
}
location ~ \.php\$ {
fastcgi_split_path_info ^(.+\.php)(/.+)\$;
fastcgi_pass unix:/var/run/php/php8.2-fpm-iflrandevu.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
"""
NGINX_CONFIG_FILE="""
server {
listen 80;
server_name localhost:8000;
location / {
alias /usr/share/nginx/html/;
#root /usr/share/nginx/html/;
index index.php;
# Common parameter to increase upload size limit in conjunction with dedicated php-fpm file
# client_max_body_size 50M;
client_max_body_size 50M;
# try_files \$uri \$uri/ index.php;
# location ~ [^/]\.php(/|\$) {
# fastcgi_split_path_info ^(.+?\.php)(/.*)\$;
# fastcgi_pass unix:/var/run/php/php8.2-fpm-iflrandevu.sock;
try_files \$uri \$uri/ index.php;
location ~ [^/]\.php(/|\$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)\$;
fastcgi_pass unix:/var/run/php/php8.2-fpm-iflrandevu.sock;
# fastcgi_index index.php;
# include fastcgi_params;
# fastcgi_param REMOTE_USER \$remote_user;
# fastcgi_param PATH_INFO \$fastcgi_path_info;
# fastcgi_param SCRIPT_FILENAME \$request_filename;
# }
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER \$remote_user;
fastcgi_param PATH_INFO \$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME \$request_filename;
}
}
error_page 500 502 503 504 /50x.html;
@ -95,6 +116,33 @@ server {
}
"""
PHP_FPM_CONFIG_FILE="""
[iflrandevu]
user = iflrandevu
group = iflrandevu
chdir = /usr/share/nginx/html
listen = /var/run/php/php8.2-fpm-iflrandevu.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0660
pm = ondemand
pm.max_children = 8
pm.max_requests = 500
request_terminate_timeout = 1d
pm.process_idle_timeout = 10s
; Additional php.ini defines, specific to this pool of workers.
php_admin_value[upload_max_filesize] = 50M
php_admin_value[post_max_size] = 50M
"""
############################
############################
@ -120,7 +168,40 @@ elif [[ $1 == "attach" ]]; then
docker attach $CONT_NAME --detach-keys="ctrl-k"
elif [[ $1 == "docker" ]]; then
set -x
echo "alias dock=\"bash /source/$SCRIPT_NAME docker\"" >>/root/.bashrc
eval "$(cat /root/.bashrc | tail -n +10)"
if [[ $2 == "restart" ]]; then
service mariadb restart
service php8.2-fpm restart
sleep 1
service nginx restart
echo
echo
echo
service nginx status
service mariadb status
service php8.2-fpm status
echo
echo
echo "exiting..."
exit
fi
if [[ $2 == "reconf" ]]; then
echo -e "$CONFIG_FILE_CONTENT" >"/usr/share/nginx/html/config.php"
echo -e "$NGINX_CONFIG_FILE" >"/etc/nginx/conf.d/default.conf"
echo -e "$PHP_FPM_CONFIG_FILE" >"/etc/php/8.2/fpm/pool.d/iflrandevu.conf"
echo RECONFIGURED
echo
echo "exiting..."
exit
fi
apt update
apt install nano exa tree wget unzip less -y
cd /usr/share/nginx/html
@ -132,19 +213,28 @@ elif [[ $1 == "docker" ]]; then
wget $DOWNLOAD_LINK
unzip $FILE_NAME
mv $FILE_NAME ../
else
echo -e "${_RED}use docker local or docker remote${_NC}"
fi
### CONFIGURATIONS ###
apt install php php-fpm -y
apt install mariadb-server -y
apt install mariadb-server php-mysql -y
service mariadb start
mysql -u root -e "create database iflrandevu"
mysql -u root -e "set password for root@localhost = password('root');"
echo -e "$CONFIG_FILE_CONTENT" >"config.php"
echo -e "$NGINX_CONFIG_FILE" >"/etc/nginx/conf.d/default.conf"
echo -e "$PHP_FPM_CONFIG_FILE" >"/etc/php/8.2/fpm/pool.d/iflrandevu.conf"
groupadd iflrandevu
useradd -g iflrandevu iflrandevu
cd /usr/share/nginx/html
chown iflrandevu:nginx -R .
chmod 770 storage
service php8.2-fpm start
service nginx start
service nginx status
service nginx restart