Skip to content

Instantly share code, notes, and snippets.

@codemobiles
Forked from huangqiheng/build_mysql.sh
Last active November 3, 2020 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codemobiles/522417b242637991ef5a44b96978ac37 to your computer and use it in GitHub Desktop.
Save codemobiles/522417b242637991ef5a44b96978ac37 to your computer and use it in GitHub Desktop.
Build and install MySQL 5.1 from source on Ubuntu 18.04
https://programmersought.com/article/99584829847/
# Crontab
@reboot /usr/local/php52/sbin/php-fpm start
#!/bin/bash
# Run as root
yum install make
yum install readline-devel
yum install ncurses-devel
yum install ncurses-compat-libs
useradd mysql
cd /opt
wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.73.tar.gz
tar xzvf mysql-5.1.73.tar.gz
cd mysql-5.1.73
./configure \
'--prefix=/usr' \
'--exec-prefix=/usr' \
'--libexecdir=/usr/sbin' \
'--datadir=/usr/share' \
'--localstatedir=/var/lib/mysql' \
'--includedir=/usr/include' \
'--infodir=/usr/share/info' \
'--mandir=/usr/share/man' \
'--with-system-type=debian-linux-gnu' \
'--enable-shared' \
'--enable-static' \
'--enable-thread-safe-client' \
'--enable-assembler' \
'--enable-local-infile' \
'--with-fast-mutexes' \
'--with-big-tables' \
'--with-unix-socket-path=/var/run/mysqld/mysqld.sock' \
'--with-mysqld-user=mysql' \
'--with-libwrap' \
'--with-readline' \
'--with-ssl' \
'--without-docs' \
'--with-extra-charsets=all' \
'--with-plugins=max' \
'--with-embedded-server' \
'--with-embedded-privilege-control' \
CXXFLAGS="-Wno-narrowing -fpermissive"
make
make install
mkdir -p /etc/mysql
mkdir -p /var/lib/mysql
mkdir -p /etc/mysql/conf.d
echo -e '[mysqld_safe]\nsyslog' > /etc/mysql/conf.d/mysqld_safe_syslog.cnf
cp /usr/share/mysql/my-medium.cnf /etc/mysql/my.cnf
sed -i 's#.*datadir.*#datadir = /var/lib/mysql#g' /etc/mysql/my.cnf
chown mysql:mysql -R /var/lib/mysql
mysql_install_db --user=mysql
mysqld_safe -user=mysql &
/usr/bin/mysql_secure_installation
cp /usr/share/mysql/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig mysql on
# For Vhost
NameVirtualHost 150.95.30.195:80
<VirtualHost 150.95.30.195:80>
ServerAdmin admin@codemobilse.com
ServerName localhost
#ServerAlias www.codemobiles.com
DocumentRoot /var/www/html/codemobiles.com/public_html/
<Directory "/var/www/html/codemobiles.com/public_html/">
DirectoryIndex index.php index.html index.htm
AllowOverride All
Options All
RewriteEngine on
RewriteBase /
Order allow,deny
Allow from all
Require all granted
</Directory>
ErrorLog /var/www/html/codemobiles.com/logs/error.log
CustomLog /var/www/html/codemobiles.com/logs/access.log combined
# In case for PHP-FPM 5.2 compatibility use 'GENERIC' instead of 'FPM'
# https://httpd.apache.org/docs/2.4/mod/mod_proxy_fcgi.html#proxyfcgibackendtype
ProxyFCGIBackendType GENERIC
# PHP-FPM Definition
<FilesMatch \.php$>
Require all granted
SetHandler proxy:fcgi://localhost:9000#
</FilesMatch>
<Proxy "fcgi://localhost:9000/">
ProxySet timeout=180
ProxySet connectiontimeout=180
</Proxy>
# If the php file doesn't exist, disable the proxy handler.
# This will allow .htaccess rewrite rules to work and
# the client will see the default 404 page of Apache
RewriteCond %{REQUEST_FILENAME} \.php$
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
RewriteRule (.*) - [H=text/html]
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment