Главная
>
Linux > centos — настройка web-сервера (apache, mysql, php)
centos — настройка web-сервера (apache, mysql, php)
hostnamectl set-hostname site.ru
yum update
yum install mc
mcedit ~/.bash_profile
export EDITOR=mcedit
##apache
yum install httpd
systemctl start httpd.service
systemctl enable httpd.service
##mysql
yum install mariadb-server mariadb
systemctl start mariadb
mysql_secure_installation
systemctl enable mariadb.service
##php centos 8
yum install php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mbstring php-curl php-xml php-pear php-bcmath php-json
##php centos 7
#yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
#yum -y install yum-utils
yum-config-manager --enable remi-php74
yum update
yum install php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json
##firewall
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
##vhosts
mcedit /etc/httpd/conf.d/0default.conf
<VirtualHost *:80>
ServerName site.local
ServerAdmin webmaster@site.ru
DocumentRoot /var/www/html
ErrorLog /var/log/httpd/default_error.log
CustomLog /var/log/httpd/default_access.log combined
</VirtualHost>
mkdir /var/www/site.ru
mcedit /etc/httpd/conf.d/site.ru.conf
<VirtualHost *:80>
ServerName site.ru
ServerAlias www.site.ru
ServerAdmin webmaster@site.ru
DocumentRoot /var/www/site.ru
ErrorLog /var/log/httpd/site.ru_error.log
CustomLog /var/log/httpd/site.ru_access.log combined
</VirtualHost>
##php.ini
mcedit /etc/php.ini
short_open_tag = On
upload_max_filesize = 2048M
max_file_uploads = 1000
post_max_size = 8192M
max_execution_time = 14400
max_input_time = 28800
max_input_vars = 10000
memory_limit = 4096M
##apache conf
mcedit /etc/httpd/conf/httpd.conf
AllowOverride All
##restart apache
apachectl restart
##disable MySQL Strict Mode
mcedit /etc/my.cnf
sql_mode=NO_ENGINE_SUBSTITUTION
service mariadb restart
##export db from old server
mysqldump -uDB_USER -p -h localhost DB_NAME > dump.sql
##import db
mysql -uDB_USER -p -h localhost DB_NAME < dump.sql
##files
chown -R apache:apache /var/www/site.ru/
find /var/www/site.ru/ -type d -exec chmod 775 {} \;
find /var/www/site.ru/ -type f -exec chmod 664 {} \;
##lets encrypt
#yum install epel-release
yum install snapd
systemctl enable --now snapd.socket
ln -s /var/lib/snapd/snap /snap
reboot
snap install core
snap refresh core
snap install --classic certbot
ln -s /snap/bin/certbot /usr/bin/certbot
yum install mod_ssl
apachectl restart
certbot --apache
##processlist
mysqladmin -uDB_USER -p -i 1 processlist